Moved platform
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@222 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file led.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file led.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
#ifndef LED_INC_LED_H_
|
||||
#define LED_INC_LED_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "IODevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct Led
|
||||
{
|
||||
struct IODevice device;
|
||||
T_PL_GPIO ledGpio;
|
||||
bool status;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus LED_construct (struct Led* self);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* LED_turnOn
|
||||
* Turns on the LED identified with the ID
|
||||
*
|
||||
* @param ledID Unique identifier of the LED
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if init was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus LED_turnOn(struct Led* led);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* LED_turnOff
|
||||
* Turns off the LED identified with the ID
|
||||
*
|
||||
* @param ledID Unique identifier of the LED
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if init was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus LED_turnOff(struct Led* led);
|
||||
|
||||
#endif /* LED_INC_LED_H_ */
|
||||
@@ -0,0 +1,111 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file platform.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {HAL} {group_description}
|
||||
/// This file defines the properties for the Olimex STM32 H107 dev-kit
|
||||
/// platform.
|
||||
///
|
||||
|
||||
/// @file olx_stm32_h107.h
|
||||
/// @ingroup {HAL}
|
||||
|
||||
|
||||
#ifndef PLATFORM_INC_PLATFORM_H_
|
||||
#define PLATFORM_INC_PLATFORM_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "stm32f10x_gpio.h"
|
||||
#include "stm32f10x_rcc.h"
|
||||
#include "stm32f10x_spi.h"
|
||||
#include "stm32f10x_usart.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GPIO_TypeDef* GPIO_Typedef;
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
} T_PL_GPIO;
|
||||
|
||||
|
||||
// Export of LEDs
|
||||
extern struct Led* const ledGreen;
|
||||
extern struct Led* const ledOrange;
|
||||
// Export of UARTs
|
||||
extern struct Uart* const uart1;
|
||||
// Export of SPIs
|
||||
extern struct Spi* const spi1;
|
||||
extern struct Spi* const spi3;
|
||||
extern struct SpiDevice* const spiDAC;
|
||||
extern struct SpiDevice* const spiDisplay;
|
||||
extern struct SpiDevice* const spiEEPROM;
|
||||
|
||||
extern struct Keypad* const keypad;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* initPlatform
|
||||
* Initialises the platform-specific properties like GPIO, peripheral systems
|
||||
* and the like
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if init was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus initPlatform(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* destructPlatform
|
||||
* Function de de-initialise (destruct) the platform-specific properties and
|
||||
* safely remove all settings that have been set-up with the initPlatform
|
||||
* function
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if init was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus destructPlatform(void);
|
||||
|
||||
#endif /* PLATFORM_INC_PLATFORM_H_ */
|
||||
@@ -0,0 +1,151 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file spi.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file spi.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
#ifndef MISC_INC_SPI_H_
|
||||
#define MISC_INC_SPI_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "IODevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define SPI_DEF_Direction (SPI_Direction_2Lines_FullDuplex)
|
||||
#define SPI_DEF_Mode (SPI_Mode_Master)
|
||||
#define SPI_DEF_DataSize (SPI_DataSize_8b)
|
||||
#define SPI_DEF_CPOL (SPI_CPOL_Low)
|
||||
#define SPI_DEF_CPHA (SPI_CPHA_1Edge)
|
||||
#define SPI_DEF_NSS (SPI_NSS_Hard)
|
||||
#define SPI_DEF_BaudRatePrescaler (SPI_BaudRatePrescaler_2)
|
||||
#define SPI_DEF_FirstBit (SPI_FirstBit_MSB)
|
||||
#define SPI_DEF_CRCPolynomial (7)
|
||||
#define SPI_DEF_RX_QUEUE (16)
|
||||
#define SPI_DEF_TX_QUEUE (16)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct spiQueueItem
|
||||
{
|
||||
char byte;
|
||||
};
|
||||
|
||||
struct Spi
|
||||
{
|
||||
SPI_TypeDef* SPI_TypeDef;
|
||||
SPI_InitTypeDef SPI_InitStruct;
|
||||
T_PL_GPIO SPI_CLK;
|
||||
const T_PL_GPIO* SPI_CE;
|
||||
T_PL_GPIO SPI_MOSI;
|
||||
T_PL_GPIO SPI_MISO;
|
||||
SemaphoreHandle_t spiClaimed; //! Semaphore to protect SPI bus
|
||||
//! against multiple use
|
||||
SemaphoreHandle_t txSemaphore; //! Semaphore for transmit handler
|
||||
//! to allow wait state while
|
||||
//! transmission is active
|
||||
xQueueHandle txQueue; //! SPI Transfer queue identifier
|
||||
xQueueHandle rxQueue; //! SPI Receive queue identifier
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
struct SpiParameters
|
||||
{
|
||||
uint16_t SPI_Direction;
|
||||
uint16_t SPI_Mode;
|
||||
uint16_t SPI_DataSize;
|
||||
uint16_t SPI_CPOL;
|
||||
uint16_t SPI_CPHA;
|
||||
uint16_t SPI_NSS;
|
||||
uint16_t SPI_BaudRatePrescaler;
|
||||
uint16_t SPI_FirstBit;
|
||||
uint16_t SPI_CRCPolynomial;
|
||||
UBaseType_t txQueueSize;
|
||||
UBaseType_t rxQueueSize;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Spi_construct
|
||||
* Description of function
|
||||
*
|
||||
* @param self The SPi object to initialize
|
||||
* @param parameters The SPI parameters to use
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if writing message was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus SPI_construct(struct Spi* self, const struct SpiParameters* parameters);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* SPI_destruct
|
||||
* Destructor for SPI interface in argument "self"
|
||||
*
|
||||
* @param self SPI to destruct
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if destruct was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus SPI_destruct(struct Spi* self);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Spi_getDefaultParameters
|
||||
* Function that assigns default parameters to the spi struct
|
||||
*
|
||||
* @param parameters
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if destruct was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus SPI_getDefaultParameters(struct SpiParameters* parameters);
|
||||
|
||||
|
||||
#endif /* MISC_INC_SPI_H_ */
|
||||
@@ -0,0 +1,78 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file spiDevice.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file spiDevice.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef PLATFORM_INC_SPIDEVICE_H_
|
||||
#define PLATFORM_INC_SPIDEVICE_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "IODevice.h"
|
||||
#include "spi.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct SpiDevice
|
||||
{
|
||||
struct IODevice device;
|
||||
struct Spi* spi;
|
||||
struct SpiParameters parameters;
|
||||
T_PL_GPIO SPI_CE;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
extern ErrorStatus SpiDevice_construct(struct SpiDevice* self, struct Spi* spi, const struct SpiParameters* parameters, T_PL_GPIO SPI_CE);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Spi_Write
|
||||
* Write the data in buffer to the SPI in argument self
|
||||
*
|
||||
* @param self The UART class object
|
||||
* @param buffer Message string to send
|
||||
* @parm length Message length
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if writing message was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus SpiDevice_write (const struct SpiDevice* self, const char* buffer, int length);
|
||||
|
||||
#endif /* PLATFORM_INC_SPIDEVICE_H_ */
|
||||
@@ -0,0 +1,146 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file uart.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file uart.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
#ifndef MISC_INC_UART_H_
|
||||
#define MISC_INC_UART_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "IODevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define UART_DEF_BAUDRATE (9600)
|
||||
#define UART_DEF_WORDLENGTH (USART_WordLength_8b)
|
||||
#define UART_DEF_STOPBITS (USART_StopBits_1)
|
||||
#define UART_DEF_PARITY (USART_Parity_No)
|
||||
#define UART_DEF_MODE (USART_Mode_Tx | USART_Mode_Rx)
|
||||
#define UART_DEF_HW_FLOW_CONTROL (USART_HardwareFlowControl_None)
|
||||
#define UART_DEF_RX_QUEUE (32)
|
||||
#define UART_DEF_TX_QUEUE (32)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct usartQueueItem
|
||||
{
|
||||
char byte;
|
||||
};
|
||||
|
||||
struct UartParameters
|
||||
{
|
||||
uint32_t baudrate;
|
||||
uint16_t wordlength;
|
||||
uint16_t stopbits;
|
||||
uint16_t parity;
|
||||
uint16_t mode;
|
||||
uint16_t hwFlowControl;
|
||||
UBaseType_t txQueueSize;
|
||||
UBaseType_t rxQueueSize;
|
||||
};
|
||||
|
||||
struct Uart
|
||||
{
|
||||
struct IODevice device;
|
||||
USART_TypeDef* USART_TypeDef;
|
||||
USART_InitTypeDef USART_InitStruct;
|
||||
USART_ClockInitTypeDef* USART_ClockInitStruct;
|
||||
T_PL_GPIO USART_RX;
|
||||
T_PL_GPIO USART_TX;
|
||||
T_PL_GPIO USART_CTS;
|
||||
T_PL_GPIO USART_RTS;
|
||||
SemaphoreHandle_t txSemaphore; //! Semaphore for transmit handler
|
||||
xQueueHandle txQueue; //! USART Transfer queue identifier
|
||||
xQueueHandle rxQueue; //! USART Receive queue identifier
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Uart_construct
|
||||
* Description of function
|
||||
*
|
||||
* @param _self The UART object to initialize
|
||||
* @param baudrate Baudrate to use
|
||||
* @param wordlength Wordlength for the UART
|
||||
* @param stopbits Number of stopbits to use
|
||||
* @param parity Parity of the UART
|
||||
* @param mode Mode (TX, RX, Both)
|
||||
* @param hwFlowControl Control of hardware flow control
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if writing message was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Uart_construct(struct Uart* self, struct UartParameters* parameters);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Uart_getDefaultParameters
|
||||
* Function that assigns default parameters to the uart struct
|
||||
*
|
||||
* @param parameters
|
||||
*
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Uart_getDefaultParameters(struct UartParameters* parameters);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Uart_Write
|
||||
* Description of function
|
||||
*
|
||||
* @param self The UART class object
|
||||
* @param buffer Message string to send
|
||||
* @param length Message length
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if writing message was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Uart_Write(struct Uart* self, const char* buffer, int length);
|
||||
|
||||
|
||||
|
||||
#endif /* MISC_INC_UART_H_ */
|
||||
Reference in New Issue
Block a user