void user_init(void) { // Set UART Parameter. uart_set_baud(0, 115200); // Give the UART some time to settle vTaskDelay(1); /** -- MANDATORY PART -- */ #ifdef SPI_USED spi_bus_init (SPI_BUS, SPI_SCK_GPIO, SPI_MISO_GPIO, SPI_MOSI_GPIO); // init the sensor connected to SPI_BUS with SPI_CS_GPIO as chip select. sensor = bme680_init_sensor (SPI_BUS, 0, SPI_CS_GPIO); #else // I2C // Init all I2C bus interfaces at which BME680 sensors are connected i2c_init(I2C_BUS, I2C_SCL_PIN, I2C_SDA_PIN, I2C_FREQ); // init the sensor with slave address BME680_I2C_ADDRESS_2 connected to I2C_BUS. sensor = bme680_init_sensor (I2C_BUS, BME680_I2C_ADDRESS_2, 0); #endif // SPI_USED if (sensor) { /** -- SENSOR CONFIGURATION PART (optional) --- */ // Changes the oversampling rates to 4x oversampling for temperature // and 2x oversampling for humidity. Pressure measurement is skipped. bme680_set_oversampling_rates(sensor, osr_4x, osr_none, osr_2x); // Change the IIR filter size for temperature and pressure to 7. bme680_set_filter_size(sensor, iir_size_7); // Change the heater profile 0 to 200 degree Celcius for 100 ms. bme680_set_heater_profile (sensor, 0, 200, 100); bme680_use_heater_profile (sensor, 0); // Set ambient temperature to 10 degree Celsius bme680_set_ambient_temperature (sensor, 10); /** -- TASK CREATION PART --- */ // must be done last to avoid concurrency situations with the sensor // configuration part // Create a task that uses the sensor xTaskCreate(user_task, "user_task", TASK_STACK_DEPTH, NULL, 2, NULL); } else printf("Could not initialize BME680 sensor\n"); }
void setup_task(void * pvParameters) { /* Initialize the I2C bus. */ trace_printf("initialize I2C bus\n"); i2c_bus_init(); /* Initialize the SPI bus. */ trace_printf("initialize SPI bus\n"); spi_bus_init(); #if BEACON_TASK trace_printf("starting beacon task\n"); xTaskCreate(beacon_task, BEACON_TASK_NAME, BEACON_TASK_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); #endif #if CAMERA_TASK trace_printf("starting camera task\n"); xTaskCreate(camera_task, CAMERA_TASK_NAME, CAMERA_TASK_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); #endif #if SKYWIRE_TASK trace_printf("starting skywire task\n"); xTaskCreate(skywire_task, SKYWIRE_TASK_NAME, SKYWIRE_TASK_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); #endif #if RECEIVE_TASK trace_printf("starting receiver task\n"); xTaskCreate(receive_task, RECEIVE_TASK_NAME, RECEIVE_TASK_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); #endif /* Delete the setup task. */ vTaskDelete(NULL); trace_printf("Setup complete\n"); }
void main() { //Local Declarations color_t my_color; uint16_t speed = 30; my_color.red = 1; spi_bus_init(); Delay_ms(300); while(1) { receive_data( &buffer, 1 ); switch( buffer[0] ) { case SETUP_CMD: setup_command(); break; case IMAGE_LOAD_CMD: image_load_command(); break; case SCROLL_IMG_LEFT_CMD: scroll_img_left_command(); break; case SCROLL_IMG_RIGHT_CMD: scroll_img_right_command(); break; case WRITE_PXL_CMD: write_pxl_command(); break; case WRITE_PXL_IMG_CMD: write_pxl_img_command(); break; case ERASE_PXL_CMD: erase_pxl_command(); break; case SCROLL_TEXT_LEFT_CMD: scroll_text_left_command(); break; case SCROLL_TEXT_RIGHT_CMD: scroll_text_right_command(); break; case DISPLAY_SHIFT_UP_CMD: display_shift_up_command(); break; case DISPLAY_SHIFT_DOWN_CMD: display_shift_down_command(); break; case DISPLAY_SHIFT_RIGHT_CMD: display_shift_right_command(); break; case DISPLAY_SHIFT_LEFT_CMD: display_shift_left_command(); break; case DISPLAY_SCROLL_OFF_SCRN_UP_CMD: display_scroll_off_scrn_up_command(); break; case DISPLAY_SCROLL_OFF_SCRN_DWN_CMD: display_scroll_off_scrn_down_command(); break; case DISPLAY_SCROLL_OFF_SCRN_LEFT_CMD: display_scroll_off_scrn_left_command(); break; case DISPLAY_SCROLL_OFF_SCRN_RIGHT_CMD: display_scroll_off_scrn_right_command(); break; case REFRESH_CMD: refresh(); break; case CLR_SCRN_CMD: clear_screen_command(); break; default: break; } } }