@@ -306,20 +306,25 @@ int32_t port_init(void) {
306306 "profiler1"
307307 );
308308
309+ /* Configure and release all CS lines. */
310+ gpio_set (GPIOB , GPIO2 | GPIO12 );
311+ gpio_mode_setup (GPIOB , GPIO_MODE_OUTPUT , GPIO_PUPD_NONE , GPIO2 | GPIO12 );
312+ gpio_set_output_options (GPIOB , GPIO_OTYPE_PP , GPIO_OSPEED_2MHZ , GPIO2 | GPIO12 );
313+
309314 /* Configure GPIO for radio & flash SPI bus (SPI2), enable SPI2 clock and
310315 * run spibus driver using libopencm3 to access it. */
311316 gpio_mode_setup (GPIOB , GPIO_MODE_AF , GPIO_PUPD_NONE , GPIO13 | GPIO14 | GPIO15 );
312- gpio_set_output_options (GPIOB , GPIO_OTYPE_PP , GPIO_OSPEED_50MHZ , GPIO13 | GPIO14 | GPIO15 );
317+ gpio_set_output_options (GPIOB , GPIO_OTYPE_PP , GPIO_OSPEED_2MHZ , GPIO13 | GPIO14 | GPIO15 );
313318 gpio_set_af (GPIOB , GPIO_AF5 , GPIO13 | GPIO14 | GPIO15 );
314319 rcc_periph_clock_enable (RCC_SPI2 );
315- rcc_periph_reset_pulse (RST_SPI2 );
320+ // rcc_periph_reset_pulse(RST_SPI2);
316321 module_spibus_locm3_init (& spi2 , "spi2" , SPI2 );
317322 hal_interface_set_name (& (spi2 .iface .descriptor ), "spi2" );
318323
319324 /* Initialize SPI device on the SPI2 bus. */
320325 gpio_set (GPIOB , GPIO12 );
321326 gpio_mode_setup (GPIOB , GPIO_MODE_OUTPUT , GPIO_PUPD_NONE , GPIO12 );
322- gpio_set_output_options (GPIOB , GPIO_OTYPE_PP , GPIO_OSPEED_50MHZ , GPIO12 );
327+ gpio_set_output_options (GPIOB , GPIO_OTYPE_PP , GPIO_OSPEED_2MHZ , GPIO12 );
323328 module_spidev_locm3_init (& spi2_flash1 , "spi2_flash1" , & (spi2 .iface ), GPIOB , GPIO12 );
324329 hal_interface_set_name (& (spi2_flash1 .iface .descriptor ), "spi2_flash1" );
325330
@@ -331,20 +336,19 @@ int32_t port_init(void) {
331336 & (spi_flash_interface (& spi_flash1 )-> interface ),
332337 "spi-flash1"
333338 );
339+ #if defined(CONFIG_SERVICE_FS_SPIFFS )
340+ fs_spiffs_init (& spiffs1 );
341+ // fs_spiffs_format(&spiffs1, spi_flash_interface(&spi_flash1));
342+ if (fs_spiffs_mount (& spiffs1 , spi_flash_interface (& spi_flash1 )) == FS_SPIFFS_RET_OK ) {
343+ iservicelocator_add (
344+ locator ,
345+ ISERVICELOCATOR_TYPE_FS ,
346+ & (fs_spiffs_interface (& spiffs1 )-> interface ),
347+ "system"
348+ );
349+ }
350+ #endif
334351 }
335-
336- #if defined(CONFIG_SERVICE_FS_SPIFFS )
337- fs_spiffs_init (& spiffs1 );
338- // fs_spiffs_format(&spiffs1, spi_flash_interface(&spi_flash1));
339- if (fs_spiffs_mount (& spiffs1 , spi_flash_interface (& spi_flash1 )) == FS_SPIFFS_RET_OK ) {
340- iservicelocator_add (
341- locator ,
342- ISERVICELOCATOR_TYPE_FS ,
343- & (fs_spiffs_interface (& spiffs1 )-> interface ),
344- "system"
345- );
346- }
347- #endif
348352 #endif
349353
350354 /* ADC initialization (power metering, prng seeding) */
@@ -562,9 +566,9 @@ int32_t port_init(void) {
562566 #if defined(CONFIG_PLUMPOT_CELLULAR_MQTT_OVER_GSM )
563567
564568 /** @todo generic service move to the system init */
565- mqtt_sensor_upload_init (& mqtt_sensor , & mqtt , "plumpot1 /s" , 120000 );
569+ mqtt_sensor_upload_init (& mqtt_sensor , & mqtt , CONFIG_HOSTNAME " /s" , 120000 );
566570
567- stream_over_mqtt_init (& mqtt_cli_stream , & mqtt , "plumpot1 /cli" , 0 );
571+ stream_over_mqtt_init (& mqtt_cli_stream , & mqtt , CONFIG_HOSTNAME " /cli" , 0 );
568572 stream_over_mqtt_start (& mqtt_cli_stream );
569573 service_cli_init (& mqtt_cli , & (mqtt_cli_stream .stream ), system_cli_tree );
570574 service_cli_start (& mqtt_cli );
0 commit comments