semaphore for SPI bus access removed from the driver, the user has to deal with concurrency

This commit is contained in:
Gunar Schorcht 2018-01-06 15:41:03 +01:00
parent 29735aa7c4
commit 1dbe9e46c4
4 changed files with 80 additions and 74 deletions

View file

@ -13,7 +13,7 @@
* | GPIO 14 (SCL) ----> SCL |
* | GPIO 13 (SDA) <---> SDA |
* | GPIO 5 <---- INT1 |
* | GPIO 4 <---- INT2 |
* | GPIO 4 <---- INT2 |
* +-----------------+ +----------+
*
* SPI
@ -289,17 +289,12 @@ void user_init(void)
if (sensor)
{
// --- SYSTEM CONFIGURATION PART ----
#ifdef INT_USED
/** --- INTERRUPT CONFIGURATION PART ---- */
#if !defined (INT_USED)
// create a user task that fetches data from sensor periodically
xTaskCreate(user_task_periodic, "user_task_periodic", TASK_STACK_DEPTH, NULL, 2, NULL);
#else // INT_USED
// create a task that is triggered only in case of interrupts to fetch the data
xTaskCreate(user_task_interrupt, "user_task_interrupt", TASK_STACK_DEPTH, NULL, 2, NULL);
// Interrupt configuration has to be done before the sensor is set
// into measurement mode to avoid losing interrupts
// create an event queue to send interrupt events from interrupt
// handler to the interrupt task
@ -311,13 +306,10 @@ void user_init(void)
gpio_set_interrupt(INT1_PIN, GPIO_INTTYPE_EDGE_POS, int_signal_handler);
gpio_set_interrupt(INT2_PIN, GPIO_INTTYPE_EDGE_POS, int_signal_handler);
#endif // !defined(INT_USED)
#endif // INT_USED
// -- SENSOR CONFIGURATION PART ---
/** -- SENSOR CONFIGURATION PART --- */
// Interrupt configuration has to be done before the sensor is set
// into measurement mode
// set the type of INTx signals if necessary
// lsm303d_config_int_signals (sensor, lsm303d_push_pull);
@ -417,7 +409,24 @@ void user_init(void)
lsm303d_set_a_mode (sensor, lsm303d_a_odr_12_5, lsm303d_a_aaf_bw_773, true, true, true);
lsm303d_set_m_mode (sensor, lsm303d_m_odr_12_5, lsm303d_m_low_res, lsm303d_m_continuous);
// -- SENSOR CONFIGURATION PART ---
/** -- TASK CREATION PART --- */
// must be done last to avoid concurrency situations with the sensor
// configuration part
#ifdef INT_USED
// create a task that is triggered only in case of interrupts to fetch the data
xTaskCreate(user_task_interrupt, "user_task_interrupt", TASK_STACK_DEPTH, NULL, 2, NULL);
#else // INT_USED
// create a user task that fetches data from sensor periodically
xTaskCreate(user_task_periodic, "user_task_periodic", TASK_STACK_DEPTH, NULL, 2, NULL);
#endif
}
else
printf("Could not initialize LSM303D sensor\n");
}