int main(void) { init(); // Start event loop. This will start a new thread and return sc_event_loop_start(); // Register callbacks. // These will be called from Event Loop thread. It's OK to do some // calculations etc. time consuming there, but not to sleep or block // for longer periods of time. sc_event_register_handle_byte(cb_handle_byte); sc_event_register_9dof_available(cb_9dof_available); sc_event_register_ahrs_available(cb_ahrs_available); #if defined(BOARD_ST_STM32F4_DISCOVERY) // Register user button on F4 discovery sc_extint_set_event(GPIOA, GPIOA_BUTTON, SC_EXTINT_EDGE_BOTH); sc_event_register_extint(GPIOA_BUTTON, cb_button_changed); #endif sc_9dof_init(64); sc_ahrs_init(); // Loop forever waiting for callbacks while(1) { uint8_t msg[] = {'d', ':', ' ', 'p','i','n','g','\r','\n'}; chThdSleepMilliseconds(1000); sc_uart_send_msg(SC_UART_LAST, msg, 9); } return 0; }
int main(void) { halInit(); /* Initialize ChibiOS core */ chSysInit(); sc_init(SC_MODULE_UART2 | SC_MODULE_GPIO | SC_MODULE_LED | SC_MODULE_SDU | SC_MODULE_RADIO); sc_uart_default_usb(TRUE); sc_log_output_uart(SC_UART_USB); // Start event loop. This will start a new thread and return sc_event_loop_start(); // Register callbacks. // These will be called from Event Loop thread. It's OK to do some // calculations etc. time consuming there, but not to sleep or block // for longer periods of time. sc_event_register_handle_byte(cb_handle_byte); sc_event_register_blob_available(cb_blob_available); sc_event_register_extint(0, cb_pa0_changed); sc_extint_set_event(GPIOA, 0, SC_EXTINT_EDGE_BOTH); // Loop forever waiting for callbacks while(1) { uint8_t msg[] = {'d', ':', ' ', 'p','i','n','g','\r','\n'}; chThdSleepMilliseconds(1000); sc_uart_send_msg(SC_UART_USB, msg, sizeof(msg)); } return 0; }
int main(void) { halInit(); /* Initialize ChibiOS core */ chSysInit(); sc_init(SC_MODULE_LED); // Start event loop. This will start a new thread and return sc_event_loop_start(); #if defined CH_NO_IDLE_THREAD && CH_NO_IDLE_THREAD chThdSetPriority(IDLEPRIO); #endif // Loop forever waiting for callbacks while(1) { sc_led_toggle(); #if defined CH_NO_IDLE_THREAD && CH_NO_IDLE_THREAD chDbgAssert(0, "Can't call chThdSleepMilliseconds() without idle thread"); #endif chThdSleepMilliseconds(1000); } return 0; }
int main(void) { halInit(); /* Initialize ChibiOS core */ chSysInit(); // Init SC framework, with USB if not F1 Discovery #if defined(BOARD_ST_STM32VL_DISCOVERY) sc_init(SC_MODULE_UART1 | SC_MODULE_PWM | SC_MODULE_ADC | SC_MODULE_GPIO | SC_MODULE_LED); #else sc_init(SC_MODULE_UART1 | SC_MODULE_PWM | SC_MODULE_SDU | SC_MODULE_ADC | SC_MODULE_GPIO | SC_MODULE_LED); sc_uart_default_usb(TRUE); #endif // Start event loop. This will start a new thread and return sc_event_loop_start(); // Register callbacks. // These will be called from Event Loop thread. It's OK to do some // calculations etc. time consuming there, but not to sleep or block. sc_event_register_handle_byte(cb_handle_byte); sc_event_register_adc_available(cb_adc_available); // Start periodic ADC readings #if defined(BOARD_ST_STM32VL_DISCOVERY) // FIXME: Not tested sc_adc_start_conversion(3, 1000, ADC_SAMPLE_55P5); #else sc_adc_start_conversion(3, 1000, ADC_SAMPLE_56); #endif // Loop forever waiting for callbacks while(1) { uint8_t msg[] = {'d', ':', ' ', 'p','i','n','g','\r','\n'}; chThdSleepMilliseconds(1000); sc_uart_send_msg(SC_UART_LAST, msg, 9); } return 0; }
int main(void) { standby = sc_pwr_get_standby_flag(); wkup = sc_pwr_get_wake_up_flag(); // Enable debugging even with WFI // This increases the power consumption by 1.5mA sc_pwr_set_wfi_dbg(); halInit(); chSysInit(); sc_init(SC_MODULE_GPIO | SC_MODULE_SPI | SC_MODULE_UART2); sc_log_output_uart(SC_UART_2); // Start event loop. This will start a new thread and return sc_event_loop_start(); SC_LOG_PRINTF("started\r\n"); // Register callbacks. // These will be called from Event Loop thread. It's OK to do some // calculations etc. time consuming there, but not to sleep or block // for longer periods of time. sc_event_register_handle_byte(cb_handle_byte); sc_event_register_spirit1_msg_available(cb_spirit1_msg); sc_event_register_spirit1_data_sent(cb_spirit1_sent); sc_event_register_spirit1_data_lost(cb_spirit1_lost); sc_spirit1_init(TOP_SECRET_KEY, MY_ADDRESS); SC_LOG_PRINTF("spirit1 init done\r\n"); while(1) { uint8_t msg[] = {'t', 'e', 's', 't', '\r', '\n', '\0'}; chThdSleepMilliseconds(1000); SC_LOG_PRINTF("sending: test\r\n"); sc_spirit1_send(SPIRIT1_BROADCAST_ADDRESS, msg, sizeof(msg) - 1); } }