Improvements:

- HAL re-organized
- FreeRTOS running stable
- UART finished
- SPI1 & SPI3 finished and functional
- Display driver added (functional)


git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@172 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-09-20 06:51:53 +00:00
parent f5dd9e0f09
commit c9562e8bfd
313 changed files with 8279 additions and 50216 deletions

View File

@@ -0,0 +1,87 @@
// -----------------------------------------------------------------------------
/// @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"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct Led
{
T_PL_GPIO ledGpio;
bool status;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* 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* const 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* const led);
#endif /* LED_INC_LED_H_ */

View File

@@ -0,0 +1,136 @@
// -----------------------------------------------------------------------------
/// @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"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct spiQueueItem
{
char byte;
};
struct Spi
{
SPI_TypeDef* SPI_TypeDef;
SPI_InitTypeDef SPI_InitStruct;
T_PL_GPIO SPI_CLK;
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 SpiDevice
{
struct Spi* spi;
T_PL_GPIO SPI_CE;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* Spi_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 SPI_construct(struct Spi* self, 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);
/** ----------------------------------------------------------------------------
* 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_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 SPI_write (struct SpiDevice* self, const uint8_t* buffer, int length);
#endif /* MISC_INC_SPI_H_ */

View File

@@ -0,0 +1,117 @@
// -----------------------------------------------------------------------------
/// @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"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct usartQueueItem
{
char byte;
};
struct UartParameters
{
int baudrate;
};
struct Uart
{
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_Init
* 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_Init(struct Uart* _self, uint32_t baudrate, uint16_t wordlength, uint16_t stopbits, uint16_t parity, uint16_t mode, uint16_t hwFlowControl, UBaseType_t txQueueSize, UBaseType_t rxQueueSize);
/** ----------------------------------------------------------------------------
* Uart_Write
* Description of function
*
* @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 Uart_Write(struct Uart* _self, const uint8_t* buffer, int length);
#endif /* MISC_INC_UART_H_ */