FreeRTOS type updates. (#261)

This commit is contained in:
Our Air Quality 2016-11-05 21:04:03 +11:00 committed by sheinz
parent 4c84b64566
commit a5cc728079
53 changed files with 151 additions and 148 deletions

View file

@ -34,7 +34,7 @@ As all data aqquired from the BMP180/BMP085 is provided to the `bmp180_informUse
```
// Own BMP180 User Inform Implementation
bool my_informUser(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure) {
bool my_informUser(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure) {
my_event_t ev;
ev.event_type = MY_EVT_BMP180;

View file

@ -214,20 +214,20 @@ bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature,
typedef struct
{
uint8_t cmd;
const xQueueHandle* resultQueue;
const QueueHandle_t* resultQueue;
} bmp180_command_t;
// Just works due to the fact that xQueueHandle is a "void *"
static xQueueHandle bmp180_rx_queue = NULL;
static xTaskHandle bmp180_task_handle = NULL;
// Just works due to the fact that QueueHandle_t is a "void *"
static QueueHandle_t bmp180_rx_queue = NULL;
static TaskHandle_t bmp180_task_handle = NULL;
//
// Forward declarations
//
static bool bmp180_informUser_Impl(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure);
static bool bmp180_informUser_Impl(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure);
// Set default implementation .. User gets result as bmp180_result_t event
bool (*bmp180_informUser)(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure) = bmp180_informUser_Impl;
bool (*bmp180_informUser)(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure) = bmp180_informUser_Impl;
// I2C Driver Task
static void bmp180_driver_task(void *pvParameters)
@ -295,7 +295,7 @@ static bool bmp180_createTask()
}
// Default user inform implementation
static bool bmp180_informUser_Impl(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure)
static bool bmp180_informUser_Impl(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure)
{
bmp180_result_t result;
@ -328,7 +328,7 @@ bool bmp180_init(uint8_t scl, uint8_t sda)
return result;
}
void bmp180_trigger_measurement(const xQueueHandle* resultQueue)
void bmp180_trigger_measurement(const QueueHandle_t* resultQueue)
{
bmp180_command_t c;
@ -339,7 +339,7 @@ void bmp180_trigger_measurement(const xQueueHandle* resultQueue)
}
void bmp180_trigger_pressure_measurement(const xQueueHandle* resultQueue)
void bmp180_trigger_pressure_measurement(const QueueHandle_t* resultQueue)
{
bmp180_command_t c;
@ -349,7 +349,7 @@ void bmp180_trigger_pressure_measurement(const xQueueHandle* resultQueue)
xQueueSend(bmp180_rx_queue, &c, 0);
}
void bmp180_trigger_temperature_measurement(const xQueueHandle* resultQueue)
void bmp180_trigger_temperature_measurement(const QueueHandle_t* resultQueue)
{
bmp180_command_t c;

View file

@ -45,16 +45,16 @@ typedef struct
bool bmp180_init(uint8_t scl, uint8_t sda);
// Trigger a "complete" measurement (temperature and pressure will be valid when given to "bmp180_informUser)
void bmp180_trigger_measurement(const xQueueHandle* resultQueue);
void bmp180_trigger_measurement(const QueueHandle_t* resultQueue);
// Trigger a "temperature only" measurement (only temperature will be valid when given to "bmp180_informUser)
void bmp180_trigger_temperature_measurement(const xQueueHandle* resultQueue);
void bmp180_trigger_temperature_measurement(const QueueHandle_t* resultQueue);
// Trigger a "pressure only" measurement (only pressure will be valid when given to "bmp180_informUser)
void bmp180_trigger_pressure_measurement(const xQueueHandle* resultQueue);
void bmp180_trigger_pressure_measurement(const QueueHandle_t* resultQueue);
// Give the user the chance to create it's own handler
extern bool (*bmp180_informUser)(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure);
extern bool (*bmp180_informUser)(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure);
// Calibration constants
typedef struct

View file

@ -72,7 +72,7 @@ while(1) {
printf("Pressure: %.2f Pa, Temperature: %.2f C", pressure, temperature);
if (bme280p)
printf(", Humidity: %.2f\n", humidity);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
```
@ -96,7 +96,7 @@ while(1) {
printf(", Humidity: %.2f\n", humidity);
else
printf("\n");
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
```

View file

@ -35,7 +35,7 @@
namespace esp_open_rtos {
namespace timer {
#define __millis() (xTaskGetTickCount() * portTICK_RATE_MS)
#define __millis() (xTaskGetTickCount() * portTICK_PERIOD_MS)
/******************************************************************************************************************
* countdown_t
@ -93,7 +93,7 @@ public:
}
private:
portTickType interval_end_ms;
TickType_t interval_end_ms;
};
} // namespace timer {

View file

@ -86,7 +86,7 @@ public:
*/
inline int try_lock(unsigned long ms)
{
return (xSemaphoreTake(mutex, ms / portTICK_RATE_MS) == pdTRUE) ? 0 : -1;
return (xSemaphoreTake(mutex, ms / portTICK_PERIOD_MS) == pdTRUE) ? 0 : -1;
}
/**
*
@ -98,7 +98,7 @@ public:
}
private:
xSemaphoreHandle mutex;
SemaphoreHandle_t mutex;
// Disable copy construction and assignment.
mutex_t (const mutex_t&);

View file

@ -83,7 +83,7 @@ public:
*/
inline int post(const Data& data, unsigned long ms = 0)
{
return (xQueueSend(queue, &data, ms / portTICK_RATE_MS) == pdTRUE) ? 0 : -1;
return (xQueueSend(queue, &data, ms / portTICK_PERIOD_MS) == pdTRUE) ? 0 : -1;
}
/**
*
@ -93,7 +93,7 @@ public:
*/
inline int receive(Data& data, unsigned long ms = 0)
{
return (xQueueReceive(queue, &data, ms / portTICK_RATE_MS) == pdTRUE) ? 0 : -1;
return (xQueueReceive(queue, &data, ms / portTICK_PERIOD_MS) == pdTRUE) ? 0 : -1;
}
/**
*
@ -110,7 +110,7 @@ public:
}
private:
xQueueHandle queue;
QueueHandle_t queue;
// Disable copy construction.
queue_t (const queue_t&);

View file

@ -66,7 +66,7 @@ protected:
*/
void sleep(unsigned long ms)
{
vTaskDelay(ms / portTICK_RATE_MS);
vTaskDelay(ms / portTICK_PERIOD_MS);
}
/**
*
@ -74,7 +74,7 @@ protected:
*/
inline unsigned long millis()
{
return xTaskGetTickCount() * portTICK_RATE_MS;
return xTaskGetTickCount() * portTICK_PERIOD_MS;
}
private:

View file

@ -49,7 +49,7 @@ typedef struct {
/* Only one DHCP server task can run at once, so we have global state
for it.
*/
static xTaskHandle dhcpserver_task_handle=NULL;
static TaskHandle_t dhcpserver_task_handle = NULL;
static server_state_t *state;
/* Handlers for various kinds of incoming DHCP messages */

View file

@ -16,7 +16,7 @@
#define DS18B20_ALARMSEARCH 0xEC
#define DS18B20_CONVERT_T 0x44
#define os_sleep_ms(x) vTaskDelay(((x) + portTICK_RATE_MS - 1) / portTICK_RATE_MS)
#define os_sleep_ms(x) vTaskDelay(((x) + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS)
#define DS18B20_FAMILY_ID 0x28
#define DS18S20_FAMILY_ID 0x10
@ -46,7 +46,7 @@ uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result) {
onewire_write(pin, DS18B20_CONVERT_T);
onewire_power(pin);
vTaskDelay(750 / portTICK_RATE_MS);
vTaskDelay(750 / portTICK_PERIOD_MS);
onewire_reset(pin);
onewire_select(pin, addr);
@ -88,7 +88,7 @@ float ds18b20_read_single(uint8_t pin) {
onewire_write(pin, DS18B20_CONVERT_T);
onewire_power(pin);
vTaskDelay(750 / portTICK_RATE_MS);
vTaskDelay(750 / portTICK_PERIOD_MS);
onewire_reset(pin);
onewire_skip_rom(pin);

View file

@ -275,7 +275,7 @@
#ifndef _FS_TIMEOUT
#define _FS_TIMEOUT 1000
#endif
#define _SYNC_t xSemaphoreHandle
#define _SYNC_t SemaphoreHandle_t
/* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/ module itself. Note that regardless of this option, file access to different
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()

View file

@ -13,7 +13,7 @@
* synchronization object, such as semaphore and mutex. When a 0 is returned,
* the f_mount() function fails with FR_INT_ERR.
*/
int ff_cre_syncobj(BYTE vol, xSemaphoreHandle *sobj)
int ff_cre_syncobj(BYTE vol, SemaphoreHandle_t *sobj)
{
int ret;
@ -29,7 +29,7 @@ int ff_cre_syncobj(BYTE vol, xSemaphoreHandle *sobj)
* object that created with ff_cre_syncobj() function. When a 0 is returned,
* the f_mount() function fails with FR_INT_ERR.
*/
int ff_del_syncobj(xSemaphoreHandle sobj)
int ff_del_syncobj(SemaphoreHandle_t sobj)
{
vSemaphoreDelete(sobj);
return 1;
@ -40,7 +40,7 @@ int ff_del_syncobj(xSemaphoreHandle sobj)
* This function is called on entering file functions to lock the volume.
* When a 0 is returned, the file function fails with FR_TIMEOUT.
*/
int ff_req_grant(xSemaphoreHandle sobj)
int ff_req_grant(SemaphoreHandle_t sobj)
{
return (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE);
}
@ -49,7 +49,7 @@ int ff_req_grant(xSemaphoreHandle sobj)
* Release Grant to Access the Volume
* This function is called on leaving file functions to unlock the volume.
*/
void ff_rel_grant(xSemaphoreHandle sobj)
void ff_rel_grant(SemaphoreHandle_t sobj)
{
xSemaphoreGive(sobj);
}

View file

@ -30,7 +30,7 @@
char mqtt_timer_expired(mqtt_timer_t* timer)
{
portTickType now = xTaskGetTickCount();
TickType_t now = xTaskGetTickCount();
int32_t left = timer->end_time - now;
return (left < 0);
}
@ -38,8 +38,8 @@ char mqtt_timer_expired(mqtt_timer_t* timer)
void mqtt_timer_countdown_ms(mqtt_timer_t* timer, unsigned int timeout)
{
portTickType now = xTaskGetTickCount();
timer->end_time = now + timeout / portTICK_RATE_MS;
TickType_t now = xTaskGetTickCount();
timer->end_time = now + timeout / portTICK_PERIOD_MS;
}
@ -51,9 +51,9 @@ void mqtt_timer_countdown(mqtt_timer_t* timer, unsigned int timeout)
int mqtt_timer_left_ms(mqtt_timer_t* timer)
{
portTickType now = xTaskGetTickCount();
TickType_t now = xTaskGetTickCount();
int32_t left = timer->end_time - now;
return (left < 0) ? 0 : left / portTICK_RATE_MS;
return (left < 0) ? 0 : left / portTICK_PERIOD_MS;
}
@ -73,7 +73,7 @@ int mqtt_esp_read(mqtt_network_t* n, unsigned char* buffer, int len, int timeou
FD_ZERO(&fdset);
FD_SET(n->my_socket, &fdset);
// It seems tv_sec actually means FreeRTOS tick
tv.tv_sec = timeout_ms / portTICK_RATE_MS;
tv.tv_sec = timeout_ms / portTICK_PERIOD_MS;
tv.tv_usec = 0;
rc = select(n->my_socket + 1, &fdset, 0, 0, &tv);
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
@ -98,7 +98,7 @@ int mqtt_esp_write(mqtt_network_t* n, unsigned char* buffer, int len, int timeo
FD_ZERO(&fdset);
FD_SET(n->my_socket, &fdset);
// It seems tv_sec actually means FreeRTOS tick
tv.tv_sec = timeout_ms / portTICK_RATE_MS;
tv.tv_sec = timeout_ms / portTICK_PERIOD_MS;
tv.tv_usec = 0;
rc = select(n->my_socket + 1, 0, &fdset, 0, &tv);
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))

View file

@ -28,7 +28,7 @@ typedef struct mqtt_timer mqtt_timer_t;
struct mqtt_timer
{
portTickType end_time;
TickType_t end_time;
};
typedef struct mqtt_network mqtt_network_t;

View file

@ -40,7 +40,7 @@
#define UART0_RX_SIZE (128) // ESP8266 UART HW FIFO size
static xSemaphoreHandle uart0_sem = NULL;
static SemaphoreHandle_t uart0_sem = NULL;
static bool inited = false;
static void uart0_rx_init(void);

View file

@ -195,13 +195,13 @@ static void get_channel_data(tsl2561_t *device, uint16_t *channel0, uint16_t *ch
switch (device->integration_time)
{
case TSL2561_INTEGRATION_13MS:
vTaskDelay(TSL2561_INTEGRATION_TIME_13MS / portTICK_RATE_MS);
vTaskDelay(TSL2561_INTEGRATION_TIME_13MS / portTICK_PERIOD_MS);
break;
case TSL2561_INTEGRATION_101MS:
vTaskDelay(TSL2561_INTEGRATION_TIME_101MS / portTICK_RATE_MS);
vTaskDelay(TSL2561_INTEGRATION_TIME_101MS / portTICK_PERIOD_MS);
break;
default:
vTaskDelay(TSL2561_INTEGRATION_TIME_402MS / portTICK_RATE_MS);
vTaskDelay(TSL2561_INTEGRATION_TIME_402MS / portTICK_PERIOD_MS);
break;
}