checked in missing file

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@240 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-06 09:04:50 +00:00
parent 5105d55089
commit 71ae4c6832
8 changed files with 382 additions and 24 deletions

View File

@@ -186,9 +186,11 @@ ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value)
{ {
ErrorStatus returnValue = SUCCESS; ErrorStatus returnValue = SUCCESS;
// Send data // Send data to CODEn register
MAX5715_writeCODEn(self->parent, MAX5715_SEL_DACB, value);
// Send GO // Load CODEn register to DAC output
MAX5715_writeLOADn(self->parent, MAX5715_SEL_DACB);
return returnValue; return returnValue;
} }

View File

@@ -81,4 +81,20 @@ struct Pcba
*/ */
extern struct Pcba* PCBA_getInstance(void); extern struct Pcba* PCBA_getInstance(void);
/** ----------------------------------------------------------------------------
* PCBA_setIO
* Sets the IO used for PCBA detection
*
* @param A0 Input 0
* @param A1 Input 1
*
* @return ErrorStatus SUCCESS if setting was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus PCBA_setIO(T_PL_GPIO* A0, T_PL_GPIO* A1);
#endif /* PCBA_H_ */ #endif /* PCBA_H_ */

View File

@@ -81,6 +81,25 @@ struct Pcba* PCBA_getInstance(void)
return instance; return instance;
} }
ErrorStatus PCBA_setIO(T_PL_GPIO* A0, T_PL_GPIO* A1)
{
ErrorStatus returnValue = SUCCESS;
if ((A0 != NULL) && (A1 != NULL))
{
thisPCBA.A0 = *A0;
thisPCBA.A1 = *A1;
}
else
{
returnValue = ERROR;
}
return returnValue;
}
static ErrorStatus PCBA_construct(struct Pcba* self) static ErrorStatus PCBA_construct(struct Pcba* self)
{ {
ErrorStatus returnValue = SUCCESS; ErrorStatus returnValue = SUCCESS;

View File

@@ -430,20 +430,21 @@ static ErrorStatus initIO (void)
/*PCBA IO initialisation -------------------------------------------------*/ /*PCBA IO initialisation -------------------------------------------------*/
// A0 // A0
gpio.GPIO_Typedef = GPIOC; T_PL_GPIO A0;
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD; A0.GPIO_Typedef = GPIOC;
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0; A0.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz; A0.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct); A0.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
PCBA_getInstance()->A0 = gpio; GPIO_Init(A0.GPIO_Typedef, &A0.GPIO_InitStruct);
// A1 // A1
gpio.GPIO_Typedef = GPIOC; T_PL_GPIO A1;
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD; A1.GPIO_Typedef = GPIOC;
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1; A1.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz; A1.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct); A1.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
PCBA_getInstance()->A1 = gpio; GPIO_Init(A1.GPIO_Typedef, &A1.GPIO_InitStruct);
PCBA_setIO(&A0, &A1);
/*LED IO initialisation --------------------------------------------------*/ /*LED IO initialisation --------------------------------------------------*/
@@ -504,17 +505,20 @@ static ErrorStatus initIO (void)
/* USART3 initialisation -------------------------------------------------*/ /* USART3 initialisation -------------------------------------------------*/
// Init TX line // Init TX line
uart3->USART_TX.GPIO_Typedef = GPIOB; gpio.GPIO_Typedef = GPIOB;
uart3->USART_TX.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
uart3->USART_TX.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10; gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10;
uart3->USART_TX.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(uart3->USART_TX.GPIO_Typedef, &uart3->USART_TX.GPIO_InitStruct); uart1->USART_TX = gpio;
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
// Init RX line // Init RX line
uart3->USART_RX.GPIO_Typedef = GPIOB; gpio.GPIO_Typedef = GPIOB;
uart3->USART_RX.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING; gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
uart3->USART_RX.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11; gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
uart3->USART_RX.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; uart1->USART_RX = gpio;
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
GPIO_Init(uart3->USART_RX.GPIO_Typedef, &uart3->USART_RX.GPIO_InitStruct); GPIO_Init(uart3->USART_RX.GPIO_Typedef, &uart3->USART_RX.GPIO_InitStruct);

View File

