@@ -79,47 +79,21 @@ si5351c_driver_t clock_gen = {
7979 .i2c_address = 0x60 ,
8080};
8181
82- spi_bus_t spi_bus_ssp1 = {
83- .obj = (void * ) SSP1_BASE ,
84- .config = & ssp_config_max5864 ,
85- .start = spi_ssp_start ,
86- .stop = spi_ssp_stop ,
87- .transfer = spi_ssp_transfer ,
88- .transfer_gather = spi_ssp_transfer_gather ,
89- };
90-
91- #ifdef PRALINE
92- const ssp_config_t ssp_config_max283x = {
93- /* FIXME speed up once everything is working reliably */
94- /*
95- // Freq About 0.0498MHz / 49.8KHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
96- const uint8_t serial_clock_rate = 32;
97- const uint8_t clock_prescale_rate = 128;
98- */
99- // Freq About 4.857MHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
100- .data_bits = SSP_DATA_9BITS , // send 2 words
101- .serial_clock_rate = 21 ,
102- .clock_prescale_rate = 2 ,
103- .gpio_select = & gpio_max283x_select ,
104- };
105- #else
106- const ssp_config_t ssp_config_max283x = {
82+ static ssp_config_t ssp_config_max283x = {
10783 /* FIXME speed up once everything is working reliably */
10884 /*
10985 // Freq About 0.0498MHz / 49.8KHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
11086 const uint8_t serial_clock_rate = 32;
11187 const uint8_t clock_prescale_rate = 128;
11288 */
11389 // Freq About 4.857MHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
114- .data_bits = SSP_DATA_16BITS ,
11590 .serial_clock_rate = 21 ,
11691 .clock_prescale_rate = 2 ,
117- .gpio_select = & gpio_max283x_select ,
11892};
119- #endif
93+
12094max283x_driver_t max283x = {};
12195
122- const ssp_config_t ssp_config_max5864 = {
96+ static ssp_config_t ssp_config_max5864 = {
12397 /* FIXME speed up once everything is working reliably */
12498 /*
12599 // Freq About 0.0498MHz / 49.8KHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
@@ -130,22 +104,29 @@ const ssp_config_t ssp_config_max5864 = {
130104 .data_bits = SSP_DATA_8BITS ,
131105 .serial_clock_rate = 21 ,
132106 .clock_prescale_rate = 2 ,
133- .gpio_select = & gpio_max5864_select ,
107+ };
108+
109+ spi_bus_t spi_bus_ssp1 = {
110+ .obj = (void * ) SSP1_BASE ,
111+ .config = & ssp_config_max5864 ,
112+ .start = spi_ssp_start ,
113+ .stop = spi_ssp_stop ,
114+ .transfer = spi_ssp_transfer ,
115+ .transfer_gather = spi_ssp_transfer_gather ,
134116};
135117
136118max5864_driver_t max5864 = {
137119 .bus = & spi_bus_ssp1 ,
138120 .target_init = max5864_target_init ,
139121};
140122
141- const ssp_config_t ssp_config_w25q80bv = {
123+ ssp_config_t ssp_config_w25q80bv = {
142124 .data_bits = SSP_DATA_8BITS ,
143125 .serial_clock_rate = 2 ,
144126 .clock_prescale_rate = 2 ,
145- .gpio_select = & gpio_w25q80bv_select ,
146127};
147128
148- spi_bus_t spi_bus_ssp0 = {
129+ static spi_bus_t spi_bus_ssp0 = {
149130 .obj = (void * ) SSP0_BASE ,
150131 .config = & ssp_config_w25q80bv ,
151132 .start = spi_ssp_start ,
@@ -156,39 +137,27 @@ spi_bus_t spi_bus_ssp0 = {
156137
157138w25q80bv_driver_t spi_flash = {
158139 .bus = & spi_bus_ssp0 ,
159- .gpio_hold = & gpio_w25q80bv_hold ,
160- .gpio_wp = & gpio_w25q80bv_wp ,
161140 .target_init = w25q80bv_target_init ,
162141};
163142
164143sgpio_config_t sgpio_config = {
165- .gpio_q_invert = & gpio_q_invert ,
166- #ifndef PRALINE
167- .gpio_trigger_enable = & gpio_trigger_enable ,
168- #endif
169144 .slice_mode_multislice = true,
170145};
171146
172- #ifdef PRALINE
173- const ssp_config_t ssp_config_ice40_fpga = {
147+ static ssp_config_t ssp_config_ice40_fpga = {
174148 .data_bits = SSP_DATA_8BITS ,
175149 .spi_mode = SSP_CPOL_1_CPHA_1 ,
176150 .serial_clock_rate = 21 ,
177151 .clock_prescale_rate = 2 ,
178- .gpio_select = & gpio_fpga_cfg_spi_cs ,
179152};
180153
181154ice40_spi_driver_t ice40 = {
182155 .bus = & spi_bus_ssp1 ,
183- .gpio_select = & gpio_fpga_cfg_spi_cs ,
184- .gpio_creset = & gpio_fpga_cfg_creset ,
185- .gpio_cdone = & gpio_fpga_cfg_cdone ,
186156};
187157
188158fpga_driver_t fpga = {
189159 .bus = & ice40 ,
190160};
191- #endif
192161
193162radio_t radio = {
194163 .channel [RADIO_CHANNEL0 ] =
@@ -228,18 +197,7 @@ radio_t radio = {
228197// rf_path gpio's now get assigned in pin_setup() TODO delete comment
229198rf_path_t rf_path ;
230199
231- jtag_gpio_t jtag_gpio_cpld = {
232- .gpio_tck = & gpio_cpld_tck ,
233- #ifndef PRALINE
234- .gpio_tms = & gpio_cpld_tms ,
235- .gpio_tdi = & gpio_cpld_tdi ,
236- .gpio_tdo = & gpio_cpld_tdo ,
237- #endif
238- #if (defined HACKRF_ONE || defined PRALINE )
239- .gpio_pp_tms = & gpio_cpld_pp_tms ,
240- .gpio_pp_tdo = & gpio_cpld_pp_tdo ,
241- #endif
242- };
200+ jtag_gpio_t jtag_gpio_cpld ;
243201
244202jtag_t jtag_cpld = {
245203 .gpio = & jtag_gpio_cpld ,
@@ -1007,6 +965,7 @@ void pin_setup(void)
1007965 const platform_gpio_t * gpio = platform_gpio ();
1008966 const platform_scu_t * scu = platform_scu ();
1009967
968+ /* Configure LEDs */
1010969 led_off (0 );
1011970 led_off (1 );
1012971 led_off (2 );
@@ -1030,6 +989,47 @@ void pin_setup(void)
1030989 break ;
1031990 }
1032991
992+ /* Configure drivers and driver pins */
993+ ssp_config_max283x .gpio_select = gpio -> max283x_select ;
994+ if (board_id == BOARD_ID_PRALINE ) {
995+ ssp_config_max283x .data_bits = SSP_DATA_9BITS ; // send 2 words
996+ } else {
997+ ssp_config_max283x .data_bits = SSP_DATA_16BITS ;
998+ }
999+
1000+ ssp_config_max5864 .gpio_select = gpio -> max5864_select ;
1001+
1002+ ssp_config_w25q80bv .gpio_select = gpio -> w25q80bv_select ;
1003+ spi_flash .gpio_hold = gpio -> w25q80bv_hold ;
1004+ spi_flash .gpio_wp = gpio -> w25q80bv_wp ;
1005+
1006+ sgpio_config .gpio_q_invert = gpio -> q_invert ;
1007+ if (board_id != BOARD_ID_PRALINE ) {
1008+ sgpio_config .gpio_trigger_enable = gpio -> trigger_enable ;
1009+ }
1010+
1011+ ssp_config_ice40_fpga .gpio_select = gpio -> fpga_cfg_spi_cs ;
1012+ ice40 .gpio_select = gpio -> fpga_cfg_spi_cs ;
1013+ ice40 .gpio_creset = gpio -> fpga_cfg_creset ;
1014+ ice40 .gpio_cdone = gpio -> fpga_cfg_cdone ;
1015+
1016+ jtag_gpio_cpld .gpio_tck = gpio -> cpld_tck ;
1017+ if (board_id != BOARD_ID_PRALINE ) {
1018+ jtag_gpio_cpld .gpio_tms = gpio -> cpld_tms ;
1019+ jtag_gpio_cpld .gpio_tdi = gpio -> cpld_tdi ;
1020+ jtag_gpio_cpld .gpio_tdo = gpio -> cpld_tdo ;
1021+ }
1022+ switch (board_id ) {
1023+ case BOARD_ID_HACKRF1_OG :
1024+ case BOARD_ID_HACKRF1_R9 :
1025+ case BOARD_ID_PRALINE :
1026+ jtag_gpio_cpld .gpio_pp_tms = gpio -> cpld_pp_tms ;
1027+ jtag_gpio_cpld .gpio_pp_tdo = gpio -> cpld_pp_tdo ;
1028+ break ;
1029+ default :
1030+ break ;
1031+ }
1032+
10331033 ssp1_set_mode_max283x ();
10341034
10351035 mixer_bus_setup (& mixer );
0 commit comments