Added PCBA information to project
tested - functional git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@227 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -26,6 +26,7 @@ OBJECTS = \
|
||||
stm32f10x_it.o \
|
||||
adc.o \
|
||||
led.o \
|
||||
PCBA.o \
|
||||
rtc.o \
|
||||
spi.o \
|
||||
spiDevice.o \
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file PCBA.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file PCBA.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef PCBA_H_
|
||||
#define PCBA_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CathodeMCP = 0,
|
||||
Tesla = 1,
|
||||
Anode = 2,
|
||||
ND = 3
|
||||
}PCBA_t;
|
||||
|
||||
struct Pcba
|
||||
{
|
||||
PCBA_t pcba;
|
||||
char name[20];
|
||||
T_PL_GPIO A0;
|
||||
T_PL_GPIO A1;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* PCBA_construct
|
||||
* Initializes the PCBA information of the hardware.
|
||||
* PCBA information is defined via placed resistors
|
||||
* This function can only be called once. Within the first call an internal flag
|
||||
* is set to prevent any further calling. That is because the PCBA information
|
||||
* cannot change during run-time
|
||||
*
|
||||
* @param self The PCBA information
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if construction was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus PCBA_construct(struct Pcba* self);
|
||||
|
||||
#endif /* PCBA_H_ */
|
||||
@@ -60,6 +60,8 @@ typedef struct
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
} T_PL_GPIO;
|
||||
|
||||
// Export of PCBA information
|
||||
extern struct Pcba* const pcba;
|
||||
|
||||
// Export of LEDs
|
||||
extern struct Led* const ledGreen;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file PCBA.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 PCBA.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "PCBA.h"
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static bool initialized = false;
|
||||
static const char nameArray[4][20] =
|
||||
{
|
||||
"Cathode/MCP repair ",
|
||||
"Tesla repair ",
|
||||
"Anode repair ",
|
||||
"UNDEFINED PCBA ",
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus PCBA_construct(struct Pcba* self)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
|
||||
uint8_t A0 = GPIO_ReadInputDataBit(self->A0.GPIO_Typedef, self->A0.GPIO_InitStruct.GPIO_Pin);
|
||||
uint8_t A1 = GPIO_ReadInputDataBit(self->A1.GPIO_Typedef, self->A1.GPIO_InitStruct.GPIO_Pin);
|
||||
|
||||
self->pcba = (A0 & 0x01) | ((A1 << 1) & 0x02);
|
||||
snprintf(self->name, (sizeof(self->name) / sizeof(self->name[0])), "%s", nameArray[self->pcba]);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -33,10 +33,11 @@
|
||||
#include "stm32f10x_it.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "spiDevice.h"
|
||||
#include "led.h"
|
||||
#include "PCBA.h"
|
||||
#include "rtc.h"
|
||||
#include "spi.h"
|
||||
#include "spiDevice.h"
|
||||
#include "uart.h"
|
||||
#include "keypadMatrix.h"
|
||||
#include "nhd0420.h"
|
||||
@@ -76,6 +77,9 @@
|
||||
// The following static file-scope variables represent the actual storage of
|
||||
// the IO/Peripheral object
|
||||
|
||||
// PCBA information
|
||||
static struct Pcba _pcba;
|
||||
|
||||
// LEDs
|
||||
static struct Led _ledGreen;
|
||||
static struct Led _ledOrange;
|
||||
@@ -105,6 +109,8 @@ static struct KeypadParameters _keypadParameters;
|
||||
|
||||
// The following pointers are for export (see platform.h) and external use.
|
||||
// Note that the pointer content is marked "const"
|
||||
struct Pcba* const pcba = &_pcba;
|
||||
|
||||
struct Led* const ledGreen = &_ledGreen;
|
||||
struct Led* const ledOrange = &_ledOrange;
|
||||
|
||||
@@ -160,6 +166,11 @@ ErrorStatus initPlatform(void)
|
||||
// INITIALIZE AND CONFIGURE ALL REQUIRED IO AND PERIPHERY
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* PCBA */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// PCBA_construct(pcba);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* LEDs */
|
||||
/* --------------------------------------------------------------------*/
|
||||
@@ -326,6 +337,22 @@ static ErrorStatus initIO (void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
/*PCBA IO initialisation -------------------------------------------------*/
|
||||
// A0
|
||||
pcba->A0.GPIO_Typedef = GPIOC;
|
||||
pcba->A0.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
|
||||
pcba->A0.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
||||
pcba->A0.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
|
||||
GPIO_Init(pcba->A0.GPIO_Typedef, &pcba->A0.GPIO_InitStruct);
|
||||
// A1
|
||||
pcba->A1.GPIO_Typedef = GPIOC;
|
||||
pcba->A1.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
|
||||
pcba->A1.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
|
||||
pcba->A1.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
|
||||
GPIO_Init(pcba->A1.GPIO_Typedef, &pcba->A1.GPIO_InitStruct);
|
||||
|
||||
|
||||
|
||||
/*LED IO initialisation --------------------------------------------------*/
|
||||
// Init LED Green
|
||||
ledGreen->ledGpio.GPIO_Typedef = GPIOC;
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Display.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file Display.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef DISPLAY_H_
|
||||
#define DISPLAY_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct Display
|
||||
{
|
||||
void* displayDriver; // USE WITH CAUTION - VOID POINTER
|
||||
TaskHandle_t taskHandle;
|
||||
int TaskPriority;
|
||||
bool runTask;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Display_construct
|
||||
* Constructor for a display application
|
||||
*
|
||||
* @param self The display object to initialize
|
||||
* @param displayDriver The specific display driver that the
|
||||
* application will use
|
||||
* This is a constant and will not be matter
|
||||
* to changes after initialisation. Only
|
||||
* via destruct and a new construct
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was OK
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Display_construct(struct Display* self, void* displayDriver);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Display_destruct
|
||||
* Destructor for a display application
|
||||
*
|
||||
* @param self The display object to destruct
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void Display_destruct(struct Display* self);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Display_clearScreen
|
||||
* Clear the complete display
|
||||
*
|
||||
* @param self The display information to use
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if clearing display was OK
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Display_clearScreen(struct Display* self);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Display_write
|
||||
* Description of function
|
||||
*
|
||||
* @param self The display information to use
|
||||
* @param buffer The message to write
|
||||
* @param length Length of the message
|
||||
* @param row The row of the display to put the message
|
||||
* Starts with 1
|
||||
* @param column The column to start at with the message
|
||||
* Starts with 1
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if putting message to display was
|
||||
* successful
|
||||
* ERROR otherwise, especially
|
||||
* - Message too long
|
||||
* - Row/Column outside display boundaries
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Display_write(struct Display* self, const char* buffer, unsigned int length, unsigned int row, unsigned int column);
|
||||
|
||||
#endif /* DISPLAY_H_ */
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "platform.h"
|
||||
#include "IODevice.h"
|
||||
#include "led.h"
|
||||
#include "PCBA.h"
|
||||
#include "uart.h"
|
||||
#include "spi.h"
|
||||
#include "spiDevice.h"
|
||||
@@ -161,12 +162,12 @@ static void initTask(void* parameters)
|
||||
|
||||
Logger_construct(&uart1->device);
|
||||
|
||||
// NHD0420_construct(&nhd0420, &uart1->device);
|
||||
NHD0420_construct(&nhd0420, &spiDisplay->device);
|
||||
|
||||
Display_construct(&display, &nhd0420);
|
||||
PCBA_construct(pcba);
|
||||
|
||||
Display_write(&display, "anode repair", 12, 1, 1);
|
||||
Display_write(&display, pcba->name, sizeof(pcba->name) / sizeof(pcba->name[0]), 1, 1);
|
||||
Display_write(&display, "A", 1, 1, 20);
|
||||
Display_write(&display, "SW V. 1.0.0.0", 13, 3, 4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user