@@ -0,0 +1,63 @@
// -----------------------------------------------------------------------------
/// @file repairPreset.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 repairPreset.h
/// @ingroup {group_name}
#ifndef REPAIRPRESET_H_
#define REPAIRPRESET_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define REPAIR_PRESET_MAX_STAGES (2)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct RepairPresetParameters
{
int voltage;
int duration;
int softstartDuration;
};
struct RepairPreset
{
size_t numberOfStages;
struct RepairPresetParameters preset[REPAIR_PRESET_MAX_STAGES];
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
#endif /* REPAIRPRESET_H_ */

View File

@@ -0,0 +1,122 @@
// -----------------------------------------------------------------------------
/// @file repairProcess.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 repairProcess.h
/// @ingroup {group_name}
#ifndef REPAIRPROCESS_H_
#define REPAIRPROCESS_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "stm32f10x.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
typedef enum
{
IDLE = 0,
SOFTSTART = 1,
VOLTAGE_HOLD = 2,
PAUSE = 3
} RepairState;
struct RepairProcess
{
TaskHandle_t taskHandle;
int TaskPriority;
uint16_t stackSize;
bool runTask;
SemaphoreHandle_t secondsSyncronisation;
uint32_t secondsCounter;
RepairState currentState;
bool initialized;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* repairProcess_construct
* Description of function
*
* @param self The process object
* @param taskPriority Task priority for the repair process
* @param stackSize Stacksize of the task
*
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus repairProcess_construct(struct RepairProcess* self, int taskPriority, uint16_t stackSize);
/** ----------------------------------------------------------------------------
* repairProcess_feedSecondsCounter
* Feeds the seconds counter of the repair process.
* The process is designed to be run every second, so this feed function should
* be called every second.
*
* @param self The repair process
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void repairProcess_feedSecondsCounter(struct RepairProcess* self);
/** ----------------------------------------------------------------------------
* repairProcess_feedSecondsCounterFromISR
* Feeds the seconds counter of the repair process.
* This function should be called in an ISR context
* The process is designed to be run every second, so this feed function should
* be called every second.
*
* @param self The repair process
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void repairProcess_feedSecondsCounterFromISR(struct RepairProcess* self);
#endif /* REPAIRPROCESS_H_ */

View File

@@ -221,13 +221,15 @@ static void initTask(void* parameters)
hwTestItems.cat2Relay = NULL; hwTestItems.cat2Relay = NULL;
hwTestItems.pcba = pcba; hwTestItems.pcba = pcba;
// EEPROM TO BE DONE // EEPROM TO BE DONE
HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 2, 1024); // HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 2, 1024);
MAX5715_construct(&max5715, &spiDAC->device); MAX5715_construct(&max5715, &spiDAC->device);
MAX5715_writeREF_ON_2V5(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC); MAX5715_writeREF_ON_2V5(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
MAX5715Channel_construct(&max5715.dac[0], &max5715, 0);
repairProcess_construct(rp, 3, 1024); repairProcess_construct(rp, 3, 1024);

View File

@@ -0,0 +1,130 @@
// -----------------------------------------------------------------------------
/// @file repairProcess.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 repairProcess.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "FreeRTOS.h"
#include "queue.h"
#include "semphr.h"
#include "task.h"
#include "repairProcess.h"
#include "repairPreset.h"
#include "Logger.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
static void repairProcess_task(void* parameters);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus repairProcess_construct(struct RepairProcess* self, int taskPriority, uint16_t stackSize)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
// Create a semaphore to sync access to the display shadow
vSemaphoreCreateBinary(self->secondsSyncronisation);
xSemaphoreGive(self->secondsSyncronisation);
if (xTaskCreate(repairProcess_task, "RepairProcess", stackSize, self, taskPriority, &self->taskHandle) != pdTRUE)
{
returnValue = ERROR;
}
if (returnValue == SUCCESS)
{
self->runTask = true;
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
void repairProcess_feedSecondsCounter(struct RepairProcess* self)
{
xSemaphoreGive(self->secondsSyncronisation);
}
void repairProcess_feedSecondsCounterFromISR(struct RepairProcess* self)
{
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(self->secondsSyncronisation, &higherPriorityTaskWoken);
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
static void repairProcess_task(void* parameters)
{
struct RepairProcess* self = (struct RepairProcess*)parameters;
while(self->runTask)
{
xSemaphoreTake(self->secondsSyncronisation, portMAX_DELAY);
int hours = (self->secondsCounter / (60 * 60));
int minutes = (self->secondsCounter - (hours * 60 * 60)) / 60;
int seconds = (self->secondsCounter - (hours * 60 * 60) - (minutes * 60));
LOGGER_WARNING(mainLog, "--- Repair clock %02i %02d %02d", hours, minutes, seconds);
self->secondsCounter++;
}
vTaskDelete(self->taskHandle);
}