minor changes

This commit is contained in:
Gunar Schorcht 2018-01-06 15:39:19 +01:00
parent 2d52ad85b4
commit 6e1bfd2845
3 changed files with 78 additions and 58 deletions

View file

@ -250,32 +250,25 @@ void user_init(void)
if (sensor)
{
// --- SYSTEM CONFIGURATION PART ----
#ifdef INT_USED
/** --- INTERRUPT CONFIGURATION PART ---- */
#if !defined (INT_USED)
// Interrupt configuration has to be done before the sensor is set
// into measurement mode to avoid losing interrupts
// 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);
// create event queue
// create an event queue to send interrupt events from interrupt
// handler to the interrupt task
gpio_evt_queue = xQueueCreate(10, sizeof(uint8_t));
// configure interupt pins for *INT1* and *INT2* signals and set the interrupt handler
gpio_enable(INT1_PIN, GPIO_INPUT);
gpio_set_interrupt(INT1_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 polarity of INT signals if necessary
// lis3dh_config_int_signals (sensor, lis3dh_high_active);
@ -351,7 +344,24 @@ void user_init(void)
lis3dh_set_scale(sensor, lis3dh_scale_2_g);
lis3dh_set_mode (sensor, lis3dh_odr_10, lis3dh_high_res, true, true, true);
// -- 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 LIS3DH sensor\n");
}