- added IODevice support
- fixed some issues with the logger and stack sizes git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@216 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
*** SESSION sep. 08, 2017 14:48:18.37 ------------------------------------------
|
|
||||||
*** SESSION sep. 08, 2017 15:45:22.37 ------------------------------------------
|
|
||||||
*** SESSION sep. 11, 2017 08:26:16.00 ------------------------------------------
|
|
||||||
*** SESSION sep. 12, 2017 09:08:37.66 ------------------------------------------
|
|
||||||
*** SESSION sep. 12, 2017 12:28:02.99 ------------------------------------------
|
|
||||||
*** SESSION sep. 13, 2017 08:31:48.14 ------------------------------------------
|
|
||||||
*** SESSION sep. 13, 2017 08:34:07.49 ------------------------------------------
|
|
||||||
*** SESSION sep. 13, 2017 08:56:22.06 ------------------------------------------
|
|
||||||
*** SESSION sep. 13, 2017 09:06:20.00 ------------------------------------------
|
|
||||||
*** SESSION sep. 13, 2017 10:19:50.15 ------------------------------------------
|
|
||||||
*** SESSION sep. 13, 2017 16:09:45.61 ------------------------------------------
|
|
||||||
*** SESSION sep. 15, 2017 11:33:26.35 ------------------------------------------
|
|
||||||
*** SESSION sep. 19, 2017 14:17:27.20 ------------------------------------------
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<section name="Workbench">
|
|
||||||
<section name="RefactoringWizard.preview">
|
|
||||||
<item value="600" key="width"/>
|
|
||||||
<item value="400" key="height"/>
|
|
||||||
</section>
|
|
||||||
<section name="RefactoringStatusDialog">
|
|
||||||
<item value="816" key="DIALOG_WIDTH"/>
|
|
||||||
<item value="1|Segoe UI|9.0|0|WINDOWS|1|-12|0|0|0|400|0|0|0|1|0|0|0|0|Segoe UI" key="DIALOG_FONT_NAME"/>
|
|
||||||
<item value="490" key="DIALOG_HEIGHT"/>
|
|
||||||
</section>
|
|
||||||
<section name="RefactoringPropertyPage">
|
|
||||||
<item value="true" key="org.eclipse.ltk.ui.refactoring.sortRefactorings"/>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<section name="Workbench">
|
|
||||||
<section name="org.eclipse.ui.texteditor.FindReplaceDialog">
|
|
||||||
<item value="false" key="isRegEx"/>
|
|
||||||
<item value="SPI_BaudRate_Prescaler" key="selection"/>
|
|
||||||
<item value="false" key="casesensitive"/>
|
|
||||||
<item value="false" key="incremental"/>
|
|
||||||
<item value="true" key="wrap"/>
|
|
||||||
<item value="false" key="wholeword"/>
|
|
||||||
<list key="findhistory">
|
|
||||||
<item value="SPI_BaudRate_Prescaler"/>
|
|
||||||
<item value="usart_queue_item"/>
|
|
||||||
<item value="INCLUDE_xResumeFromISR"/>
|
|
||||||
<item value="usartTxQueue"/>
|
|
||||||
<item value="txSemaphore"/>
|
|
||||||
<item value="Queue"/>
|
|
||||||
<item value="USART"/>
|
|
||||||
<item value="USART_Last_Bit"/>
|
|
||||||
</list>
|
|
||||||
<list key="replacehistory">
|
|
||||||
<item value="usartQueueItem"/>
|
|
||||||
</list>
|
|
||||||
</section>
|
|
||||||
<section name="org.eclipse.ui.texteditor.FindReplaceDialog_dialogBounds">
|
|
||||||
<item value="284" key="DIALOG_WIDTH"/>
|
|
||||||
<item value="1|Segoe UI|9.0|0|WINDOWS|1|-12|0|0|0|400|0|0|0|1|0|0|0|0|Segoe UI" key="DIALOG_FONT_NAME"/>
|
|
||||||
<item value="391" key="DIALOG_HEIGHT"/>
|
|
||||||
<item value="1318" key="DIALOG_X_ORIGIN"/>
|
|
||||||
<item value="427" key="DIALOG_Y_ORIGIN"/>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#Tue Sep 19 14:17:20 CEST 2017
|
|
||||||
org.eclipse.core.runtime=2
|
|
||||||
org.eclipse.platform=4.6.3.v20170301-0400
|
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -32,12 +32,25 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "spi.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define NHD0420_SPI_MAX_CLK_HZ (100000)
|
||||||
|
// SPI settings
|
||||||
|
#define NHD0420_SPI_Direction (SPI_Direction_1Line_Tx)
|
||||||
|
#define NHD0420_SPI_Mode (SPI_Mode_Master)
|
||||||
|
#define NHD0420_SPI_DataSize (SPI_DataSize_8b)
|
||||||
|
#define NHD0420_SPI_CPOL (SPI_CPOL_High)
|
||||||
|
#define NHD0420_SPI_CPHA (SPI_CPHA_2Edge)
|
||||||
|
#define NHD0420_SPI_NSS (SPI_NSS_Soft)
|
||||||
|
#define NHD0420_SPI_FirstBit (SPI_FirstBit_MSB)
|
||||||
|
#define NHD0420_SPI_CRCPolynomial (7)
|
||||||
|
#define NHD0420_SPI_RX_QUEUE (32)
|
||||||
|
#define NHD0420_SPI_TX_QUEUE (32)
|
||||||
|
|
||||||
#define NHD0420_NUMBER_OF_ROWS (4)
|
#define NHD0420_NUMBER_OF_ROWS (4)
|
||||||
#define NHD0420_NUMBER_OF_COLUMNS (20)
|
#define NHD0420_NUMBER_OF_COLUMNS (20)
|
||||||
|
|
||||||
@@ -109,7 +122,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
* NHD0420_Init
|
* NHD0420_construct
|
||||||
* Initialises the NewHeaven Display 0420
|
* Initialises the NewHeaven Display 0420
|
||||||
*
|
*
|
||||||
* @param interface The interface to use
|
* @param interface The interface to use
|
||||||
@@ -123,6 +136,34 @@
|
|||||||
extern ErrorStatus NHD0420_construct(void* interface);
|
extern ErrorStatus NHD0420_construct(void* interface);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* NHD0420_destruct
|
||||||
|
* Destructor for the NHD0420 instance
|
||||||
|
*
|
||||||
|
* @param interface The interface to use
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void NHD0420_destruct(void);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* NHD0420_getSpiParameters
|
||||||
|
* Function that assigns the NHD0420 SPI parameters to a spiParameters struct
|
||||||
|
*
|
||||||
|
* @param parameters
|
||||||
|
*
|
||||||
|
* @return ErrorStatus
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters);
|
||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
* NHD0420_setCursorToPosition
|
* NHD0420_setCursorToPosition
|
||||||
* Sets the cursor of the display to the specified row and column
|
* Sets the cursor of the display to the specified row and column
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -25,7 +25,9 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
#include "nhd0420.h"
|
#include "nhd0420.h"
|
||||||
@@ -58,6 +60,8 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] =
|
|||||||
NHD0420_CURSOR_OFFSET_ROW4
|
NHD0420_CURSOR_OFFSET_ROW4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool initialized = false;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -72,7 +76,65 @@ static struct SpiDevice* nhd0420Interface;
|
|||||||
ErrorStatus NHD0420_construct(void* interface)
|
ErrorStatus NHD0420_construct(void* interface)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
nhd0420Interface = (struct SpiDevice*)interface;
|
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
nhd0420Interface = (struct SpiDevice*)interface;
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NHD0420_destruct (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
if ((configCPU_CLOCK_HZ / 64) < NHD0420_SPI_MAX_CLK_HZ)
|
||||||
|
{
|
||||||
|
parameters->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;
|
||||||
|
}
|
||||||
|
else if ((configCPU_CLOCK_HZ / 128) < NHD0420_SPI_MAX_CLK_HZ)
|
||||||
|
{
|
||||||
|
parameters->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;
|
||||||
|
}
|
||||||
|
else if ((configCPU_CLOCK_HZ / 256) < NHD0420_SPI_MAX_CLK_HZ)
|
||||||
|
{
|
||||||
|
parameters->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The CPU clock is too high. The pre-scaler has a max of 256. A clock higher than 25,6 MHz
|
||||||
|
// results in a SPI CLK higher than 100 kHz, which is the max of the display
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
// SPI pre-scaler was no problem - assign the remaining parameters
|
||||||
|
parameters->SPI_CPHA = NHD0420_SPI_CPHA;
|
||||||
|
parameters->SPI_CPOL = NHD0420_SPI_CPOL;
|
||||||
|
parameters->SPI_CRCPolynomial = NHD0420_SPI_CRCPolynomial;
|
||||||
|
parameters->SPI_DataSize = NHD0420_SPI_DataSize;
|
||||||
|
parameters->SPI_Direction = NHD0420_SPI_Direction;
|
||||||
|
parameters->SPI_FirstBit = NHD0420_SPI_FirstBit;
|
||||||
|
parameters->SPI_Mode = NHD0420_SPI_Mode;
|
||||||
|
parameters->SPI_NSS = NHD0420_SPI_NSS;
|
||||||
|
parameters->rxQueueSize = NHD0420_SPI_RX_QUEUE;
|
||||||
|
parameters->txQueueSize = NHD0420_SPI_TX_QUEUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
@@ -100,7 +162,7 @@ ErrorStatus NHD0420_setCursorToPosition(uint8_t row, uint8_t column)
|
|||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
uint8_t address = nhd0420_cursorRowOffset[row] + column;
|
uint8_t address = nhd0420_cursorRowOffset[row] + column;
|
||||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
|
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CURSOR_SET, address};
|
||||||
returnValue = NHD0420_sendData(buffer, 3);
|
returnValue = NHD0420_sendData(buffer, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +188,7 @@ ErrorStatus NHD0420_setContrast(uint8_t contrast)
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
|
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_CONTRAST, contrast};
|
||||||
returnValue = NHD0420_sendData(buffer, 3);
|
returnValue = NHD0420_sendData(buffer, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +214,7 @@ ErrorStatus NHD0420_setBacklightBrightness(uint8_t brightness)
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
|
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_SET_BRIGHTNESS, brightness};
|
||||||
returnValue = NHD0420_sendData(buffer, 3);
|
returnValue = NHD0420_sendData(buffer, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +239,7 @@ ErrorStatus NHD0420_setRS232Baudrate(uint8_t baudrate)
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
|
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_RS232_BR, baudrate};
|
||||||
returnValue = NHD0420_sendData(buffer, 3);
|
returnValue = NHD0420_sendData(buffer, 3);
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -201,7 +263,7 @@ ErrorStatus NHD0420_setI2CAddress(uint8_t address)
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
char buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
|
uint8_t buffer[3] = {NHD0420_CMD_PREFIX, NHD0420_CMD_CHANGE_I2C_ADDRSS, address};
|
||||||
returnValue = NHD0420_sendData(buffer, 3);
|
returnValue = NHD0420_sendData(buffer, 3);
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
CROSS_COMPILE = arm-none-eabi-
|
||||||
|
CC = $(CROSS_COMPILE)gcc
|
||||||
|
LD = $(CROSS_COMPILE)gcc
|
||||||
|
AR = $(CROSS_COMPILE)ar
|
||||||
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
|
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||||
|
|
||||||
|
OBJDIR = obj
|
||||||
|
SRCDIR = src/
|
||||||
|
ROOTDIR = ../../
|
||||||
|
|
||||||
|
LIBRARY_NAME = ../libKeypad.a
|
||||||
|
|
||||||
|
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb \
|
||||||
|
-Iinc \
|
||||||
|
-I../Platform/inc \
|
||||||
|
-I../Misc/inc \
|
||||||
|
-I$(ROOTDIR)/hsb-mrts/inc \
|
||||||
|
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc \
|
||||||
|
-I$(ROOTDIR)/FreeRTOS/Source/include \
|
||||||
|
-I$(ROOTDIR)/FreeRTOS/Source/portable/GCC/ARM_CM3 \
|
||||||
|
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x \
|
||||||
|
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/CoreSupport
|
||||||
|
ARFLAGS = rs
|
||||||
|
|
||||||
|
OBJECTS = \
|
||||||
|
keypadMatrix.o \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vpath %.o $(OBJDIR)
|
||||||
|
vpath %.c $(SRCDIR)
|
||||||
|
|
||||||
|
all: $(LIBRARY_NAME)
|
||||||
|
|
||||||
|
$(LIBRARY_NAME): $(OBJDIR) $(OBJECTS)
|
||||||
|
$(AR) $(ARFLAGS) $@ $(addprefix $(OBJDIR)/, $(OBJECTS))
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(CCFLAGS) $< -o $(OBJDIR)/$@
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(OBJDIR) $(LIBRARY_NAME)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file keypadMatrix.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 keypadMatrix.h
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef KEYPAD_INC_KEYPADMATRIX_H_
|
||||||
|
#define KEYPAD_INC_KEYPADMATRIX_H_
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "stm32f10x_exti.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define KEYPAD_NUMBER_OF_ROWS (4)
|
||||||
|
#define KEYPAD_NUMBER_OF_COLUMNS (4)
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct keypadElement
|
||||||
|
{
|
||||||
|
T_PL_GPIO gpio;
|
||||||
|
EXTI_InitTypeDef EXTI_InitStruct;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Keypad
|
||||||
|
{
|
||||||
|
struct keypadElement row[KEYPAD_NUMBER_OF_ROWS];
|
||||||
|
struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS];
|
||||||
|
};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* Keypad_construct
|
||||||
|
* contructor for the Keypad driver
|
||||||
|
*
|
||||||
|
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||||
|
* ERROR otherwise
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern ErrorStatus Keypad_construct(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern ErrorStatus Keypad_logModuleInfo(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* KEYPAD_INC_KEYPADMATRIX_H_ */
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file keypadMatrix.c
|
||||||
|
/// @brief 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
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// @file keypadMatrix.c
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "FreeRTOSFixes.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#include "keypadMatrix.h"
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define KEYPAD_STACK_SIZE (512)
|
||||||
|
#define KEYPAD_TASK_PRIORITY (3)
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// File-scope variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static bool initialized = false;
|
||||||
|
static xTaskHandle keypadTaskHandle = NULL;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void KeypadTask(void* parameters);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus Keypad_construct(void)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
BaseType_t taskCreateReturn;
|
||||||
|
|
||||||
|
if(!initialized)
|
||||||
|
{
|
||||||
|
if(returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
taskCreateReturn = xTaskCreate(KeypadTask, (const char*)"keypadTask", KEYPAD_STACK_SIZE, NULL, KEYPAD_TASK_PRIORITY, &keypadTaskHandle);
|
||||||
|
if(taskCreateReturn != pdPASS)
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
LOGGER_INFO("Keypad task started");
|
||||||
|
// GPIO_SetBits(kRow1->rowGpio.GPIO_Typedef, kRow1->rowGpio.GPIO_InitStruct.GPIO_Pin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER_ERROR("Keypad task FAILED with code %x", (unsigned int)taskCreateReturn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus Keypad_logModuleInfo(void)
|
||||||
|
{
|
||||||
|
ErrorStatus errorStatus = SUCCESS;
|
||||||
|
|
||||||
|
OS_logTaskInfo(keypadTaskHandle);
|
||||||
|
|
||||||
|
return errorStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Keypad_Destruct (void)
|
||||||
|
{
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void KeypadTask(void* parameters)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
vTaskDelay(1000);
|
||||||
|
|
||||||
|
LOGGER_DEBUG("ROW1: %d, ROW2: %d, ROW3: %d, ROW4: %d - Col1: %d, Col2: %d, Col3: %d, Col4: %d",
|
||||||
|
GPIO_ReadOutputDataBit(keypad->row[0].gpio.GPIO_Typedef, keypad->row[0].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadOutputDataBit(keypad->row[1].gpio.GPIO_Typedef, keypad->row[1].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadOutputDataBit(keypad->row[2].gpio.GPIO_Typedef, keypad->row[2].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadOutputDataBit(keypad->row[3].gpio.GPIO_Typedef, keypad->row[3].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadInputDataBit(keypad->column[0].gpio.GPIO_Typedef, keypad->column[0].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadInputDataBit(keypad->column[1].gpio.GPIO_Typedef, keypad->column[1].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadInputDataBit(keypad->column[2].gpio.GPIO_Typedef, keypad->column[2].gpio.GPIO_InitStruct.GPIO_Pin),
|
||||||
|
GPIO_ReadInputDataBit(keypad->column[3].gpio.GPIO_Typedef, keypad->column[3].gpio.GPIO_InitStruct.GPIO_Pin)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
all:
|
all:
|
||||||
# $(MAKE) -C Keypad
|
$(MAKE) -C Keypad
|
||||||
$(MAKE) -C Display
|
$(MAKE) -C Display
|
||||||
$(MAKE) -C Misc
|
$(MAKE) -C Misc
|
||||||
$(MAKE) -C Platform
|
$(MAKE) -C Platform
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
# $(MAKE) -C Keypad clean
|
$(MAKE) -C Keypad clean
|
||||||
$(MAKE) -C Display clean
|
$(MAKE) -C Display clean
|
||||||
$(MAKE) -C Misc clean
|
$(MAKE) -C Misc clean
|
||||||
$(MAKE) -C Platform clean
|
$(MAKE) -C Platform clean
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb \
|
|||||||
ARFLAGS = rs
|
ARFLAGS = rs
|
||||||
|
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
stm32f10x_it.o \
|
IODevice.o
|
||||||
led.o \
|
|
||||||
spi.o \
|
|
||||||
uart.o \
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file IODevice.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 IODevice.h
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MISC_INC_IODEVICE_H_
|
||||||
|
#define MISC_INC_IODEVICE_H_
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
struct IODevice;
|
||||||
|
|
||||||
|
typedef ErrorStatus (*ReadFunction)(struct IODevice* self, char* buffer, size_t length, size_t* actualLength);
|
||||||
|
typedef ErrorStatus (*WriteFunction)(struct IODevice* self, const char* buffer, size_t length);
|
||||||
|
|
||||||
|
struct IODevice
|
||||||
|
{
|
||||||
|
ReadFunction _read;
|
||||||
|
WriteFunction _write;
|
||||||
|
};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern ErrorStatus IODevice_construct (struct IODevice* self, ReadFunction read, WriteFunction write);
|
||||||
|
|
||||||
|
extern ErrorStatus IODevice_write(struct IODevice* self, const char* buffer, size_t length);
|
||||||
|
|
||||||
|
extern ErrorStatus IODevice_read(struct IODevice* self, char* buffer, size_t length, size_t* actualLength);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* MISC_INC_IODEVICE_H_ */
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file IODevice.c
|
||||||
|
/// @brief 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
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// @file IODevice.c
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "IODevice.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// File-scope variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus IODevice_construct (struct IODevice* self, ReadFunction read, WriteFunction write)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
self->_write = write;
|
||||||
|
self->_read = read;
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorStatus IODevice_write(struct IODevice* self, const char* buffer, size_t length)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
if (self->_write != NULL)
|
||||||
|
{
|
||||||
|
self->_write(self, buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ LIBRARY_NAME = ../libPlatform.a
|
|||||||
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb -DOLI_STM32_H107 \
|
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb -DOLI_STM32_H107 \
|
||||||
-Iinc \
|
-Iinc \
|
||||||
-I../Misc/inc \
|
-I../Misc/inc \
|
||||||
|
-I../Keypad/inc \
|
||||||
|
-I../Display/inc \
|
||||||
-I$(ROOTDIR)/hsb-mrts/inc \
|
-I$(ROOTDIR)/hsb-mrts/inc \
|
||||||
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc \
|
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc \
|
||||||
-I$(ROOTDIR)/FreeRTOS/Source/include \
|
-I$(ROOTDIR)/FreeRTOS/Source/include \
|
||||||
@@ -23,12 +25,17 @@ CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb -DOLI_STM32_H107 \
|
|||||||
ARFLAGS = rs
|
ARFLAGS = rs
|
||||||
|
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
|
stm32f10x_it.o \
|
||||||
|
led.o \
|
||||||
|
spi.o \
|
||||||
|
uart.o \
|
||||||
oli_stm32_h107.o \
|
oli_stm32_h107.o \
|
||||||
|
|
||||||
|
|
||||||
vpath %.o $(OBJDIR)
|
vpath %.o $(OBJDIR)
|
||||||
vpath %.c \
|
vpath %.c \
|
||||||
$(SRCDIR)
|
$(SRCDIR) \
|
||||||
|
$(ROOTDIR)/hsb-mrts/src
|
||||||
|
|
||||||
all: $(LIBRARY_NAME)
|
all: $(LIBRARY_NAME)
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -34,6 +34,8 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "FreeRTOSConfig.h"
|
#include "FreeRTOSConfig.h"
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
@@ -71,6 +73,9 @@ extern struct SpiDevice* const spiDAC;
|
|||||||
extern struct SpiDevice* const spiDisplay;
|
extern struct SpiDevice* const spiDisplay;
|
||||||
extern struct SpiDevice* const spiEEPROM;
|
extern struct SpiDevice* const spiEEPROM;
|
||||||
|
|
||||||
|
extern struct Keypad* const keypad;
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -43,7 +43,17 @@
|
|||||||
// Constant and macro definitions
|
// 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.
|
// Type definitions.
|
||||||
@@ -72,9 +82,25 @@ struct Spi
|
|||||||
bool initialized;
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
struct SpiDevice
|
struct SpiDevice
|
||||||
{
|
{
|
||||||
struct Spi* spi;
|
struct Spi* spi;
|
||||||
|
struct SpiParameters* spiParameters;
|
||||||
T_PL_GPIO SPI_CE;
|
T_PL_GPIO SPI_CE;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -86,13 +112,8 @@ struct SpiDevice
|
|||||||
* Spi_construct
|
* Spi_construct
|
||||||
* Description of function
|
* Description of function
|
||||||
*
|
*
|
||||||
* @param self The UART object to initialize
|
* @param self The SPi object to initialize
|
||||||
* @param baudrate Baudrate to use
|
* @param parameters The SPI parameters 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
|
* @return ErrorStatus SUCCESS if writing message was successful
|
||||||
* ERROR otherwise
|
* ERROR otherwise
|
||||||
@@ -100,7 +121,7 @@ struct SpiDevice
|
|||||||
* @todo
|
* @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);
|
extern ErrorStatus SPI_construct(struct Spi* self, struct SpiParameters* parameters);
|
||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
@@ -118,6 +139,21 @@ extern ErrorStatus SPI_construct(struct Spi* self, uint16_t SPI_Direction, uint1
|
|||||||
extern ErrorStatus SPI_destruct(struct Spi* self);
|
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);
|
||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
* Spi_Write
|
* Spi_Write
|
||||||
* Write the data in buffer to the SPI in argument self
|
* Write the data in buffer to the SPI in argument self
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -36,12 +36,20 @@
|
|||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "IODevice.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// 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.
|
// Type definitions.
|
||||||
@@ -54,11 +62,19 @@ struct usartQueueItem
|
|||||||
|
|
||||||
struct UartParameters
|
struct UartParameters
|
||||||
{
|
{
|
||||||
int baudrate;
|
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 Uart
|
||||||
{
|
{
|
||||||
|
struct IODevice device;
|
||||||
USART_TypeDef* USART_TypeDef;
|
USART_TypeDef* USART_TypeDef;
|
||||||
USART_InitTypeDef USART_InitStruct;
|
USART_InitTypeDef USART_InitStruct;
|
||||||
USART_ClockInitTypeDef* USART_ClockInitStruct;
|
USART_ClockInitTypeDef* USART_ClockInitStruct;
|
||||||
@@ -76,7 +92,7 @@ struct Uart
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
* Uart_Init
|
* Uart_construct
|
||||||
* Description of function
|
* Description of function
|
||||||
*
|
*
|
||||||
* @param _self The UART object to initialize
|
* @param _self The UART object to initialize
|
||||||
@@ -93,16 +109,29 @@ struct Uart
|
|||||||
* @todo
|
* @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);
|
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
|
* Uart_Write
|
||||||
* Description of function
|
* Description of function
|
||||||
*
|
*
|
||||||
* @param _self The UART class object
|
* @param self The UART class object
|
||||||
* @param buffer Message string to send
|
* @param buffer Message string to send
|
||||||
* @parm length Message length
|
* @param length Message length
|
||||||
*
|
*
|
||||||
* @return ErrorStatus SUCCESS if writing message was successful
|
* @return ErrorStatus SUCCESS if writing message was successful
|
||||||
* ERROR otherwise
|
* ERROR otherwise
|
||||||
@@ -110,7 +139,7 @@ extern ErrorStatus Uart_Init(struct Uart* _self, uint32_t baudrate, uint16_t wor
|
|||||||
* @todo
|
* @todo
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
extern ErrorStatus Uart_Write(struct Uart* _self, const uint8_t* buffer, int length);
|
extern ErrorStatus Uart_Write(struct Uart* self, const char* buffer, int length);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -34,6 +34,8 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
#include "keypadMatrix.h"
|
||||||
|
#include "nhd0420.h"
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -43,12 +45,6 @@
|
|||||||
// UART1 Settings (Logger/Console)
|
// UART1 Settings (Logger/Console)
|
||||||
#define UART_LOG_TYPEDEF (USART1)
|
#define UART_LOG_TYPEDEF (USART1)
|
||||||
#define UART_LOG_BAUDRATE (57600)
|
#define UART_LOG_BAUDRATE (57600)
|
||||||
#define UART_LOG_WORDLENGTH (USART_WordLength_8b)
|
|
||||||
#define UART_LOG_STOPBITS (USART_StopBits_1)
|
|
||||||
#define UART_LOG_PARITY (USART_Parity_No)
|
|
||||||
#define UART_LOG_MODE (USART_Mode_Tx | USART_Mode_Rx)
|
|
||||||
#define UART_LOG_HW_FLOW_CONTROL (USART_HardwareFlowControl_None)
|
|
||||||
#define UART_LOG_RX_QUEUE (256)
|
|
||||||
#define UART_LOG_TX_QUEUE (256)
|
#define UART_LOG_TX_QUEUE (256)
|
||||||
|
|
||||||
// SPI1 settings
|
// SPI1 settings
|
||||||
@@ -65,20 +61,11 @@
|
|||||||
#define SPI_DAC_RX_QUEUE (32)
|
#define SPI_DAC_RX_QUEUE (32)
|
||||||
#define SPI_DAC_TX_QUEUE (32)
|
#define SPI_DAC_TX_QUEUE (32)
|
||||||
|
|
||||||
// SPI3 settings
|
// SPI3 settings (LCD / EEPROM)
|
||||||
#define SPI_LCD_TYPEDEF (SPI3)
|
#define SPI_LCD_EEPROM_TYPEDEF (SPI3)
|
||||||
#define SPI_LCD_Direction (SPI_Direction_2Lines_FullDuplex)
|
#define SPI_LCD_EEPROM_Direction (SPI_Direction_2Lines_FullDuplex)
|
||||||
#define SPI_LCD_Mode (SPI_Mode_Master)
|
#define SPI_LCD_EEPROM_RX_QUEUE (32)
|
||||||
#define SPI_LCD_DataSize (SPI_DataSize_8b)
|
#define SPI_LCD_EEPROM_TX_QUEUE (32)
|
||||||
#define SPI_LCD_CPOL (SPI_CPOL_High)
|
|
||||||
#define SPI_LCD_CPHA (SPI_CPHA_2Edge)
|
|
||||||
#define SPI_LCD_NSS (SPI_NSS_Soft)
|
|
||||||
// Display has max SPI CLK of 100 kHz
|
|
||||||
#define SPI_LCD_BaudRatePrescaler (SPI_BaudRatePrescaler_128)
|
|
||||||
#define SPI_LCD_FirstBit (SPI_FirstBit_MSB)
|
|
||||||
#define SPI_LCD_CRCPolynomial (7)
|
|
||||||
#define SPI_LCD_RX_QUEUE (32)
|
|
||||||
#define SPI_LCD_TX_QUEUE (32)
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Type definitions
|
// Type definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -97,14 +84,20 @@ static struct Led _ledOrange;
|
|||||||
|
|
||||||
// USART
|
// USART
|
||||||
static struct Uart _uart1;
|
static struct Uart _uart1;
|
||||||
|
static struct UartParameters _uart1Parameters;
|
||||||
|
|
||||||
// SPI
|
// SPI
|
||||||
static struct Spi _spi1;
|
static struct Spi _spi1;
|
||||||
|
static struct SpiParameters _spi1Parameters;
|
||||||
static struct SpiDevice _spiDAC;
|
static struct SpiDevice _spiDAC;
|
||||||
static struct Spi _spi3;
|
static struct Spi _spi3;
|
||||||
|
static struct SpiParameters _spi3Parameters;
|
||||||
static struct SpiDevice _spiDisplay;
|
static struct SpiDevice _spiDisplay;
|
||||||
static struct SpiDevice _spiEEPROM;
|
static struct SpiDevice _spiEEPROM;
|
||||||
|
|
||||||
|
// Keypad
|
||||||
|
static struct Keypad _keypad;
|
||||||
|
|
||||||
// The following pointers are for export (see platform.h) and external use.
|
// The following pointers are for export (see platform.h) and external use.
|
||||||
// Note that the pointer content is marked "const"
|
// Note that the pointer content is marked "const"
|
||||||
struct Led* const ledGreen = &_ledGreen;
|
struct Led* const ledGreen = &_ledGreen;
|
||||||
@@ -116,6 +109,8 @@ struct SpiDevice* const spiDAC = &_spiDAC;
|
|||||||
struct SpiDevice* const spiDisplay = &_spiDisplay;
|
struct SpiDevice* const spiDisplay = &_spiDisplay;
|
||||||
struct SpiDevice* const spiEEPROM = &_spiEEPROM;
|
struct SpiDevice* const spiEEPROM = &_spiEEPROM;
|
||||||
|
|
||||||
|
struct Keypad* const keypad = &_keypad;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -139,17 +134,60 @@ ErrorStatus initPlatform(void)
|
|||||||
// Initialize the Console UART
|
// Initialize the Console UART
|
||||||
IRQ_setInterruptProperties(USART1_IRQn, 15, 15, ENABLE);
|
IRQ_setInterruptProperties(USART1_IRQn, 15, 15, ENABLE);
|
||||||
uart1->USART_TypeDef = UART_LOG_TYPEDEF;
|
uart1->USART_TypeDef = UART_LOG_TYPEDEF;
|
||||||
returnValue = Uart_Init(uart1, UART_LOG_BAUDRATE, UART_LOG_WORDLENGTH, UART_LOG_STOPBITS, UART_LOG_PARITY, UART_LOG_MODE, UART_LOG_HW_FLOW_CONTROL, UART_LOG_TX_QUEUE, UART_LOG_RX_QUEUE);
|
Uart_getDefaultParameters(&_uart1Parameters);
|
||||||
|
// Adjust to higher baudrate for intensive logging
|
||||||
|
_uart1Parameters.baudrate = UART_LOG_BAUDRATE;
|
||||||
|
// Adjust the TX queue size for intensive logging
|
||||||
|
_uart1Parameters.txQueueSize = UART_LOG_TX_QUEUE;
|
||||||
|
returnValue = Uart_construct(uart1, &_uart1Parameters);
|
||||||
|
|
||||||
IRQ_setInterruptProperties(SPI1_IRQn, 11, 11, ENABLE);
|
IRQ_setInterruptProperties(SPI1_IRQn, 11, 11, ENABLE);
|
||||||
spi1->initialized = false;
|
spi1->initialized = false;
|
||||||
spi1->SPI_TypeDef = SPI_DAC_TYPEDEF;
|
spi1->SPI_TypeDef = SPI_DAC_TYPEDEF;
|
||||||
SPI_construct(spi1, SPI_DAC_Direction, SPI_DAC_Mode, SPI_DAC_DataSize, SPI_DAC_CPOL, SPI_DAC_CPHA, SPI_DAC_NSS, SPI_DAC_BaudRatePrescaler, SPI_DAC_FirstBit, SPI_DAC_CRCPolynomial, SPI_DAC_TX_QUEUE, SPI_DAC_RX_QUEUE);
|
SPI_getDefaultParameters(&_spi1Parameters);
|
||||||
|
SPI_construct(spi1, &_spi1Parameters);
|
||||||
|
|
||||||
IRQ_setInterruptProperties(SPI3_IRQn, 12, 12, ENABLE);
|
IRQ_setInterruptProperties(SPI3_IRQn, 12, 12, ENABLE);
|
||||||
spi3->initialized = false;
|
spi3->initialized = false;
|
||||||
spi3->SPI_TypeDef = SPI_LCD_TYPEDEF;
|
spi3->SPI_TypeDef = SPI_LCD_EEPROM_TYPEDEF;
|
||||||
SPI_construct(spi3, SPI_LCD_Direction, SPI_LCD_Mode, SPI_LCD_DataSize, SPI_LCD_CPOL, SPI_LCD_CPHA, SPI_LCD_NSS, SPI_LCD_BaudRatePrescaler, SPI_LCD_FirstBit, SPI_LCD_CRCPolynomial, SPI_LCD_TX_QUEUE, SPI_LCD_RX_QUEUE);
|
// Get the SPI parameters from the NHD0420 driver. They are more critical than the parameters from the EEPROM
|
||||||
|
NHD0420_getSpiParameters(&_spi3Parameters);
|
||||||
|
// In order to use multiple slaves on this bus (and to increase performance), some parameters are altered
|
||||||
|
// Use full-duples instead of TX only, because the EEPROM is both write- and readable
|
||||||
|
_spi3Parameters.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||||
|
// Adjust the RX and TX queues for multiple use
|
||||||
|
_spi3Parameters.rxQueueSize = SPI_LCD_EEPROM_RX_QUEUE;
|
||||||
|
_spi3Parameters.txQueueSize = SPI_LCD_EEPROM_TX_QUEUE;
|
||||||
|
SPI_construct(spi3, &_spi3Parameters);
|
||||||
|
|
||||||
|
// Enable the interrupts for the Keypad columns
|
||||||
|
keypad->column[0].EXTI_InitStruct.EXTI_Line = EXTI_Line4;
|
||||||
|
keypad->column[0].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||||
|
keypad->column[0].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||||
|
keypad->column[0].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||||
|
EXTI_Init(&keypad->column[0].EXTI_InitStruct);
|
||||||
|
// Enable the interrupts for the Keypad columns
|
||||||
|
keypad->column[1].EXTI_InitStruct.EXTI_Line = EXTI_Line5;
|
||||||
|
keypad->column[1].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||||
|
keypad->column[1].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||||
|
keypad->column[1].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||||
|
EXTI_Init(&keypad->column[1].EXTI_InitStruct);
|
||||||
|
// Enable the interrupts for the Keypad columns
|
||||||
|
keypad->column[2].EXTI_InitStruct.EXTI_Line = EXTI_Line6;
|
||||||
|
keypad->column[2].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||||
|
keypad->column[2].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||||
|
keypad->column[2].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||||
|
EXTI_Init(&keypad->column[2].EXTI_InitStruct);
|
||||||
|
// Enable the interrupts for the Keypad columns
|
||||||
|
keypad->column[3].EXTI_InitStruct.EXTI_Line = EXTI_Line7;
|
||||||
|
keypad->column[3].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||||
|
keypad->column[3].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||||
|
keypad->column[3].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||||
|
EXTI_Init(&keypad->column[3].EXTI_InitStruct);
|
||||||
|
|
||||||
|
IRQ_setInterruptProperties(EXTI4_IRQn, 11, 0, ENABLE);
|
||||||
|
IRQ_setInterruptProperties(EXTI9_5_IRQn, 11, 0, ENABLE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +211,8 @@ static ErrorStatus initIO (void)
|
|||||||
|
|
||||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, DISABLE);
|
RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, DISABLE);
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
||||||
|
|
||||||
|
|
||||||
//! Enable USART clock
|
//! Enable USART clock
|
||||||
|
|
||||||
/* Peripheral bus power --------------------------------------------------*/
|
/* Peripheral bus power --------------------------------------------------*/
|
||||||
@@ -180,6 +220,8 @@ static ErrorStatus initIO (void)
|
|||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE);
|
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE);
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||||
|
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, DISABLE);
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
|
||||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE);
|
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE);
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
||||||
|
|
||||||
@@ -285,5 +327,65 @@ static ErrorStatus initIO (void)
|
|||||||
GPIO_Init(_spiEEPROM.SPI_CE.GPIO_Typedef, &_spiEEPROM.SPI_CE.GPIO_InitStruct);
|
GPIO_Init(_spiEEPROM.SPI_CE.GPIO_Typedef, &_spiEEPROM.SPI_CE.GPIO_InitStruct);
|
||||||
|
|
||||||
|
|
||||||
|
// Keypad I/O
|
||||||
|
// Row1
|
||||||
|
keypad->row[0].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->row[0].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
keypad->row[0].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
||||||
|
keypad->row[0].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->row[0].gpio.GPIO_Typedef, &keypad->row[0].gpio.GPIO_InitStruct);
|
||||||
|
|
||||||
|
// Row2
|
||||||
|
keypad->row[1].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->row[1].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
keypad->row[1].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
|
||||||
|
keypad->row[1].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->row[1].gpio.GPIO_Typedef, &keypad->row[1].gpio.GPIO_InitStruct);
|
||||||
|
// Row3
|
||||||
|
keypad->row[2].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->row[2].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
keypad->row[2].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
|
||||||
|
keypad->row[2].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->row[2].gpio.GPIO_Typedef, &keypad->row[2].gpio.GPIO_InitStruct);
|
||||||
|
// Row4
|
||||||
|
keypad->row[3].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->row[3].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
keypad->row[3].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
|
||||||
|
keypad->row[3].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->row[3].gpio.GPIO_Typedef, &keypad->row[3].gpio.GPIO_InitStruct);
|
||||||
|
|
||||||
|
// Column1
|
||||||
|
keypad->column[0].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->column[0].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
|
keypad->column[0].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
|
||||||
|
keypad->column[0].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->column[0].gpio.GPIO_Typedef, &keypad->column[0].gpio.GPIO_InitStruct);
|
||||||
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);
|
||||||
|
|
||||||
|
// Column2
|
||||||
|
keypad->column[1].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->column[1].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
|
keypad->column[1].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
|
||||||
|
keypad->column[1].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->column[1].gpio.GPIO_Typedef, &keypad->column[1].gpio.GPIO_InitStruct);
|
||||||
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource5);
|
||||||
|
|
||||||
|
// Column3
|
||||||
|
keypad->column[2].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->column[2].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
|
keypad->column[2].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
|
||||||
|
keypad->column[2].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->column[2].gpio.GPIO_Typedef, &keypad->column[2].gpio.GPIO_InitStruct);
|
||||||
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource6);
|
||||||
|
|
||||||
|
// Column4
|
||||||
|
keypad->column[3].gpio.GPIO_Typedef = GPIOD;
|
||||||
|
keypad->column[3].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
|
keypad->column[3].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
|
||||||
|
keypad->column[3].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(keypad->column[3].gpio.GPIO_Typedef, &keypad->column[3].gpio.GPIO_InitStruct);
|
||||||
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource7);
|
||||||
|
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
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)
|
ErrorStatus SPI_construct(struct Spi* self, struct SpiParameters* parameters)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
@@ -69,24 +69,24 @@ ErrorStatus SPI_construct(struct Spi* self, uint16_t SPI_Direction, uint16_t SPI
|
|||||||
|
|
||||||
SPI_I2S_DeInit(self->SPI_TypeDef);
|
SPI_I2S_DeInit(self->SPI_TypeDef);
|
||||||
|
|
||||||
self->SPI_InitStruct.SPI_Direction = SPI_Direction;
|
self->SPI_InitStruct.SPI_Direction = parameters->SPI_Direction;
|
||||||
self->SPI_InitStruct.SPI_Mode = SPI_Mode;
|
self->SPI_InitStruct.SPI_Mode = parameters->SPI_Mode;
|
||||||
self->SPI_InitStruct.SPI_DataSize = SPI_DataSize;
|
self->SPI_InitStruct.SPI_DataSize = parameters->SPI_DataSize;
|
||||||
self->SPI_InitStruct.SPI_CPOL = SPI_CPOL;
|
self->SPI_InitStruct.SPI_CPOL = parameters->SPI_CPOL;
|
||||||
self->SPI_InitStruct.SPI_CPHA = SPI_CPHA;
|
self->SPI_InitStruct.SPI_CPHA = parameters->SPI_CPHA;
|
||||||
self->SPI_InitStruct.SPI_NSS = SPI_NSS;
|
self->SPI_InitStruct.SPI_NSS = parameters->SPI_NSS;
|
||||||
self->SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler;
|
self->SPI_InitStruct.SPI_BaudRatePrescaler = parameters->SPI_BaudRatePrescaler;
|
||||||
self->SPI_InitStruct.SPI_FirstBit = SPI_FirstBit;
|
self->SPI_InitStruct.SPI_FirstBit = parameters->SPI_FirstBit;
|
||||||
self->SPI_InitStruct.SPI_CRCPolynomial = SPI_CRCPolynomial;
|
self->SPI_InitStruct.SPI_CRCPolynomial = parameters->SPI_CRCPolynomial;
|
||||||
SPI_Init(self->SPI_TypeDef, &self->SPI_InitStruct);
|
SPI_Init(self->SPI_TypeDef, &self->SPI_InitStruct);
|
||||||
|
|
||||||
//! Enable USART interface
|
//! Enable USART interface
|
||||||
SPI_Cmd(self->SPI_TypeDef, ENABLE);
|
SPI_Cmd(self->SPI_TypeDef, ENABLE);
|
||||||
|
|
||||||
//! Create a new FREERTOS queue to handle data from app to USART output
|
//! Create a new FREERTOS queue to handle data from app to USART output
|
||||||
self->txQueue = xQueueCreate(txQueueSize, sizeof(struct spiQueueItem));
|
self->txQueue = xQueueCreate(parameters->txQueueSize, sizeof(struct spiQueueItem));
|
||||||
//! Create a new FREERTOS queue to handle data from USART input to app
|
//! Create a new FREERTOS queue to handle data from USART input to app
|
||||||
self->rxQueue = xQueueCreate(rxQueueSize, sizeof(struct spiQueueItem));
|
self->rxQueue = xQueueCreate(parameters->rxQueueSize, sizeof(struct spiQueueItem));
|
||||||
//! Queue identifier must not be 0 (0 means that the queue is not available)
|
//! Queue identifier must not be 0 (0 means that the queue is not available)
|
||||||
if (self->txQueue == 0)
|
if (self->txQueue == 0)
|
||||||
{
|
{
|
||||||
@@ -126,9 +126,32 @@ ErrorStatus SPI_destruct (struct Spi* self)
|
|||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
self->initialized = false;
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus SPI_getDefaultParameters(struct SpiParameters* parameters)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
parameters->SPI_BaudRatePrescaler = SPI_DEF_BaudRatePrescaler;
|
||||||
|
parameters->SPI_CPHA = SPI_DEF_CPHA;
|
||||||
|
parameters->SPI_CPOL = SPI_DEF_CPOL;
|
||||||
|
parameters->SPI_CRCPolynomial = SPI_DEF_CRCPolynomial;
|
||||||
|
parameters->SPI_DataSize = SPI_DEF_DataSize;
|
||||||
|
parameters->SPI_Direction = SPI_DEF_Direction;
|
||||||
|
parameters->SPI_FirstBit = SPI_DEF_FirstBit;
|
||||||
|
parameters->SPI_Mode = SPI_DEF_Mode;
|
||||||
|
parameters->SPI_NSS = SPI_DEF_NSS;
|
||||||
|
parameters->rxQueueSize = SPI_DEF_RX_QUEUE;
|
||||||
|
parameters->txQueueSize = SPI_DEF_TX_QUEUE;
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ErrorStatus SPI_write (struct SpiDevice* self, const uint8_t* buffer, int length)
|
ErrorStatus SPI_write (struct SpiDevice* self, const uint8_t* buffer, int length)
|
||||||
{
|
{
|
||||||
struct spiQueueItem txItem;
|
struct spiQueueItem txItem;
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -54,53 +54,56 @@
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
static ErrorStatus write(struct IODevice* self, const char* buffer, size_t length);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function definitions
|
// Function definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
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)
|
ErrorStatus Uart_construct(struct Uart* self, struct UartParameters* parameters)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
IODevice_construct(&self->device, NULL, write);
|
||||||
|
|
||||||
//! Create semaphore to synchronize with USART interrupt handler
|
//! Create semaphore to synchronize with USART interrupt handler
|
||||||
vSemaphoreCreateBinary(_self->txSemaphore);
|
vSemaphoreCreateBinary(self->txSemaphore);
|
||||||
|
|
||||||
USART_DeInit(_self->USART_TypeDef);
|
USART_DeInit(self->USART_TypeDef);
|
||||||
|
|
||||||
_self->USART_ClockInitStruct->USART_Clock = USART_Clock_Enable;
|
self->USART_ClockInitStruct->USART_Clock = USART_Clock_Enable;
|
||||||
_self->USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge;
|
self->USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge;
|
||||||
_self->USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low;
|
self->USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low;
|
||||||
_self->USART_ClockInitStruct->USART_LastBit = USART_LastBit_Disable;
|
self->USART_ClockInitStruct->USART_LastBit = USART_LastBit_Disable;
|
||||||
|
|
||||||
//! Enable USART clock
|
//! Enable USART clock
|
||||||
USART_ClockInit(_self->USART_TypeDef, _self->USART_ClockInitStruct);
|
USART_ClockInit(self->USART_TypeDef, self->USART_ClockInitStruct);
|
||||||
|
|
||||||
// Initialise the UART
|
// Initialise the UART
|
||||||
_self->USART_InitStruct.USART_BaudRate = baudrate;
|
self->USART_InitStruct.USART_BaudRate = parameters->baudrate;
|
||||||
_self->USART_InitStruct.USART_WordLength = wordlength;
|
self->USART_InitStruct.USART_WordLength = parameters->wordlength;
|
||||||
_self->USART_InitStruct.USART_StopBits = stopbits;
|
self->USART_InitStruct.USART_StopBits = parameters->stopbits;
|
||||||
_self->USART_InitStruct.USART_Parity = parity;
|
self->USART_InitStruct.USART_Parity = parameters->parity;
|
||||||
_self->USART_InitStruct.USART_Mode = mode;
|
self->USART_InitStruct.USART_Mode = parameters->mode;
|
||||||
_self->USART_InitStruct.USART_HardwareFlowControl = hwFlowControl;
|
self->USART_InitStruct.USART_HardwareFlowControl = parameters->hwFlowControl;
|
||||||
|
|
||||||
USART_Init(_self->USART_TypeDef, &_self->USART_InitStruct);
|
USART_Init(self->USART_TypeDef, &self->USART_InitStruct);
|
||||||
|
|
||||||
//! Enable USART interface
|
//! Enable USART interface
|
||||||
USART_Cmd(_self->USART_TypeDef, ENABLE);
|
USART_Cmd(self->USART_TypeDef, ENABLE);
|
||||||
|
|
||||||
//! Create a new FREERTOS queue to handle data from app to USART output
|
//! Create a new FREERTOS queue to handle data from app to USART output
|
||||||
_self->txQueue = xQueueCreate(txQueueSize, sizeof(struct usartQueueItem));
|
self->txQueue = xQueueCreate(parameters->txQueueSize, sizeof(struct usartQueueItem));
|
||||||
//! Create a new FREERTOS queue to handle data from USART input to app
|
//! Create a new FREERTOS queue to handle data from USART input to app
|
||||||
_self->rxQueue = xQueueCreate(rxQueueSize, sizeof(struct usartQueueItem));
|
self->rxQueue = xQueueCreate(parameters->rxQueueSize, sizeof(struct usartQueueItem));
|
||||||
//! Queue identifier must not be 0 (0 means that the queue is not available)
|
//! Queue identifier must not be 0 (0 means that the queue is not available)
|
||||||
if (_self->txQueue == 0)
|
if (self->txQueue == 0)
|
||||||
{
|
{
|
||||||
//! Queue identifier is 0 -> error
|
//! Queue identifier is 0 -> error
|
||||||
returnValue = ERROR; //! Set error flag
|
returnValue = ERROR; //! Set error flag
|
||||||
}
|
}
|
||||||
if (_self->rxQueue == 0)
|
if (self->rxQueue == 0)
|
||||||
{
|
{
|
||||||
//! Queue identifier is 0 -> error
|
//! Queue identifier is 0 -> error
|
||||||
returnValue = ERROR; //! Set error flag
|
returnValue = ERROR; //! Set error flag
|
||||||
@@ -108,7 +111,7 @@ ErrorStatus Uart_Init(struct Uart* _self, uint32_t baudrate, uint16_t wordlength
|
|||||||
//! Queue identifier is not 0 -> queue is available
|
//! Queue identifier is not 0 -> queue is available
|
||||||
|
|
||||||
//! take txSemaphore
|
//! take txSemaphore
|
||||||
if (xSemaphoreTake(_self->txSemaphore, 0) == pdFALSE)
|
if (xSemaphoreTake(self->txSemaphore, 0) == pdFALSE)
|
||||||
{
|
{
|
||||||
//! An error has occurred
|
//! An error has occurred
|
||||||
returnValue = ERROR;
|
returnValue = ERROR;
|
||||||
@@ -117,14 +120,37 @@ ErrorStatus Uart_Init(struct Uart* _self, uint32_t baudrate, uint16_t wordlength
|
|||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
//! Enable the UART RX not empty interrupt
|
//! Enable the UART RX not empty interrupt
|
||||||
USART_ITConfig(_self->USART_TypeDef, USART_IT_RXNE, ENABLE);
|
USART_ITConfig(self->USART_TypeDef, USART_IT_RXNE, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ErrorStatus Uart_Write(struct Uart* _self, const uint8_t* buffer, int length)
|
ErrorStatus Uart_getDefaultParameters(struct UartParameters* parameters)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
parameters->baudrate = UART_DEF_BAUDRATE;
|
||||||
|
parameters->wordlength = UART_DEF_WORDLENGTH;
|
||||||
|
parameters->stopbits = UART_DEF_STOPBITS;
|
||||||
|
parameters->mode = UART_DEF_MODE;
|
||||||
|
parameters->parity = UART_DEF_PARITY;
|
||||||
|
parameters->hwFlowControl = UART_DEF_HW_FLOW_CONTROL;
|
||||||
|
parameters->txQueueSize = UART_DEF_TX_QUEUE;
|
||||||
|
parameters->rxQueueSize = UART_DEF_RX_QUEUE;
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ErrorStatus write(struct IODevice* self, const char* buffer, size_t length)
|
||||||
|
{
|
||||||
|
return Uart_Write((struct Uart*)self, buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus Uart_Write(struct Uart* self, const char* buffer, int length)
|
||||||
{
|
{
|
||||||
struct usartQueueItem usartTxItem;
|
struct usartQueueItem usartTxItem;
|
||||||
ErrorStatus returnValue = SUCCESS; //! Define return variable
|
ErrorStatus returnValue = SUCCESS; //! Define return variable
|
||||||
@@ -135,7 +161,7 @@ ErrorStatus Uart_Write(struct Uart* _self, const uint8_t* buffer, int length)
|
|||||||
{
|
{
|
||||||
usartTxItem.byte = buffer[txCounter]; //! Copy current data in struct
|
usartTxItem.byte = buffer[txCounter]; //! Copy current data in struct
|
||||||
//! Add the current set of data to bluetooth transmission queue
|
//! Add the current set of data to bluetooth transmission queue
|
||||||
if (pdTRUE != xQueueSend(_self->txQueue, &usartTxItem, 0))
|
if (pdTRUE != xQueueSend(self->txQueue, &usartTxItem, 0))
|
||||||
{
|
{
|
||||||
//! Adding item was NOT successful - break out of loop
|
//! Adding item was NOT successful - break out of loop
|
||||||
returnValue = ERROR; //! Set return value to FALSE
|
returnValue = ERROR; //! Set return value to FALSE
|
||||||
@@ -147,12 +173,12 @@ ErrorStatus Uart_Write(struct Uart* _self, const uint8_t* buffer, int length)
|
|||||||
{
|
{
|
||||||
//! Semaphore has been taken
|
//! Semaphore has been taken
|
||||||
//! Enable the USARTx TXE (transmission empty) interrupt
|
//! Enable the USARTx TXE (transmission empty) interrupt
|
||||||
USART_ITConfig(_self->USART_TypeDef, USART_IT_TXE, ENABLE);
|
USART_ITConfig(self->USART_TypeDef, USART_IT_TXE, ENABLE);
|
||||||
|
|
||||||
//! Try to take Semaphore - If the USART transmission is still busy, the
|
//! Try to take Semaphore - If the USART transmission is still busy, the
|
||||||
//! Semaphore cannot be taken - FREERTOS will suspend this task until the
|
//! Semaphore cannot be taken - FREERTOS will suspend this task until the
|
||||||
//! Semaphore is released again
|
//! Semaphore is released again
|
||||||
xSemaphoreTake(_self->txSemaphore, portMAX_DELAY);
|
xSemaphoreTake(self->txSemaphore, portMAX_DELAY);
|
||||||
|
|
||||||
/** Enabling the TX interrupt will immediately cause an interrupt because
|
/** Enabling the TX interrupt will immediately cause an interrupt because
|
||||||
* the transmission register is still empty. The ISR will get the data
|
* the transmission register is still empty. The ISR will get the data
|
||||||
@@ -161,7 +187,7 @@ ErrorStatus Uart_Write(struct Uart* _self, const uint8_t* buffer, int length)
|
|||||||
* An empty queue will cause the transmission complete flag (TC) to be set,
|
* An empty queue will cause the transmission complete flag (TC) to be set,
|
||||||
* which is polled
|
* which is polled
|
||||||
*/
|
*/
|
||||||
while (USART_GetFlagStatus(_self->USART_TypeDef, USART_FLAG_TC) == RESET)
|
while (USART_GetFlagStatus(self->USART_TypeDef, USART_FLAG_TC) == RESET)
|
||||||
{
|
{
|
||||||
//! The software must wait until TC=1. The TC flag remains cleared during
|
//! The software must wait until TC=1. The TC flag remains cleared during
|
||||||
//! all data transfers and it is set by hardware at the last frame's
|
//! all data transfers and it is set by hardware at the last frame's
|
||||||
@@ -19,7 +19,7 @@ system_stm32f10x.o \
|
|||||||
sysmem.o \
|
sysmem.o \
|
||||||
startup_stm32f10x_cl.o \
|
startup_stm32f10x_cl.o \
|
||||||
\
|
\
|
||||||
freeRTOSFixes.o \
|
FreeRTOSFixes.o \
|
||||||
Logger.o \
|
Logger.o \
|
||||||
\
|
\
|
||||||
heap_2.o\
|
heap_2.o\
|
||||||
@@ -81,7 +81,7 @@ OLI_STM32_H107: export CROSS_COMPILE := arm-none-eabi-
|
|||||||
OLI_STM32_H107: export CCFLAGS := -c -O2 -Wall -g -lc -lm -fno-common -mcpu=cortex-m3 -DOLI_STM32_H107 -DENABLE_SERIAL_LOGGING -mthumb $(RELEASE_DEFINES) $(INCLUDES)
|
OLI_STM32_H107: export CCFLAGS := -c -O2 -Wall -g -lc -lm -fno-common -mcpu=cortex-m3 -DOLI_STM32_H107 -DENABLE_SERIAL_LOGGING -mthumb $(RELEASE_DEFINES) $(INCLUDES)
|
||||||
OLI_STM32_H107: export ASFLAGS := -g -mapcs-32
|
OLI_STM32_H107: export ASFLAGS := -g -mapcs-32
|
||||||
OLI_STM32_H107: export LDFLAGS := -g -nostartfiles -mcpu=cortex-m3 -mthumb -T$(LINKER_SCRIPTS_DIR)/$(LINKER_SCRIPT) -Wl,-Map=hsb_mrts_OLI_STM32_H107.map
|
OLI_STM32_H107: export LDFLAGS := -g -nostartfiles -mcpu=cortex-m3 -mthumb -T$(LINKER_SCRIPTS_DIR)/$(LINKER_SCRIPT) -Wl,-Map=hsb_mrts_OLI_STM32_H107.map
|
||||||
OLI_STM32_H107: export LDARCHIVES := -L. -L$(STM32_STDPERIPH_ROOT) -L$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lDisplay -lMisc -lSTM_StdPeriph
|
OLI_STM32_H107: export LDARCHIVES := -L. -L$(STM32_STDPERIPH_ROOT) -L$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lKeypad -lDisplay -lMisc -lSTM_StdPeriph
|
||||||
OLI_STM32_H107: export ARFLAGS := ru
|
OLI_STM32_H107: export ARFLAGS := ru
|
||||||
OLI_STM32_H107: export OBJCOPYFLAGS := -O binary
|
OLI_STM32_H107: export OBJCOPYFLAGS := -O binary
|
||||||
OLI_STM32_H107: export OBJDUMPFLAGS := -x --syms -S
|
OLI_STM32_H107: export OBJDUMPFLAGS := -x --syms -S
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 8000000 )
|
#define configCPU_CLOCK_HZ ( ( unsigned long ) 8000000 )
|
||||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||||
#define configMAX_PRIORITIES ( 5 )
|
#define configMAX_PRIORITIES ( 5 )
|
||||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 512 )
|
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 )
|
||||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 30 * 1024 ) )
|
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0x8000 ) )
|
||||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||||
#define configUSE_TRACE_FACILITY 1
|
#define configUSE_TRACE_FACILITY 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
@@ -65,20 +65,21 @@
|
|||||||
/* Set the following definitions to 1 to include the API function, or zero
|
/* Set the following definitions to 1 to include the API function, or zero
|
||||||
to exclude the API function. */
|
to exclude the API function. */
|
||||||
|
|
||||||
#define INCLUDE_vTaskPrioritySet 1
|
#define INCLUDE_vTaskPrioritySet 1
|
||||||
#define INCLUDE_uxTaskPriorityGet 1
|
#define INCLUDE_uxTaskPriorityGet 1
|
||||||
#define INCLUDE_vTaskDelete 1
|
#define INCLUDE_vTaskDelete 1
|
||||||
#define INCLUDE_vTaskCleanUpResources 0
|
#define INCLUDE_vTaskCleanUpResources 0
|
||||||
#define INCLUDE_vTaskSuspend 1
|
#define INCLUDE_vTaskSuspend 1
|
||||||
#define INCLUDE_vTaskDelayUntil 1
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
#define INCLUDE_vTaskDelay 1
|
#define INCLUDE_vTaskDelay 1
|
||||||
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
|
||||||
|
|
||||||
/* Software timer related definitions. */
|
/* Software timer related definitions. */
|
||||||
#define configUSE_TIMERS 1
|
#define configUSE_TIMERS 1
|
||||||
#define configTIMER_TASK_PRIORITY (4)
|
#define configTIMER_TASK_PRIORITY (4)
|
||||||
#define configTIMER_QUEUE_LENGTH (10)
|
#define configTIMER_QUEUE_LENGTH (10)
|
||||||
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||||
|
|
||||||
/* Define to trap errors during development. */
|
/* Define to trap errors during development. */
|
||||||
#define configASSERT( x ) if( ( x ) == 0 ) for(;;)
|
#define configASSERT( x ) if( ( x ) == 0 ) for(;;)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: 167 $
|
/// $Revision$
|
||||||
/// $Author: mmi $
|
/// $Author$
|
||||||
/// $Date: 2017-09-12 13:09:10 +0200 (di, 12 sep 2017) $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -32,6 +32,9 @@
|
|||||||
|
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
#include "IODevice.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -83,20 +86,6 @@ typedef enum
|
|||||||
LOGTYPE_ERROR /**< Unrecoverable fault */
|
LOGTYPE_ERROR /**< Unrecoverable fault */
|
||||||
} LogType;
|
} LogType;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
FATALCODE_STACKOVERFLOW = 0x11,
|
|
||||||
FATALCODE_MALLOCFAILED = 0x12,
|
|
||||||
FATALCODE_USBCOMQUEUE = 0x13,
|
|
||||||
FATALCODE_LOGGERINITFAILED = 0x14,
|
|
||||||
FATALCODE_LOGGERQUEUEFAILED = 0x15,
|
|
||||||
FATALCODE_ADCOVERFLOW = 0x16,
|
|
||||||
FATALCODE_HIDQUEUETIMEOUT = 0x17,
|
|
||||||
FATALCODE_OUTPUTACTIONSQUEUETIMEOUT = 0x18,
|
|
||||||
FATALCODE_RNETQUEUEFAILED = 0x19,
|
|
||||||
FATALCODE_TEST2 = 0xFE,
|
|
||||||
FATALCODE_TEST = 0xFF
|
|
||||||
} FatalCode;
|
|
||||||
|
|
||||||
struct LogQueueItem
|
struct LogQueueItem
|
||||||
{
|
{
|
||||||
@@ -112,12 +101,12 @@ struct LogQueueItem
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
void Logger_initialize(void* const interface);
|
ErrorStatus Logger_construct(struct IODevice* const device);
|
||||||
void Logger_terminate(void);
|
void Logger_terminate(void);
|
||||||
|
|
||||||
void Logger_logISR(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
|
void Logger_logISR(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
|
||||||
void Logger_fatal(FatalCode code);
|
|
||||||
ErrorStatus Logger_addCommandHandlers(void);
|
ErrorStatus Logger_addCommandHandlers(void);
|
||||||
ErrorStatus Logger_logModuleInfo(void);
|
extern ErrorStatus Logger_logModuleInfo(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a string.
|
* Logs a string.
|
||||||
|
|||||||
@@ -54,5 +54,4 @@
|
|||||||
|
|
||||||
void OS_logTaskInfo(xTaskHandle taskHandle);
|
void OS_logTaskInfo(xTaskHandle taskHandle);
|
||||||
|
|
||||||
|
|
||||||
#endif /* FREERTOSFIXES_H_ */
|
#endif /* FREERTOSFIXES_H_ */
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
|
|
||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
|
|
||||||
|
|
||||||
extern void IRQ_setInterruptProperties(uint8_t irqChannel, uint8_t preemptionPriority, uint8_t subPriority, FunctionalState command);
|
extern void IRQ_setInterruptProperties(uint8_t irqChannel, uint8_t preemptionPriority, uint8_t subPriority, FunctionalState command);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: 167 $
|
/// $Revision$
|
||||||
/// $Author: mmi $
|
/// $Author$
|
||||||
/// $Date: 2017-09-12 13:09:10 +0200 (di, 12 sep 2017) $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#include <FreeRTOSFixes.h>
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
@@ -42,9 +43,9 @@
|
|||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define LOGQUEUE_SIZE (64)
|
#define LOGQUEUE_SIZE (16)
|
||||||
#define LOGGER_STACK_SIZE (512)
|
#define LOGGER_STACK_SIZE (512)
|
||||||
#define LOGGER_TASK_PRIORITY (1)
|
#define LOGGER_TASK_PRIORITY (2)
|
||||||
|
|
||||||
// Makefile compile options:
|
// Makefile compile options:
|
||||||
// ENABLE_SERIAL_LOGGING: Use the serial port for logging.
|
// ENABLE_SERIAL_LOGGING: Use the serial port for logging.
|
||||||
@@ -64,7 +65,7 @@
|
|||||||
// File-scope variables
|
// File-scope variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static struct Uart* loggerInterface;
|
static struct IODevice* loggerDevice;
|
||||||
|
|
||||||
static xQueueHandle logQueue;
|
static xQueueHandle logQueue;
|
||||||
|
|
||||||
@@ -90,34 +91,35 @@ static void loggerTask(void* parameters);
|
|||||||
* ---------------------*
|
* ---------------------*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Logger_initialize(void* const interface)
|
ErrorStatus Logger_construct(struct IODevice* const device)
|
||||||
{
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
if(!initialized)
|
if(!initialized)
|
||||||
{
|
{
|
||||||
ErrorStatus errorStatus = SUCCESS;
|
|
||||||
|
|
||||||
///TODO This is currently hardcoded into the UART - there must be a way for more generic usage
|
///TODO This is currently hardcoded into the UART - there must be a way for more generic usage
|
||||||
loggerInterface = (struct Uart* const) interface;
|
loggerDevice = device;
|
||||||
|
|
||||||
if(errorStatus == SUCCESS)
|
if(returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
logQueue = xQueueCreate(LOGQUEUE_SIZE, sizeof(struct LogQueueItem));
|
logQueue = xQueueCreate(LOGQUEUE_SIZE, sizeof(struct LogQueueItem));
|
||||||
|
|
||||||
if(logQueue == 0)
|
if(logQueue == 0)
|
||||||
{
|
{
|
||||||
errorStatus = ERROR;
|
returnValue = ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(errorStatus == SUCCESS)
|
if(returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
if(xTaskCreate(loggerTask, (const char*)"loggerTask", LOGGER_STACK_SIZE, NULL, LOGGER_TASK_PRIORITY, &loggerTaskHandle) != pdPASS)
|
if(xTaskCreate(loggerTask, (const char*)"loggerTask", LOGGER_STACK_SIZE, NULL, LOGGER_TASK_PRIORITY, &loggerTaskHandle) != pdPASS)
|
||||||
{
|
{
|
||||||
errorStatus = ERROR;
|
returnValue = ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(errorStatus == SUCCESS)
|
if(returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
initialized = true;
|
initialized = true;
|
||||||
LOGGER_INFO("Logger started");
|
LOGGER_INFO("Logger started");
|
||||||
@@ -127,6 +129,11 @@ void Logger_initialize(void* const interface)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger_terminate(void)
|
void Logger_terminate(void)
|
||||||
@@ -135,6 +142,15 @@ void Logger_terminate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus Logger_logModuleInfo(void)
|
||||||
|
{
|
||||||
|
ErrorStatus errorStatus = SUCCESS;
|
||||||
|
|
||||||
|
OS_logTaskInfo(loggerTaskHandle);
|
||||||
|
|
||||||
|
return errorStatus;
|
||||||
|
}
|
||||||
|
|
||||||
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
|
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
|
||||||
{
|
{
|
||||||
if(initialized)
|
if(initialized)
|
||||||
@@ -174,7 +190,7 @@ void Logger_log(const char* fileName, const char* functionName, int lineNumber,
|
|||||||
vsnprintf(str, sizeof(str) / sizeof(str[0]), format, ap);
|
vsnprintf(str, sizeof(str) / sizeof(str[0]), format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, logType, str);
|
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, str);
|
||||||
(void)xQueueSend(logQueue, &logQueueItem, 0);
|
(void)xQueueSend(logQueue, &logQueueItem, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -254,7 +270,7 @@ static void loggerTask(void* parameters)
|
|||||||
{
|
{
|
||||||
// Raw print
|
// Raw print
|
||||||
#if defined(ENABLE_SERIAL_LOGGING)
|
#if defined(ENABLE_SERIAL_LOGGING)
|
||||||
Uart_Write(loggerInterface, (const uint8_t*)logQueueItem.context, strlen(logQueueItem.context));
|
IODevice_write(loggerDevice, logQueueItem.context, strlen(logQueueItem.context));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -310,7 +326,7 @@ static void loggerTask(void* parameters)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_SERIAL_LOGGING)
|
#if defined(ENABLE_SERIAL_LOGGING)
|
||||||
Uart_Write(loggerInterface, (const uint8_t*)str, strlen(str));
|
IODevice_write(loggerDevice, str, strlen(str));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,13 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <FreeRTOSFixes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "freeRTOSFixes.h"
|
#include "Logger.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
@@ -65,12 +67,12 @@ void OS_logTaskInfo(xTaskHandle taskHandle)
|
|||||||
unsigned portBASE_TYPE highWaterMark;
|
unsigned portBASE_TYPE highWaterMark;
|
||||||
char text[128];
|
char text[128];
|
||||||
|
|
||||||
snprintf(text, sizeof(text), "Task %s\n", pcTaskGetTaskName(taskHandle));
|
snprintf(text, sizeof(text), "***** Task %s", pcTaskGetTaskName(taskHandle));
|
||||||
// Shell_sendString(text);
|
LOGGER_INFO(text);
|
||||||
|
|
||||||
highWaterMark = uxTaskGetStackHighWaterMark(taskHandle);
|
highWaterMark = uxTaskGetStackHighWaterMark(taskHandle);
|
||||||
snprintf(text, sizeof(text), "Stack high water mark : %lu long words\n", highWaterMark);
|
snprintf(text, sizeof(text), "***** Stack high water mark : %lu long words", highWaterMark);
|
||||||
// Shell_sendString(text);
|
LOGGER_INFO(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation for libc, needed for printf related functions.
|
// Implementation for libc, needed for printf related functions.
|
||||||
@@ -93,7 +95,8 @@ caddr_t _sbrk(int incr)
|
|||||||
// Stack overflow hook
|
// Stack overflow hook
|
||||||
void vApplicationStackOverflowHook(xTaskHandle xTask, signed portCHAR* pcTaskName)
|
void vApplicationStackOverflowHook(xTaskHandle xTask, signed portCHAR* pcTaskName)
|
||||||
{
|
{
|
||||||
// Logger_fatal(FATALCODE_STACKOVERFLOW);
|
LED_turnOn(ledGreen);
|
||||||
|
LOGGER_ERROR("STACK OVERFLOW IN TASK %s", pcTaskName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Malloc failed hook
|
// Malloc failed hook
|
||||||
|
|||||||
@@ -25,16 +25,19 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <FreeRTOSFixes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
// FreeRTOS includes
|
// FreeRTOS includes
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "freeRTOSFixes.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "stm32f10x_rcc.h"
|
#include "stm32f10x_rcc.h"
|
||||||
|
|
||||||
#include "nhd0420.h"
|
#include "nhd0420.h"
|
||||||
|
#include "keypadMatrix.h"
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
@@ -69,11 +72,13 @@ unsigned long ulRunTimeStatsClock = 0UL;
|
|||||||
static struct LedTaskArguments ledTaskArguments;
|
static struct LedTaskArguments ledTaskArguments;
|
||||||
static xTaskHandle initTaskHandle;
|
static xTaskHandle initTaskHandle;
|
||||||
static xTaskHandle ledTaskHandle;
|
static xTaskHandle ledTaskHandle;
|
||||||
|
static xTaskHandle sysTaskHandle;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static ErrorStatus systeminfoCommandHandler(void);
|
||||||
static void initTask(void* parameters);
|
static void initTask(void* parameters);
|
||||||
static void ledBlinkTask(void* parameters);
|
static void ledBlinkTask(void* parameters);
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -91,10 +96,7 @@ int main (void)
|
|||||||
ledTaskArguments.led = ledOrange;
|
ledTaskArguments.led = ledOrange;
|
||||||
ledTaskArguments.frequency = 2;
|
ledTaskArguments.frequency = 2;
|
||||||
|
|
||||||
xTaskCreate(initTask, (const char* const)"initTask", 1024, NULL, 0, &initTaskHandle);
|
xTaskCreate(initTask, (const char* const)"initTask", 1024, NULL, 5, &initTaskHandle);
|
||||||
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 1024, &ledTaskArguments, 0, &ledTaskHandle);
|
|
||||||
|
|
||||||
LOGGER_INFO("Starting the scheduler");
|
|
||||||
|
|
||||||
/* Start the scheduler. */
|
/* Start the scheduler. */
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
@@ -113,11 +115,44 @@ void vApplicationTickHook ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void printSystemInfoTask(void* parameters)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
systeminfoCommandHandler();
|
||||||
|
vTaskDelay(60000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ErrorStatus systeminfoCommandHandler(void)
|
||||||
|
{
|
||||||
|
ErrorStatus errorStatus = SUCCESS;
|
||||||
|
size_t freeMemory;
|
||||||
|
char text[128];
|
||||||
|
|
||||||
|
freeMemory = xPortGetFreeHeapSize();
|
||||||
|
snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory);
|
||||||
|
LOGGER_INFO(text);
|
||||||
|
|
||||||
|
errorStatus &= Logger_logModuleInfo();
|
||||||
|
vTaskDelay(100);
|
||||||
|
errorStatus &= Keypad_logModuleInfo();
|
||||||
|
vTaskDelay(100);
|
||||||
|
OS_logTaskInfo(ledTaskHandle);
|
||||||
|
vTaskDelay(100);
|
||||||
|
OS_logTaskInfo(sysTaskHandle);
|
||||||
|
|
||||||
|
return errorStatus;
|
||||||
|
}
|
||||||
|
|
||||||
static void initTask(void* parameters)
|
static void initTask(void* parameters)
|
||||||
{
|
{
|
||||||
initPlatform();
|
initPlatform();
|
||||||
|
|
||||||
Logger_initialize(uart1);
|
Logger_construct(&uart1->device);
|
||||||
|
|
||||||
|
Keypad_construct();
|
||||||
|
|
||||||
NHD0420_construct(spiDisplay);
|
NHD0420_construct(spiDisplay);
|
||||||
|
|
||||||
@@ -133,10 +168,13 @@ static void initTask(void* parameters)
|
|||||||
vTaskDelay(1000);
|
vTaskDelay(1000);
|
||||||
NHD0420_setCursorToHome();
|
NHD0420_setCursorToHome();
|
||||||
vTaskDelay(1000);
|
vTaskDelay(1000);
|
||||||
NHD0420_sendData("Hallo Welt", 10);
|
|
||||||
vTaskDelay(1);
|
|
||||||
NHD0420_setCursorToPosition(4, 5);
|
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 40, &ledTaskArguments, 0, &ledTaskHandle);
|
||||||
NHD0420_sendData("Koetjeboe", 9);
|
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 1, &sysTaskHandle);
|
||||||
|
|
||||||
|
// Delete this init task
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
// Email: support@microkey.nl
|
// Email: support@microkey.nl
|
||||||
// Web: www.microkey.nl
|
// Web: www.microkey.nl
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/// $Revision: $
|
/// $Revision$
|
||||||
/// $Author: $
|
/// $Author$
|
||||||
/// $Date: $
|
/// $Date$
|
||||||
// (c) 2017 Micro-Key bv
|
// (c) 2017 Micro-Key bv
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -31,6 +31,9 @@
|
|||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
|
|
||||||
#include "stm32f10x_it.h"
|
#include "stm32f10x_it.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#include "stm32f10x_exti.h"
|
||||||
|
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
@@ -264,3 +267,48 @@ void SPI3_IRQHandler (void)
|
|||||||
|
|
||||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EXTI4_IRQHandler(void)
|
||||||
|
{
|
||||||
|
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
LOGGER_INFO_ISR("EXT4 ISR");
|
||||||
|
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line4);
|
||||||
|
|
||||||
|
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXTI9_5_IRQHandler (void)
|
||||||
|
{
|
||||||
|
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
if (EXTI_GetITStatus(EXTI_Line5) != RESET)
|
||||||
|
{
|
||||||
|
LOGGER_INFO_ISR("EXT5 ISR");
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line5);
|
||||||
|
}
|
||||||
|
else if (EXTI_GetITStatus(EXTI_Line6) != RESET)
|
||||||
|
{
|
||||||
|
LOGGER_INFO_ISR("EXT6 ISR");
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line6);
|
||||||
|
}
|
||||||
|
else if (EXTI_GetITStatus(EXTI_Line7) != RESET)
|
||||||
|
{
|
||||||
|
LOGGER_INFO_ISR("EXT7 ISR");
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line7);
|
||||||
|
}
|
||||||
|
else if (EXTI_GetITStatus(EXTI_Line8) != RESET)
|
||||||
|
{
|
||||||
|
LOGGER_INFO_ISR("EXT8 ISR");
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line8);
|
||||||
|
}
|
||||||
|
else if (EXTI_GetITStatus(EXTI_Line9) != RESET)
|
||||||
|
{
|
||||||
|
LOGGER_INFO_ISR("EXT9 ISR");
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line9);
|
||||||
|
}
|
||||||
|
|
||||||
|
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user