Skip to content

Commit

Permalink
#63 - Mocked more I/O - hw_interrupt_queue builds for Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
PerMalmberg committed Aug 31, 2019
1 parent bd7ed05 commit c733195
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,17 @@ set(SMOOTH_SOURCES
${CMAKE_CURRENT_LIST_DIR}/smooth/include/smooth/core/filesystem/SDCard.h
${CMAKE_CURRENT_LIST_DIR}/smooth/include/smooth/core/filesystem/SPISDCard.h
${CMAKE_CURRENT_LIST_DIR}/smooth/include/smooth/core/filesystem/MMCSDCard.h
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/InterruptInput.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/Input.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/include/smooth/core/io/Input.h
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/Output.cpp
$ENV{IDF_PATH}/components/json/cJSON/cJSON.c
$ENV{IDF_PATH}/components/json/cJSON/cJSON.h
)

if (${ESP_PLATFORM})
list(APPEND SMOOTH_SOURCES
${CMAKE_CURRENT_LIST_DIR}/smooth/core/logging/idf/idf_log.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/Input.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/Output.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/InterruptInput.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/i2c/I2CCommandLink.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/i2c/I2CMasterDevice.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/core/io/i2c/Master.cpp
Expand All @@ -162,7 +163,6 @@ if (${ESP_PLATFORM})
${CMAKE_CURRENT_LIST_DIR}/smooth/application/io/i2c/MCP23017.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/application/io/i2c/BME280.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/application/io/wiegand/Wiegand.cpp
${CMAKE_CURRENT_LIST_DIR}/smooth/include/smooth/core/io/Input.h
)
else()
list(APPEND SMOOTH_SOURCES
Expand Down
17 changes: 17 additions & 0 deletions mock-idf/components/driver/gpio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <driver/gpio.h>
#include <esp_err.h>

esp_err_t gpio_isr_handler_add(gpio_num_t /*gpio_num*/, gpio_isr_t /*isr_handler*/, void* args)
{
return ESP_OK;
}

esp_err_t gpio_config(const gpio_config_t* /*pGPIOConfig*/)
{
return ESP_OK;
}

int gpio_get_level(gpio_num_t /*gpio_num*/)
{
return 0;
}
4 changes: 3 additions & 1 deletion mock-idf/components/esp_common/include/esp_err.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ typedef int32_t esp_err_t;

#define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */
#define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */
#define ESP_ERR_FLASH_BASE 0x6000 /*!< Starting number of flash error codes */
#define ESP_ERR_FLASH_BASE 0x6000 /*!< Starting number of flash error codes */

#define ESP_ERROR_CHECK(x) (x)
1 change: 1 addition & 0 deletions mock-idf/components/freertos/include/freertos/FreeRTOS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#pragma once
14 changes: 14 additions & 0 deletions mock-idf/components/freertos/include/freertos/portmacro.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#pragma once

#include <cstdint>

#define portCHAR int8_t
#define portFLOAT float
#define portDOUBLE double
#define portLONG int32_t
#define portSHORT int16_t
#define portSTACK_TYPE uint8_t
#define portBASE_TYPE int

typedef portSTACK_TYPE StackType_t;
typedef portBASE_TYPE BaseType_t;
typedef unsigned portBASE_TYPE UBaseType_t;

typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
12 changes: 12 additions & 0 deletions mock-idf/components/freertos/include/freertos/projdefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

/* Converts a time in milliseconds to a time in ticks. */
#define pdMS_TO_TICKS( xTimeInMs ) ( ( ( TickType_t ) ( xTimeInMs ) * configTICK_RATE_HZ ) / ( TickType_t ) 1000 )

#define pdFALSE ( ( BaseType_t ) 0 )
#define pdTRUE ( ( BaseType_t ) 1 )

#define pdPASS ( pdTRUE )
#define pdFAIL ( pdFALSE )
#define errQUEUE_EMPTY ( ( BaseType_t ) 0 )
#define errQUEUE_FULL ( ( BaseType_t ) 0 )
48 changes: 48 additions & 0 deletions mock-idf/components/freertos/include/freertos/queue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once

#include "portmacro.h"
#include "projdefs.h"

#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U )
#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U )
#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U )
#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U )
#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U )
#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U )

#define queueSEND_TO_BACK ( ( BaseType_t ) 0 )
#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 )
#define queueOVERWRITE ( ( BaseType_t ) 2 )

typedef void* QueueHandle_t;

UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );

QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
const uint8_t ucQueueType );

BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
const void* const pvItemToQueue,
BaseType_t* const pxHigherPriorityTaskWoken,
const BaseType_t xCopyPosition );

BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t* const pxHigherPriorityTaskWoken );

BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void* const pvBuffer,
BaseType_t* const pxHigherPriorityTaskWoken );

#define xQueueCreate( uxQueueLength, \
uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) )

#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, \
pxHigherPriorityTaskWoken ) \
xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )

#define xQueueReceive( xQueue, pvBuffer, \
xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )

BaseType_t xQueueGenericReceive( QueueHandle_t xQueue,
void* const pvBuffer,
TickType_t xTicksToWait,
const BaseType_t xJustPeek );
39 changes: 39 additions & 0 deletions mock-idf/components/freertos/queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <freertos/queue.h>

UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t /*xQueue*/ )
{
return 0;
}

QueueHandle_t xQueueGenericCreate( const UBaseType_t /*uxQueueLength*/, const UBaseType_t /*uxItemSize*/,
const uint8_t /*ucQueueType*/ )
{
return nullptr;
}

BaseType_t xQueueGenericSendFromISR( QueueHandle_t /*xQueue*/,
const void* const /*pvItemToQueue*/,
BaseType_t* const /*pxHigherPriorityTaskWoken*/,
const BaseType_t /*xCopyPosition*/ )
{
return pdPASS;
}

BaseType_t xQueueGiveFromISR( QueueHandle_t /*xQueue*/, BaseType_t* const /*pxHigherPriorityTaskWoken*/)
{
return pdPASS;
}

BaseType_t xQueueReceiveFromISR( QueueHandle_t /*xQueue*/, void* const /*pvBuffer*/,
BaseType_t* const /*pxHigherPriorityTaskWoken*/ )
{
return pdFAIL;
}

BaseType_t xQueueGenericReceive( QueueHandle_t /*xQueue*/,
void* const /*pvBuffer*/,
TickType_t /*xTicksToWait*/,
const BaseType_t /*xJustPeek*/ )
{
return pdFAIL;
}

0 comments on commit c733195

Please sign in to comment.