FreeRTOS type updates. (#261)
This commit is contained in:
parent
4c84b64566
commit
a5cc728079
53 changed files with 151 additions and 148 deletions
|
@ -44,7 +44,7 @@
|
||||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 80000000 )
|
#define configCPU_CLOCK_HZ ( ( unsigned long ) 80000000 )
|
||||||
#endif
|
#endif
|
||||||
#ifndef configTICK_RATE_HZ
|
#ifndef configTICK_RATE_HZ
|
||||||
#define configTICK_RATE_HZ ( ( portTickType ) 100 )
|
#define configTICK_RATE_HZ ( ( TickType_t ) 100 )
|
||||||
#endif
|
#endif
|
||||||
#ifndef configMAX_PRIORITIES
|
#ifndef configMAX_PRIORITIES
|
||||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 15 )
|
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 15 )
|
||||||
|
@ -140,5 +140,9 @@ to exclude the API function. */
|
||||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef configENABLE_BACKWARD_COMPATIBILITY
|
||||||
|
#define configENABLE_BACKWARD_COMPATIBILITY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __DEFAULT_FREERTOS_CONFIG_H */
|
#endif /* __DEFAULT_FREERTOS_CONFIG_H */
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ void *xPortSupervisorStackPointer;
|
||||||
/*
|
/*
|
||||||
* Stack initialization
|
* Stack initialization
|
||||||
*/
|
*/
|
||||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
|
||||||
{
|
{
|
||||||
#define SET_STKREG(r,v) sp[(r) >> 2] = (portSTACK_TYPE)(v)
|
#define SET_STKREG(r,v) sp[(r) >> 2] = (portSTACK_TYPE)(v)
|
||||||
portSTACK_TYPE *sp, *tp;
|
portSTACK_TYPE *sp, *tp;
|
||||||
|
@ -259,7 +259,7 @@ void IRAM vPortExitCritical( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Backward compatibility with libmain.a and libpp.a and can remove when these are open. */
|
/* Backward compatibility with libmain.a and libpp.a and can remove when these are open. */
|
||||||
signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions )
|
signed portBASE_TYPE xTaskGenericCreate( TaskFunction_t pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, TaskHandle_t *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const MemoryRegion_t * const xRegions )
|
||||||
{
|
{
|
||||||
(void)puxStackBuffer; (void)xRegions;
|
(void)puxStackBuffer; (void)xRegions;
|
||||||
return xTaskCreate( pxTaskCode, (const char * const)pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask);
|
return xTaskCreate( pxTaskCode, (const char * const)pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask);
|
||||||
|
|
|
@ -100,13 +100,12 @@ typedef portSTACK_TYPE StackType_t;
|
||||||
typedef portBASE_TYPE BaseType_t;
|
typedef portBASE_TYPE BaseType_t;
|
||||||
typedef unsigned portBASE_TYPE UBaseType_t;
|
typedef unsigned portBASE_TYPE UBaseType_t;
|
||||||
|
|
||||||
typedef uint32_t portTickType;
|
|
||||||
typedef uint32_t TickType_t;
|
typedef uint32_t TickType_t;
|
||||||
#define portMAX_DELAY ( portTickType ) 0xffffffff
|
#define portMAX_DELAY ( TickType_t ) 0xffffffff
|
||||||
|
|
||||||
/* Architecture specifics. */
|
/* Architecture specifics. */
|
||||||
#define portSTACK_GROWTH ( -1 )
|
#define portSTACK_GROWTH ( -1 )
|
||||||
#define portTICK_PERIOD_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||||
#define portBYTE_ALIGNMENT 8
|
#define portBYTE_ALIGNMENT 8
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,10 @@ uint8_t sdk_user_init_flag;
|
||||||
struct sdk_info_st sdk_info;
|
struct sdk_info_st sdk_info;
|
||||||
|
|
||||||
// xUserTaskHandle -- .bss+0x28
|
// xUserTaskHandle -- .bss+0x28
|
||||||
xTaskHandle sdk_xUserTaskHandle;
|
TaskHandle_t sdk_xUserTaskHandle;
|
||||||
|
|
||||||
// xWatchDogTaskHandle -- .bss+0x2c
|
// xWatchDogTaskHandle -- .bss+0x2c
|
||||||
xTaskHandle sdk_xWatchDogTaskHandle;
|
TaskHandle_t sdk_xWatchDogTaskHandle;
|
||||||
|
|
||||||
/* Static function prototypes */
|
/* Static function prototypes */
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ void IRAM sdk_user_start(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// .text+0x3a8
|
// .text+0x3a8
|
||||||
void IRAM vApplicationStackOverflowHook(xTaskHandle task, char *task_name) {
|
void IRAM vApplicationStackOverflowHook(TaskHandle_t task, char *task_name) {
|
||||||
printf("Task stack overflow (high water mark=%lu name=\"%s\")\n", uxTaskGetStackHighWaterMark(task), task_name);
|
printf("Task stack overflow (high water mark=%lu name=\"%s\")\n", uxTaskGetStackHighWaterMark(task), task_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ static struct {
|
||||||
uint32_t end_addr;
|
uint32_t end_addr;
|
||||||
size_t region_size;
|
size_t region_size;
|
||||||
bool force_compact;
|
bool force_compact;
|
||||||
xSemaphoreHandle sem;
|
SemaphoreHandle_t sem;
|
||||||
} _sysparam_info;
|
} _sysparam_info;
|
||||||
|
|
||||||
/***************************** Internal routines *****************************/
|
/***************************** Internal routines *****************************/
|
||||||
|
|
|
@ -84,7 +84,7 @@ static void telnetTask(void *pvParameters)
|
||||||
|
|
||||||
char buf[80];
|
char buf[80];
|
||||||
snprintf(buf, sizeof(buf), "Uptime %d seconds\r\n",
|
snprintf(buf, sizeof(buf), "Uptime %d seconds\r\n",
|
||||||
xTaskGetTickCount()*portTICK_RATE_MS/1000);
|
xTaskGetTickCount()*portTICK_PERIOD_MS/1000);
|
||||||
netconn_write(client, buf, strlen(buf), NETCONN_COPY);
|
netconn_write(client, buf, strlen(buf), NETCONN_COPY);
|
||||||
snprintf(buf, sizeof(buf), "Free heap %d bytes\r\n", (int)xPortGetFreeHeapSize());
|
snprintf(buf, sizeof(buf), "Free heap %d bytes\r\n", (int)xPortGetFreeHeapSize());
|
||||||
netconn_write(client, buf, strlen(buf), NETCONN_COPY);
|
netconn_write(client, buf, strlen(buf), NETCONN_COPY);
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern char *ca_cert, *client_endpoint, *client_cert, *client_key;
|
||||||
static int wifi_alive = 0;
|
static int wifi_alive = 0;
|
||||||
static int ssl_reset;
|
static int ssl_reset;
|
||||||
static SSLConnection *ssl_conn;
|
static SSLConnection *ssl_conn;
|
||||||
static xQueueHandle publish_queue;
|
static QueueHandle_t publish_queue;
|
||||||
|
|
||||||
static void beat_task(void *pvParameters) {
|
static void beat_task(void *pvParameters) {
|
||||||
char msg[16];
|
char msg[16];
|
||||||
|
@ -39,7 +39,7 @@ static void beat_task(void *pvParameters) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!wifi_alive) {
|
if (!wifi_alive) {
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ static void beat_task(void *pvParameters) {
|
||||||
printf("Publish queue overflow\r\n");
|
printf("Publish queue overflow\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(10000 / portTICK_RATE_MS);
|
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ static void mqtt_task(void *pvParameters) {
|
||||||
ssl_conn = (SSLConnection *) malloc(sizeof(SSLConnection));
|
ssl_conn = (SSLConnection *) malloc(sizeof(SSLConnection));
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!wifi_alive) {
|
if (!wifi_alive) {
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ static void mqtt_task(void *pvParameters) {
|
||||||
while (wifi_alive && !ssl_reset) {
|
while (wifi_alive && !ssl_reset) {
|
||||||
char msg[64];
|
char msg[64];
|
||||||
while (xQueueReceive(publish_queue, (void *) msg, 0) == pdTRUE) {
|
while (xQueueReceive(publish_queue, (void *) msg, 0) == pdTRUE) {
|
||||||
portTickType task_tick = xTaskGetTickCount();
|
TickType_t task_tick = xTaskGetTickCount();
|
||||||
uint32_t free_heap = xPortGetFreeHeapSize();
|
uint32_t free_heap = xPortGetFreeHeapSize();
|
||||||
uint32_t free_stack = uxTaskGetStackHighWaterMark(NULL);
|
uint32_t free_stack = uxTaskGetStackHighWaterMark(NULL);
|
||||||
snprintf(msg, sizeof(msg), "%u: free heap %u, free stack %u",
|
snprintf(msg, sizeof(msg), "%u: free heap %u, free stack %u",
|
||||||
|
@ -246,7 +246,7 @@ static void wifi_task(void *pvParameters) {
|
||||||
printf("WiFi: connection failed\r\n");
|
printf("WiFi: connection failed\r\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
--retries;
|
--retries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,12 +256,12 @@ static void wifi_task(void *pvParameters) {
|
||||||
printf("WiFi: Connected\n\r");
|
printf("WiFi: Connected\n\r");
|
||||||
wifi_alive = 1;
|
wifi_alive = 1;
|
||||||
}
|
}
|
||||||
vTaskDelay(500 / portTICK_RATE_MS);
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_alive = 0;
|
wifi_alive = 0;
|
||||||
printf("WiFi: disconnected\n\r");
|
printf("WiFi: disconnected\n\r");
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ int ssl_connect(SSLConnection* conn, const char* host, int port) {
|
||||||
}
|
}
|
||||||
handle_error(ret);
|
handle_error(ret);
|
||||||
|
|
||||||
vTaskDelay(5000 / portTICK_RATE_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_ssl_get_record_expansion(&conn->ssl_ctx);
|
mbedtls_ssl_get_record_expansion(&conn->ssl_ctx);
|
||||||
|
|
|
@ -19,9 +19,9 @@ void blinkenTask(void *pvParameters)
|
||||||
gpio_enable(gpio, GPIO_OUTPUT);
|
gpio_enable(gpio, GPIO_OUTPUT);
|
||||||
while(1) {
|
while(1) {
|
||||||
gpio_write(gpio, 1);
|
gpio_write(gpio, 1);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
gpio_write(gpio, 0);
|
gpio_write(gpio, 0);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ void blinkenRegisterTask(void *pvParameters)
|
||||||
IOMUX_GPIO2 = IOMUX_GPIO2_FUNC_GPIO | IOMUX_PIN_OUTPUT_ENABLE; /* change this line if you change 'gpio' */
|
IOMUX_GPIO2 = IOMUX_GPIO2_FUNC_GPIO | IOMUX_PIN_OUTPUT_ENABLE; /* change this line if you change 'gpio' */
|
||||||
while(1) {
|
while(1) {
|
||||||
GPIO.OUT_SET = BIT(gpio);
|
GPIO.OUT_SET = BIT(gpio);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
GPIO.OUT_CLEAR = BIT(gpio);
|
GPIO.OUT_CLEAR = BIT(gpio);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,11 @@ typedef struct
|
||||||
} my_event_t;
|
} my_event_t;
|
||||||
|
|
||||||
// Communication Queue
|
// Communication Queue
|
||||||
static xQueueHandle mainqueue;
|
static QueueHandle_t mainqueue;
|
||||||
static xTimerHandle timerHandle;
|
static TimerHandle_t timerHandle;
|
||||||
|
|
||||||
// Own BMP180 User Inform Implementation
|
// Own BMP180 User Inform Implementation
|
||||||
bool bmp180_i2c_informUser(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure)
|
bool bmp180_i2c_informUser(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure)
|
||||||
{
|
{
|
||||||
my_event_t ev;
|
my_event_t ev;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ bool bmp180_i2c_informUser(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timer call back
|
// Timer call back
|
||||||
static void bmp180_i2c_timer_cb(xTimerHandle xTimer)
|
static void bmp180_i2c_timer_cb(TimerHandle_t xTimer)
|
||||||
{
|
{
|
||||||
my_event_t ev;
|
my_event_t ev;
|
||||||
ev.event_type = MY_EVT_TIMER;
|
ev.event_type = MY_EVT_TIMER;
|
||||||
|
@ -55,7 +55,7 @@ static void bmp180_i2c_timer_cb(xTimerHandle xTimer)
|
||||||
void bmp180_task(void *pvParameters)
|
void bmp180_task(void *pvParameters)
|
||||||
{
|
{
|
||||||
// Received pvParameters is communication queue
|
// Received pvParameters is communication queue
|
||||||
xQueueHandle *com_queue = (xQueueHandle *)pvParameters;
|
QueueHandle_t *com_queue = (QueueHandle_t *)pvParameters;
|
||||||
|
|
||||||
printf("%s: Started user interface task\n", __FUNCTION__);
|
printf("%s: Started user interface task\n", __FUNCTION__);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void user_init(void)
|
||||||
xTaskCreate(bmp180_task, "bmp180_task", 256, &mainqueue, 2, NULL);
|
xTaskCreate(bmp180_task, "bmp180_task", 256, &mainqueue, 2, NULL);
|
||||||
|
|
||||||
// Create Timer (Trigger a measurement every second)
|
// Create Timer (Trigger a measurement every second)
|
||||||
timerHandle = xTimerCreate("BMP180 Trigger", 1000/portTICK_RATE_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
|
timerHandle = xTimerCreate("BMP180 Trigger", 1000/portTICK_PERIOD_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
|
||||||
|
|
||||||
if (timerHandle != NULL)
|
if (timerHandle != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,14 +31,14 @@ static void bmp280_task_forced(void *pvParameters)
|
||||||
while (1) {
|
while (1) {
|
||||||
while (!bmp280_init(&bmp280_dev, ¶ms)) {
|
while (!bmp280_init(&bmp280_dev, ¶ms)) {
|
||||||
printf("BMP280 initialization failed\n");
|
printf("BMP280 initialization failed\n");
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bme280p = bmp280_dev.id == BME280_CHIP_ID;
|
bool bme280p = bmp280_dev.id == BME280_CHIP_ID;
|
||||||
printf("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");
|
printf("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
if (!bmp280_force_measurement(&bmp280_dev)) {
|
if (!bmp280_force_measurement(&bmp280_dev)) {
|
||||||
printf("Failed initiating measurement\n");
|
printf("Failed initiating measurement\n");
|
||||||
break;
|
break;
|
||||||
|
@ -72,14 +72,14 @@ static void bmp280_task_normal(void *pvParameters)
|
||||||
while (1) {
|
while (1) {
|
||||||
while (!bmp280_init(&bmp280_dev, ¶ms)) {
|
while (!bmp280_init(&bmp280_dev, ¶ms)) {
|
||||||
printf("BMP280 initialization failed\n");
|
printf("BMP280 initialization failed\n");
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bme280p = bmp280_dev.id == BME280_CHIP_ID;
|
bool bme280p = bmp280_dev.id == BME280_CHIP_ID;
|
||||||
printf("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");
|
printf("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
if (!bmp280_read_float(&bmp280_dev, &temperature, &pressure, &humidity)) {
|
if (!bmp280_read_float(&bmp280_dev, &temperature, &pressure, &humidity)) {
|
||||||
printf("Temperature/pressure reading failed\n");
|
printf("Temperature/pressure reading failed\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -34,8 +34,8 @@ void buttonPollTask(void *pvParameters)
|
||||||
{
|
{
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
}
|
}
|
||||||
printf("Polled for button press at %dms\r\n", xTaskGetTickCount()*portTICK_RATE_MS);
|
printf("Polled for button press at %dms\r\n", xTaskGetTickCount()*portTICK_PERIOD_MS);
|
||||||
vTaskDelay(200 / portTICK_RATE_MS);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,14 +50,14 @@ void buttonPollTask(void *pvParameters)
|
||||||
void buttonIntTask(void *pvParameters)
|
void buttonIntTask(void *pvParameters)
|
||||||
{
|
{
|
||||||
printf("Waiting for button press interrupt on gpio %d...\r\n", gpio);
|
printf("Waiting for button press interrupt on gpio %d...\r\n", gpio);
|
||||||
xQueueHandle *tsqueue = (xQueueHandle *)pvParameters;
|
QueueHandle_t *tsqueue = (QueueHandle_t *)pvParameters;
|
||||||
gpio_set_interrupt(gpio, int_type);
|
gpio_set_interrupt(gpio, int_type);
|
||||||
|
|
||||||
uint32_t last = 0;
|
uint32_t last = 0;
|
||||||
while(1) {
|
while(1) {
|
||||||
uint32_t button_ts;
|
uint32_t button_ts;
|
||||||
xQueueReceive(*tsqueue, &button_ts, portMAX_DELAY);
|
xQueueReceive(*tsqueue, &button_ts, portMAX_DELAY);
|
||||||
button_ts *= portTICK_RATE_MS;
|
button_ts *= portTICK_PERIOD_MS;
|
||||||
if(last < button_ts-200) {
|
if(last < button_ts-200) {
|
||||||
printf("Button interrupt fired at %dms\r\n", button_ts);
|
printf("Button interrupt fired at %dms\r\n", button_ts);
|
||||||
last = button_ts;
|
last = button_ts;
|
||||||
|
@ -65,7 +65,7 @@ void buttonIntTask(void *pvParameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static xQueueHandle tsqueue;
|
static QueueHandle_t tsqueue;
|
||||||
|
|
||||||
void GPIO_HANDLER(void)
|
void GPIO_HANDLER(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ void dhtMeasurementTask(void *pvParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Three second delay...
|
// Three second delay...
|
||||||
vTaskDelay(3000 / portTICK_RATE_MS);
|
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ void broadcast_temperature(void *pvParameters)
|
||||||
}
|
}
|
||||||
netbuf_delete(buf); // De-allocate packet buffer
|
netbuf_delete(buf); // De-allocate packet buffer
|
||||||
}
|
}
|
||||||
vTaskDelay(1000/portTICK_RATE_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = netconn_disconnect(conn);
|
err = netconn_disconnect(conn);
|
||||||
|
@ -97,7 +97,7 @@ void broadcast_temperature(void *pvParameters)
|
||||||
err = netconn_delete(conn);
|
err = netconn_delete(conn);
|
||||||
printf("%s : Deleted connection (%s)\n", __FUNCTION__, lwip_strerr(err));
|
printf("%s : Deleted connection (%s)\n", __FUNCTION__, lwip_strerr(err));
|
||||||
|
|
||||||
vTaskDelay(1000/portTICK_RATE_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void print_temperature(void *pvParameters) {
|
||||||
// Wait for a little bit between each sample (note that the
|
// Wait for a little bit between each sample (note that the
|
||||||
// ds18b20_measure_and_read_multi operation already takes at
|
// ds18b20_measure_and_read_multi operation already takes at
|
||||||
// least 750ms to run, so this is on top of that delay).
|
// least 750ms to run, so this is on top of that delay).
|
||||||
vTaskDelay(LOOP_DELAY_MS / portTICK_RATE_MS);
|
vTaskDelay(LOOP_DELAY_MS / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ void timerRegTask(void *pvParameters)
|
||||||
printf("frc2 handler called %d times, last value 0x%08x\r\n", frc2_handler_call_count,
|
printf("frc2 handler called %d times, last value 0x%08x\r\n", frc2_handler_call_count,
|
||||||
frc2_last_count_val);
|
frc2_last_count_val);
|
||||||
|
|
||||||
vTaskDelay(500 / portTICK_RATE_MS);
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ void user_init(void)
|
||||||
test_isr();
|
test_isr();
|
||||||
test_sign_extension();
|
test_sign_extension();
|
||||||
|
|
||||||
xTaskHandle taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
xTaskCreate(test_system_interaction, "interactionTask", 256, &taskHandle, 2, NULL);
|
xTaskCreate(test_system_interaction, "interactionTask", 256, &taskHandle, 2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ static void test_system_interaction()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
uint32_t ticks = xTaskGetTickCount() - start;
|
uint32_t ticks = xTaskGetTickCount() - start;
|
||||||
printf("Timer interaction test PASSED after %dms.\n", ticks*portTICK_RATE_MS);
|
printf("Timer interaction test PASSED after %dms.\n", ticks*portTICK_PERIOD_MS);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ void rewrite_file_task(void *p)
|
||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
|
||||||
vTaskDelay(DELAY_MS / portTICK_RATE_MS);
|
vTaskDelay(DELAY_MS / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ void http_get_task(void *pvParameters)
|
||||||
printf("DNS lookup failed err=%d res=%p\r\n", err, res);
|
printf("DNS lookup failed err=%d res=%p\r\n", err, res);
|
||||||
if(res)
|
if(res)
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
failures++;
|
failures++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void http_get_task(void *pvParameters)
|
||||||
if(s < 0) {
|
if(s < 0) {
|
||||||
printf("... Failed to allocate socket.\r\n");
|
printf("... Failed to allocate socket.\r\n");
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
failures++;
|
failures++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ void http_get_task(void *pvParameters)
|
||||||
close(s);
|
close(s);
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
printf("... socket connect failed.\r\n");
|
printf("... socket connect failed.\r\n");
|
||||||
vTaskDelay(4000 / portTICK_RATE_MS);
|
vTaskDelay(4000 / portTICK_PERIOD_MS);
|
||||||
failures++;
|
failures++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void http_get_task(void *pvParameters)
|
||||||
if (write(s, req, strlen(req)) < 0) {
|
if (write(s, req, strlen(req)) < 0) {
|
||||||
printf("... socket send failed\r\n");
|
printf("... socket send failed\r\n");
|
||||||
close(s);
|
close(s);
|
||||||
vTaskDelay(4000 / portTICK_RATE_MS);
|
vTaskDelay(4000 / portTICK_PERIOD_MS);
|
||||||
failures++;
|
failures++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ void http_get_task(void *pvParameters)
|
||||||
printf("successes = %d failures = %d\r\n", successes, failures);
|
printf("successes = %d failures = %d\r\n", successes, failures);
|
||||||
for(int countdown = 10; countdown >= 0; countdown--) {
|
for(int countdown = 10; countdown >= 0; countdown--) {
|
||||||
printf("%d... ", countdown);
|
printf("%d... ", countdown);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
printf("\r\nStarting again!\r\n");
|
printf("\r\nStarting again!\r\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ void http_get_task(void *pvParameters)
|
||||||
err_t dns_err;
|
err_t dns_err;
|
||||||
ip_addr_t host_ip;
|
ip_addr_t host_ip;
|
||||||
do {
|
do {
|
||||||
vTaskDelay(500 / portTICK_RATE_MS);
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||||
dns_err = netconn_gethostbyname(WEB_SERVER, &host_ip);
|
dns_err = netconn_gethostbyname(WEB_SERVER, &host_ip);
|
||||||
} while(dns_err != ERR_OK);
|
} while(dns_err != ERR_OK);
|
||||||
printf("done.\n");
|
printf("done.\n");
|
||||||
|
@ -313,7 +313,7 @@ void http_get_task(void *pvParameters)
|
||||||
printf("\n\nsuccesses = %d failures = %d\n", successes, failures);
|
printf("\n\nsuccesses = %d failures = %d\n", successes, failures);
|
||||||
for(int countdown = successes ? 10 : 5; countdown >= 0; countdown--) {
|
for(int countdown = successes ? 10 : 5; countdown >= 0; countdown--) {
|
||||||
printf("%d... ", countdown);
|
printf("%d... ", countdown);
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
printf("\nStarting again!\n");
|
printf("\nStarting again!\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ static dma_descriptor_t dma_block_list[DMA_QUEUE_SIZE];
|
||||||
static uint8_t dma_buffer[DMA_QUEUE_SIZE][DMA_BUFFER_SIZE];
|
static uint8_t dma_buffer[DMA_QUEUE_SIZE][DMA_BUFFER_SIZE];
|
||||||
|
|
||||||
// Queue of empty DMA blocks
|
// Queue of empty DMA blocks
|
||||||
static xQueueHandle dma_queue;
|
static QueueHandle_t dma_queue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a circular list of DMA descriptors
|
* Create a circular list of DMA descriptors
|
||||||
|
@ -183,7 +183,7 @@ void play_task(void *pvParameters)
|
||||||
|
|
||||||
printf("underrun counter: %d\n", underrun_counter);
|
printf("underrun counter: %d\n", underrun_counter);
|
||||||
|
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -24,18 +24,18 @@
|
||||||
#define MQTT_USER NULL
|
#define MQTT_USER NULL
|
||||||
#define MQTT_PASS NULL
|
#define MQTT_PASS NULL
|
||||||
|
|
||||||
xSemaphoreHandle wifi_alive;
|
SemaphoreHandle_t wifi_alive;
|
||||||
xQueueHandle publish_queue;
|
QueueHandle_t publish_queue;
|
||||||
#define PUB_MSG_LEN 16
|
#define PUB_MSG_LEN 16
|
||||||
|
|
||||||
static void beat_task(void *pvParameters)
|
static void beat_task(void *pvParameters)
|
||||||
{
|
{
|
||||||
portTickType xLastWakeTime = xTaskGetTickCount();
|
TickType_t xLastWakeTime = xTaskGetTickCount();
|
||||||
char msg[PUB_MSG_LEN];
|
char msg[PUB_MSG_LEN];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelayUntil(&xLastWakeTime, 10000 / portTICK_RATE_MS);
|
vTaskDelayUntil(&xLastWakeTime, 10000 / portTICK_PERIOD_MS);
|
||||||
printf("beat\r\n");
|
printf("beat\r\n");
|
||||||
snprintf(msg, PUB_MSG_LEN, "Beat %d\r\n", count++);
|
snprintf(msg, PUB_MSG_LEN, "Beat %d\r\n", count++);
|
||||||
if (xQueueSend(publish_queue, (void *)msg, 0) == pdFALSE) {
|
if (xQueueSend(publish_queue, (void *)msg, 0) == pdFALSE) {
|
||||||
|
@ -190,7 +190,7 @@ static void wifi_task(void *pvParameters)
|
||||||
printf("WiFi: connection failed\r\n");
|
printf("WiFi: connection failed\r\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vTaskDelay( 1000 / portTICK_RATE_MS );
|
vTaskDelay( 1000 / portTICK_PERIOD_MS );
|
||||||
--retries;
|
--retries;
|
||||||
}
|
}
|
||||||
if (status == STATION_GOT_IP) {
|
if (status == STATION_GOT_IP) {
|
||||||
|
@ -205,7 +205,7 @@ static void wifi_task(void *pvParameters)
|
||||||
}
|
}
|
||||||
printf("WiFi: disconnected\n\r");
|
printf("WiFi: disconnected\n\r");
|
||||||
sdk_wifi_station_disconnect();
|
sdk_wifi_station_disconnect();
|
||||||
vTaskDelay( 1000 / portTICK_RATE_MS );
|
vTaskDelay( 1000 / portTICK_PERIOD_MS );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,10 +109,10 @@ void tftp_client_task(void *pvParameters)
|
||||||
*/
|
*/
|
||||||
while(1) {
|
while(1) {
|
||||||
tftpclient_download_and_verify_file1(slot, &conf);
|
tftpclient_download_and_verify_file1(slot, &conf);
|
||||||
vTaskDelay(5000 / portTICK_RATE_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
tftpclient_download_file2(slot);
|
tftpclient_download_file2(slot);
|
||||||
vTaskDelay(5000 / portTICK_RATE_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,14 @@ void test_task(void *pvParameters)
|
||||||
esp_spiffs_mount();
|
esp_spiffs_mount();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(5000 / portTICK_RATE_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
if (fs_load_test_run(100)) {
|
if (fs_load_test_run(100)) {
|
||||||
printf("PASS\n");
|
printf("PASS\n");
|
||||||
} else {
|
} else {
|
||||||
printf("FAIL\n");
|
printf("FAIL\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(5000 / portTICK_RATE_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
float write_rate, read_rate;
|
float write_rate, read_rate;
|
||||||
if (fs_speed_test_run(get_current_time, &write_rate, &read_rate)) {
|
if (fs_speed_test_run(get_current_time, &write_rate, &read_rate)) {
|
||||||
printf("Read speed: %.0f bytes/s\n", read_rate * 1000);
|
printf("Read speed: %.0f bytes/s\n", read_rate * 1000);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
void task1(void *pvParameters)
|
void task1(void *pvParameters)
|
||||||
{
|
{
|
||||||
xQueueHandle *queue = (xQueueHandle *)pvParameters;
|
QueueHandle_t *queue = (QueueHandle_t *)pvParameters;
|
||||||
printf("Hello from task1!\r\n");
|
printf("Hello from task1!\r\n");
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
while(1) {
|
while(1) {
|
||||||
|
@ -21,7 +21,7 @@ void task1(void *pvParameters)
|
||||||
void task2(void *pvParameters)
|
void task2(void *pvParameters)
|
||||||
{
|
{
|
||||||
printf("Hello from task 2!\r\n");
|
printf("Hello from task 2!\r\n");
|
||||||
xQueueHandle *queue = (xQueueHandle *)pvParameters;
|
QueueHandle_t *queue = (QueueHandle_t *)pvParameters;
|
||||||
while(1) {
|
while(1) {
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
if(xQueueReceive(*queue, &count, 1000)) {
|
if(xQueueReceive(*queue, &count, 1000)) {
|
||||||
|
@ -32,7 +32,7 @@ void task2(void *pvParameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static xQueueHandle mainqueue;
|
static QueueHandle_t mainqueue;
|
||||||
|
|
||||||
void user_init(void)
|
void user_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#define SNTP_SERVERS "0.pool.ntp.org", "1.pool.ntp.org", \
|
#define SNTP_SERVERS "0.pool.ntp.org", "1.pool.ntp.org", \
|
||||||
"2.pool.ntp.org", "3.pool.ntp.org"
|
"2.pool.ntp.org", "3.pool.ntp.org"
|
||||||
|
|
||||||
#define vTaskDelayMs(ms) vTaskDelay((ms)/portTICK_RATE_MS)
|
#define vTaskDelayMs(ms) vTaskDelay((ms)/portTICK_PERIOD_MS)
|
||||||
#define UNUSED_ARG(x) (void)x
|
#define UNUSED_ARG(x) (void)x
|
||||||
|
|
||||||
void sntp_tsk(void *pvParameters)
|
void sntp_tsk(void *pvParameters)
|
||||||
|
|
|
@ -96,7 +96,7 @@ void test_task(void *pvParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
example_write_file();
|
example_write_file();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ static uint8_t buffer[SSD1306_ROWS * SSD1306_COLS / 8];
|
||||||
static void ssd1306_task(void *pvParameters)
|
static void ssd1306_task(void *pvParameters)
|
||||||
{
|
{
|
||||||
printf("%s: Started user interface task\n", __FUNCTION__);
|
printf("%s: Started user interface task\n", __FUNCTION__);
|
||||||
vTaskDelay(1000/portTICK_RATE_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
|
|
||||||
|
|
||||||
if (ssd1306_load_xbm(image_bits, buffer))
|
if (ssd1306_load_xbm(image_bits, buffer))
|
||||||
|
@ -30,14 +30,14 @@ static void ssd1306_task(void *pvParameters)
|
||||||
|
|
||||||
ssd1306_set_whole_display_lighting(false);
|
ssd1306_set_whole_display_lighting(false);
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
printf("%s: steel alive\n", __FUNCTION__);
|
printf("%s: steel alive\n", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
error_loop:
|
error_loop:
|
||||||
printf("%s: error while loading framebuffer into SSD1306\n", __func__);
|
printf("%s: error while loading framebuffer into SSD1306\n", __func__);
|
||||||
for(;;){
|
for(;;){
|
||||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
printf("%s: error loop\n", __FUNCTION__);
|
printf("%s: error loop\n", __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,12 @@ void user_init(void)
|
||||||
if (ssd1306_init()){
|
if (ssd1306_init()){
|
||||||
for (;;) {
|
for (;;) {
|
||||||
printf("%s: failed to init SSD1306 lcd\n", __func__);
|
printf("%s: failed to init SSD1306 lcd\n", __func__);
|
||||||
vTaskDelay(1000/portTICK_RATE_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssd1306_set_whole_display_lighting(true);
|
ssd1306_set_whole_display_lighting(true);
|
||||||
vTaskDelay(1000/portTICK_RATE_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
// Create user interface task
|
// Create user interface task
|
||||||
xTaskCreate(ssd1306_task, "ssd1306_task", 256, NULL, 2, NULL);
|
xTaskCreate(ssd1306_task, "ssd1306_task", 256, NULL, 2, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void cmd_help(uint32_t argc, char *argv[])
|
||||||
static void cmd_sleep(uint32_t argc, char *argv[])
|
static void cmd_sleep(uint32_t argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("Type away while I take a 2 second nap (ie. let you test the UART HW FIFO\n");
|
printf("Type away while I take a 2 second nap (ie. let you test the UART HW FIFO\n");
|
||||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_command(char *cmd)
|
static void handle_command(char *cmd)
|
||||||
|
|
|
@ -56,7 +56,7 @@ void tsl2561MeasurementTask(void *pvParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0.1 second delay
|
// 0.1 second delay
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void demo(void *pvParameters)
|
||||||
sizeof(ws2812_pixel_t));
|
sizeof(ws2812_pixel_t));
|
||||||
|
|
||||||
ws2812_i2s_update(pixels);
|
ws2812_i2s_update(pixels);
|
||||||
vTaskDelay(20 / portTICK_RATE_MS);
|
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "ws2812.h"
|
#include "ws2812.h"
|
||||||
|
|
||||||
|
|
||||||
#define delay_ms(ms) vTaskDelay((ms) / portTICK_RATE_MS)
|
#define delay_ms(ms) vTaskDelay((ms) / portTICK_PERIOD_MS)
|
||||||
|
|
||||||
|
|
||||||
/** GPIO number used to control the RGBs */
|
/** GPIO number used to control the RGBs */
|
||||||
|
|
|
@ -34,7 +34,7 @@ As all data aqquired from the BMP180/BMP085 is provided to the `bmp180_informUse
|
||||||
|
|
||||||
```
|
```
|
||||||
// Own BMP180 User Inform Implementation
|
// 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;
|
my_event_t ev;
|
||||||
|
|
||||||
ev.event_type = MY_EVT_BMP180;
|
ev.event_type = MY_EVT_BMP180;
|
||||||
|
|
|
@ -214,20 +214,20 @@ bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature,
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
const xQueueHandle* resultQueue;
|
const QueueHandle_t* resultQueue;
|
||||||
} bmp180_command_t;
|
} bmp180_command_t;
|
||||||
|
|
||||||
// Just works due to the fact that xQueueHandle is a "void *"
|
// Just works due to the fact that QueueHandle_t is a "void *"
|
||||||
static xQueueHandle bmp180_rx_queue = NULL;
|
static QueueHandle_t bmp180_rx_queue = NULL;
|
||||||
static xTaskHandle bmp180_task_handle = NULL;
|
static TaskHandle_t bmp180_task_handle = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Forward declarations
|
// 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
|
// 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
|
// I2C Driver Task
|
||||||
static void bmp180_driver_task(void *pvParameters)
|
static void bmp180_driver_task(void *pvParameters)
|
||||||
|
@ -295,7 +295,7 @@ static bool bmp180_createTask()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default user inform implementation
|
// 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;
|
bmp180_result_t result;
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ bool bmp180_init(uint8_t scl, uint8_t sda)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bmp180_trigger_measurement(const xQueueHandle* resultQueue)
|
void bmp180_trigger_measurement(const QueueHandle_t* resultQueue)
|
||||||
{
|
{
|
||||||
bmp180_command_t c;
|
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;
|
bmp180_command_t c;
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ void bmp180_trigger_pressure_measurement(const xQueueHandle* resultQueue)
|
||||||
xQueueSend(bmp180_rx_queue, &c, 0);
|
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;
|
bmp180_command_t c;
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,16 @@ typedef struct
|
||||||
bool bmp180_init(uint8_t scl, uint8_t sda);
|
bool bmp180_init(uint8_t scl, uint8_t sda);
|
||||||
|
|
||||||
// Trigger a "complete" measurement (temperature and pressure will be valid when given to "bmp180_informUser)
|
// 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)
|
// 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)
|
// 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
|
// 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
|
// Calibration constants
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -72,7 +72,7 @@ while(1) {
|
||||||
printf("Pressure: %.2f Pa, Temperature: %.2f C", pressure, temperature);
|
printf("Pressure: %.2f Pa, Temperature: %.2f C", pressure, temperature);
|
||||||
if (bme280p)
|
if (bme280p)
|
||||||
printf(", Humidity: %.2f\n", humidity);
|
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);
|
printf(", Humidity: %.2f\n", humidity);
|
||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
namespace esp_open_rtos {
|
namespace esp_open_rtos {
|
||||||
namespace timer {
|
namespace timer {
|
||||||
|
|
||||||
#define __millis() (xTaskGetTickCount() * portTICK_RATE_MS)
|
#define __millis() (xTaskGetTickCount() * portTICK_PERIOD_MS)
|
||||||
|
|
||||||
/******************************************************************************************************************
|
/******************************************************************************************************************
|
||||||
* countdown_t
|
* countdown_t
|
||||||
|
@ -93,7 +93,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
portTickType interval_end_ms;
|
TickType_t interval_end_ms;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace timer {
|
} // namespace timer {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
*/
|
*/
|
||||||
inline int try_lock(unsigned long ms)
|
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:
|
private:
|
||||||
xSemaphoreHandle mutex;
|
SemaphoreHandle_t mutex;
|
||||||
|
|
||||||
// Disable copy construction and assignment.
|
// Disable copy construction and assignment.
|
||||||
mutex_t (const mutex_t&);
|
mutex_t (const mutex_t&);
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
*/
|
*/
|
||||||
inline int post(const Data& data, unsigned long ms = 0)
|
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)
|
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:
|
private:
|
||||||
xQueueHandle queue;
|
QueueHandle_t queue;
|
||||||
|
|
||||||
// Disable copy construction.
|
// Disable copy construction.
|
||||||
queue_t (const queue_t&);
|
queue_t (const queue_t&);
|
||||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
void sleep(unsigned long ms)
|
void sleep(unsigned long ms)
|
||||||
{
|
{
|
||||||
vTaskDelay(ms / portTICK_RATE_MS);
|
vTaskDelay(ms / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -74,7 +74,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
inline unsigned long millis()
|
inline unsigned long millis()
|
||||||
{
|
{
|
||||||
return xTaskGetTickCount() * portTICK_RATE_MS;
|
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -49,7 +49,7 @@ typedef struct {
|
||||||
/* Only one DHCP server task can run at once, so we have global state
|
/* Only one DHCP server task can run at once, so we have global state
|
||||||
for it.
|
for it.
|
||||||
*/
|
*/
|
||||||
static xTaskHandle dhcpserver_task_handle=NULL;
|
static TaskHandle_t dhcpserver_task_handle = NULL;
|
||||||
static server_state_t *state;
|
static server_state_t *state;
|
||||||
|
|
||||||
/* Handlers for various kinds of incoming DHCP messages */
|
/* Handlers for various kinds of incoming DHCP messages */
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define DS18B20_ALARMSEARCH 0xEC
|
#define DS18B20_ALARMSEARCH 0xEC
|
||||||
#define DS18B20_CONVERT_T 0x44
|
#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 DS18B20_FAMILY_ID 0x28
|
||||||
#define DS18S20_FAMILY_ID 0x10
|
#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_write(pin, DS18B20_CONVERT_T);
|
||||||
|
|
||||||
onewire_power(pin);
|
onewire_power(pin);
|
||||||
vTaskDelay(750 / portTICK_RATE_MS);
|
vTaskDelay(750 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
onewire_reset(pin);
|
onewire_reset(pin);
|
||||||
onewire_select(pin, addr);
|
onewire_select(pin, addr);
|
||||||
|
@ -88,7 +88,7 @@ float ds18b20_read_single(uint8_t pin) {
|
||||||
onewire_write(pin, DS18B20_CONVERT_T);
|
onewire_write(pin, DS18B20_CONVERT_T);
|
||||||
|
|
||||||
onewire_power(pin);
|
onewire_power(pin);
|
||||||
vTaskDelay(750 / portTICK_RATE_MS);
|
vTaskDelay(750 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
onewire_reset(pin);
|
onewire_reset(pin);
|
||||||
onewire_skip_rom(pin);
|
onewire_skip_rom(pin);
|
||||||
|
|
|
@ -275,7 +275,7 @@
|
||||||
#ifndef _FS_TIMEOUT
|
#ifndef _FS_TIMEOUT
|
||||||
#define _FS_TIMEOUT 1000
|
#define _FS_TIMEOUT 1000
|
||||||
#endif
|
#endif
|
||||||
#define _SYNC_t xSemaphoreHandle
|
#define _SYNC_t SemaphoreHandle_t
|
||||||
/* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
/* 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
|
/ 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()
|
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* synchronization object, such as semaphore and mutex. When a 0 is returned,
|
* synchronization object, such as semaphore and mutex. When a 0 is returned,
|
||||||
* the f_mount() function fails with FR_INT_ERR.
|
* 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;
|
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,
|
* object that created with ff_cre_syncobj() function. When a 0 is returned,
|
||||||
* the f_mount() function fails with FR_INT_ERR.
|
* the f_mount() function fails with FR_INT_ERR.
|
||||||
*/
|
*/
|
||||||
int ff_del_syncobj(xSemaphoreHandle sobj)
|
int ff_del_syncobj(SemaphoreHandle_t sobj)
|
||||||
{
|
{
|
||||||
vSemaphoreDelete(sobj);
|
vSemaphoreDelete(sobj);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -40,7 +40,7 @@ int ff_del_syncobj(xSemaphoreHandle sobj)
|
||||||
* This function is called on entering file functions to lock the volume.
|
* This function is called on entering file functions to lock the volume.
|
||||||
* When a 0 is returned, the file function fails with FR_TIMEOUT.
|
* 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);
|
return (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ int ff_req_grant(xSemaphoreHandle sobj)
|
||||||
* Release Grant to Access the Volume
|
* Release Grant to Access the Volume
|
||||||
* This function is called on leaving file functions to unlock 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);
|
xSemaphoreGive(sobj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
char mqtt_timer_expired(mqtt_timer_t* timer)
|
char mqtt_timer_expired(mqtt_timer_t* timer)
|
||||||
{
|
{
|
||||||
portTickType now = xTaskGetTickCount();
|
TickType_t now = xTaskGetTickCount();
|
||||||
int32_t left = timer->end_time - now;
|
int32_t left = timer->end_time - now;
|
||||||
return (left < 0);
|
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)
|
void mqtt_timer_countdown_ms(mqtt_timer_t* timer, unsigned int timeout)
|
||||||
{
|
{
|
||||||
portTickType now = xTaskGetTickCount();
|
TickType_t now = xTaskGetTickCount();
|
||||||
timer->end_time = now + timeout / portTICK_RATE_MS;
|
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)
|
int mqtt_timer_left_ms(mqtt_timer_t* timer)
|
||||||
{
|
{
|
||||||
portTickType now = xTaskGetTickCount();
|
TickType_t now = xTaskGetTickCount();
|
||||||
int32_t left = timer->end_time - now;
|
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_ZERO(&fdset);
|
||||||
FD_SET(n->my_socket, &fdset);
|
FD_SET(n->my_socket, &fdset);
|
||||||
// It seems tv_sec actually means FreeRTOS tick
|
// 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;
|
tv.tv_usec = 0;
|
||||||
rc = select(n->my_socket + 1, &fdset, 0, 0, &tv);
|
rc = select(n->my_socket + 1, &fdset, 0, 0, &tv);
|
||||||
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
|
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_ZERO(&fdset);
|
||||||
FD_SET(n->my_socket, &fdset);
|
FD_SET(n->my_socket, &fdset);
|
||||||
// It seems tv_sec actually means FreeRTOS tick
|
// 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;
|
tv.tv_usec = 0;
|
||||||
rc = select(n->my_socket + 1, 0, &fdset, 0, &tv);
|
rc = select(n->my_socket + 1, 0, &fdset, 0, &tv);
|
||||||
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
|
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
|
||||||
|
|
|
@ -28,7 +28,7 @@ typedef struct mqtt_timer mqtt_timer_t;
|
||||||
|
|
||||||
struct mqtt_timer
|
struct mqtt_timer
|
||||||
{
|
{
|
||||||
portTickType end_time;
|
TickType_t end_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct mqtt_network mqtt_network_t;
|
typedef struct mqtt_network mqtt_network_t;
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#define UART0_RX_SIZE (128) // ESP8266 UART HW FIFO size
|
#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 bool inited = false;
|
||||||
static void uart0_rx_init(void);
|
static void uart0_rx_init(void);
|
||||||
|
|
||||||
|
|
|
@ -195,13 +195,13 @@ static void get_channel_data(tsl2561_t *device, uint16_t *channel0, uint16_t *ch
|
||||||
switch (device->integration_time)
|
switch (device->integration_time)
|
||||||
{
|
{
|
||||||
case TSL2561_INTEGRATION_13MS:
|
case TSL2561_INTEGRATION_13MS:
|
||||||
vTaskDelay(TSL2561_INTEGRATION_TIME_13MS / portTICK_RATE_MS);
|
vTaskDelay(TSL2561_INTEGRATION_TIME_13MS / portTICK_PERIOD_MS);
|
||||||
break;
|
break;
|
||||||
case TSL2561_INTEGRATION_101MS:
|
case TSL2561_INTEGRATION_101MS:
|
||||||
vTaskDelay(TSL2561_INTEGRATION_TIME_101MS / portTICK_RATE_MS);
|
vTaskDelay(TSL2561_INTEGRATION_TIME_101MS / portTICK_PERIOD_MS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vTaskDelay(TSL2561_INTEGRATION_TIME_402MS / portTICK_RATE_MS);
|
vTaskDelay(TSL2561_INTEGRATION_TIME_402MS / portTICK_PERIOD_MS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ typedef void ETSTimerFunc(void *);
|
||||||
|
|
||||||
typedef struct ETSTimer_st {
|
typedef struct ETSTimer_st {
|
||||||
struct ETSTimer_st *timer_next;
|
struct ETSTimer_st *timer_next;
|
||||||
xTimerHandle timer_handle;
|
TimerHandle_t timer_handle;
|
||||||
uint32_t _unknown;
|
uint32_t _unknown;
|
||||||
uint32_t timer_ms;
|
uint32_t timer_ms;
|
||||||
ETSTimerFunc *timer_func;
|
ETSTimerFunc *timer_func;
|
||||||
|
|
|
@ -39,14 +39,14 @@
|
||||||
|
|
||||||
/* MBOX primitives */
|
/* MBOX primitives */
|
||||||
|
|
||||||
#define SYS_MBOX_NULL ( ( xQueueHandle ) NULL )
|
#define SYS_MBOX_NULL ( ( QueueHandle_t ) NULL )
|
||||||
#define SYS_SEM_NULL ( ( xSemaphoreHandle ) NULL )
|
#define SYS_SEM_NULL ( ( SemaphoreHandle_t ) NULL )
|
||||||
#define SYS_DEFAULT_THREAD_STACK_DEPTH configMINIMAL_STACK_SIZE
|
#define SYS_DEFAULT_THREAD_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||||
|
|
||||||
typedef xSemaphoreHandle sys_sem_t;
|
typedef SemaphoreHandle_t sys_sem_t;
|
||||||
typedef xSemaphoreHandle sys_mutex_t;
|
typedef SemaphoreHandle_t sys_mutex_t;
|
||||||
typedef xQueueHandle sys_mbox_t;
|
typedef QueueHandle_t sys_mbox_t;
|
||||||
typedef xTaskHandle sys_thread_t;
|
typedef TaskHandle_t sys_thread_t;
|
||||||
|
|
||||||
#define sys_mbox_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
#define sys_mbox_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||||
#define sys_mbox_set_invalid( x ) ( ( *x ) = NULL )
|
#define sys_mbox_set_invalid( x ) ( ( *x ) = NULL )
|
||||||
|
|
|
@ -159,7 +159,7 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xReturn = xQueueSend( *pxMailBox, &pxMessageToPost, ( portTickType ) 0 );
|
xReturn = xQueueSend( *pxMailBox, &pxMessageToPost, ( TickType_t ) 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( xReturn == pdPASS )
|
if( xReturn == pdPASS )
|
||||||
|
@ -204,7 +204,7 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
u32_t sys_arch_mbox_fetch( sys_mbox_t *pxMailBox, void **ppvBuffer, u32_t ulTimeOut )
|
u32_t sys_arch_mbox_fetch( sys_mbox_t *pxMailBox, void **ppvBuffer, u32_t ulTimeOut )
|
||||||
{
|
{
|
||||||
void *pvDummy;
|
void *pvDummy;
|
||||||
portTickType xStartTime, xEndTime, xElapsed;
|
TickType_t xStartTime, xEndTime, xElapsed;
|
||||||
unsigned long ulReturn;
|
unsigned long ulReturn;
|
||||||
|
|
||||||
xStartTime = xTaskGetTickCount();
|
xStartTime = xTaskGetTickCount();
|
||||||
|
@ -218,10 +218,10 @@ unsigned long ulReturn;
|
||||||
{
|
{
|
||||||
configASSERT( is_inside_isr() == ( portBASE_TYPE ) 0 );
|
configASSERT( is_inside_isr() == ( portBASE_TYPE ) 0 );
|
||||||
|
|
||||||
if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), ulTimeOut/ portTICK_RATE_MS ) )
|
if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), ulTimeOut/ portTICK_PERIOD_MS ) )
|
||||||
{
|
{
|
||||||
xEndTime = xTaskGetTickCount();
|
xEndTime = xTaskGetTickCount();
|
||||||
xElapsed = ( xEndTime - xStartTime ) * portTICK_RATE_MS;
|
xElapsed = ( xEndTime - xStartTime ) * portTICK_PERIOD_MS;
|
||||||
|
|
||||||
ulReturn = xElapsed;
|
ulReturn = xElapsed;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ unsigned long ulReturn;
|
||||||
{
|
{
|
||||||
while( pdTRUE != xQueueReceive( *pxMailBox, &( *ppvBuffer ), portMAX_DELAY ) );
|
while( pdTRUE != xQueueReceive( *pxMailBox, &( *ppvBuffer ), portMAX_DELAY ) );
|
||||||
xEndTime = xTaskGetTickCount();
|
xEndTime = xTaskGetTickCount();
|
||||||
xElapsed = ( xEndTime - xStartTime ) * portTICK_RATE_MS;
|
xElapsed = ( xEndTime - xStartTime ) * portTICK_PERIOD_MS;
|
||||||
|
|
||||||
if( xElapsed == 0UL )
|
if( xElapsed == 0UL )
|
||||||
{
|
{
|
||||||
|
@ -358,17 +358,17 @@ err_t xReturn = ERR_MEM;
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
u32_t sys_arch_sem_wait( sys_sem_t *pxSemaphore, u32_t ulTimeout )
|
u32_t sys_arch_sem_wait( sys_sem_t *pxSemaphore, u32_t ulTimeout )
|
||||||
{
|
{
|
||||||
portTickType xStartTime, xEndTime, xElapsed;
|
TickType_t xStartTime, xEndTime, xElapsed;
|
||||||
unsigned long ulReturn;
|
unsigned long ulReturn;
|
||||||
|
|
||||||
xStartTime = xTaskGetTickCount();
|
xStartTime = xTaskGetTickCount();
|
||||||
|
|
||||||
if( ulTimeout != 0UL )
|
if( ulTimeout != 0UL )
|
||||||
{
|
{
|
||||||
if( xSemaphoreTake( *pxSemaphore, ulTimeout / portTICK_RATE_MS ) == pdTRUE )
|
if( xSemaphoreTake( *pxSemaphore, ulTimeout / portTICK_PERIOD_MS ) == pdTRUE )
|
||||||
{
|
{
|
||||||
xEndTime = xTaskGetTickCount();
|
xEndTime = xTaskGetTickCount();
|
||||||
xElapsed = (xEndTime - xStartTime) * portTICK_RATE_MS;
|
xElapsed = (xEndTime - xStartTime) * portTICK_PERIOD_MS;
|
||||||
ulReturn = xElapsed;
|
ulReturn = xElapsed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -380,7 +380,7 @@ unsigned long ulReturn;
|
||||||
{
|
{
|
||||||
while( xSemaphoreTake( *pxSemaphore, portMAX_DELAY ) != pdTRUE );
|
while( xSemaphoreTake( *pxSemaphore, portMAX_DELAY ) != pdTRUE );
|
||||||
xEndTime = xTaskGetTickCount();
|
xEndTime = xTaskGetTickCount();
|
||||||
xElapsed = ( xEndTime - xStartTime ) * portTICK_RATE_MS;
|
xElapsed = ( xEndTime - xStartTime ) * portTICK_PERIOD_MS;
|
||||||
|
|
||||||
if( xElapsed == 0UL )
|
if( xElapsed == 0UL )
|
||||||
{
|
{
|
||||||
|
@ -487,7 +487,7 @@ void sys_init(void)
|
||||||
|
|
||||||
u32_t sys_now(void)
|
u32_t sys_now(void)
|
||||||
{
|
{
|
||||||
return xTaskGetTickCount() * portTICK_RATE_MS;
|
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
|
@ -510,7 +510,7 @@ u32_t sys_now(void)
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
sys_thread_t sys_thread_new( const char *pcName, void( *pxThread )( void *pvParameters ), void *pvArg, int iStackSize, int iPriority )
|
sys_thread_t sys_thread_new( const char *pcName, void( *pxThread )( void *pvParameters ), void *pvArg, int iStackSize, int iPriority )
|
||||||
{
|
{
|
||||||
xTaskHandle xCreatedTask;
|
TaskHandle_t xCreatedTask;
|
||||||
portBASE_TYPE xResult;
|
portBASE_TYPE xResult;
|
||||||
sys_thread_t xReturn;
|
sys_thread_t xReturn;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ void IRAM sdk__xt_int_exit(void) {
|
||||||
void IRAM sdk__xt_timer_int(void) {
|
void IRAM sdk__xt_timer_int(void) {
|
||||||
uint32_t trigger_ccount;
|
uint32_t trigger_ccount;
|
||||||
uint32_t current_ccount;
|
uint32_t current_ccount;
|
||||||
uint32_t ccount_interval = portTICK_RATE_MS * sdk_os_get_cpu_frequency() * 1000;
|
uint32_t ccount_interval = portTICK_PERIOD_MS * sdk_os_get_cpu_frequency() * 1000;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RSR(trigger_ccount, ccompare0);
|
RSR(trigger_ccount, ccompare0);
|
||||||
|
@ -93,7 +93,7 @@ void IRAM sdk__xt_timer_int1(void) {
|
||||||
void IRAM sdk__xt_tick_timer_init(void) {
|
void IRAM sdk__xt_tick_timer_init(void) {
|
||||||
uint32_t ints_enabled;
|
uint32_t ints_enabled;
|
||||||
uint32_t current_ccount;
|
uint32_t current_ccount;
|
||||||
uint32_t ccount_interval = portTICK_RATE_MS * sdk_os_get_cpu_frequency() * 1000;
|
uint32_t ccount_interval = portTICK_PERIOD_MS * sdk_os_get_cpu_frequency() * 1000;
|
||||||
|
|
||||||
RSR(current_ccount, ccount);
|
RSR(current_ccount, ccount);
|
||||||
WSR(current_ccount + ccount_interval, ccompare0);
|
WSR(current_ccount + ccount_interval, ccompare0);
|
||||||
|
|
|
@ -60,7 +60,7 @@ void sdk_os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) {
|
||||||
*tailptr = new_entry;
|
*tailptr = new_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void timer_tramp(xTimerHandle xTimer)
|
static void timer_tramp(TimerHandle_t xTimer)
|
||||||
{
|
{
|
||||||
ETSTimer *ptimer = pvTimerGetTimerID(xTimer);
|
ETSTimer *ptimer = pvTimerGetTimerID(xTimer);
|
||||||
ptimer->timer_func(ptimer->timer_arg);
|
ptimer->timer_func(ptimer->timer_arg);
|
||||||
|
|
Loading…
Reference in a new issue