minor code cleanup

pull/102/head
RobertGawron 2019-08-04 10:26:16 +01:00
rodzic afb2e745d9
commit ff48a187f3
5 zmienionych plików z 12 dodań i 25 usunięć

Wyświetl plik

@ -10,16 +10,11 @@
#include "CommonDataTypes.h" #include "CommonDataTypes.h"
#define VoltageSensorActualValue_MeasurementData_t uint8_t typedef uint8_t VoltageSensorActualValue_MeasurementData_t;
typedef struct MCP3425A0TConfig_t {
int i2cAddress;
} MCP3425A0TConfig_t;
void VoltageSensorActualValue_Init(); void VoltageSensorActualValue_Init();
bool VoltageSensorActualValue_GetMeasurementData(VoltageSensorActualValue_MeasurementData_t *measurementData); bool VoltageSensorActualValue_MeasureValue(VoltageSensorActualValue_MeasurementData_t *measurementData);
#endif /* SRC_VOLTAGESENSORACTUALVALUE_H_ */ #endif /* SRC_VOLTAGESENSORACTUALVALUE_H_ */

Wyświetl plik

@ -20,7 +20,6 @@ void ApplicationBuilder_Init()
{ {
ClockConfigurator_Init(); ClockConfigurator_Init();
TimerConfigurator_Init(); TimerConfigurator_Init();
Logger_Init(); Logger_Init();
PulseCounter_Init(); PulseCounter_Init();
UserInterface_Init(); UserInterface_Init();
@ -29,7 +28,7 @@ void ApplicationBuilder_Init()
enableInterrupts(); enableInterrupts();
// UserInterface_ShowMessage(USER_INTERFAE_STATE_OK_MSG); UserInterface_ShowMessage(USER_INTERFAE_STATE_OK_MSG);
} }

Wyświetl plik

@ -6,17 +6,17 @@
*/ */
#include "Logger.h" #include "Logger.h"
#include "stm8s_uart1.h"
#include "PinoutConfiguration.h"
//#define USE_PRINTF //#define USE_PRINTF
#if defined USE_PRINTF #if defined USE_PRINTF
#include <stdio.h> #include <stdio.h>
#endif #endif
#include "stm8s_uart1.h"
#include "PinoutConfiguration.h"
#define UART_SPEED 9600 #define UART_SPEED 9600
static void GPIO_setup(void); static void GPIO_setup(void);
static void UART1_setup(void); static void UART1_setup(void);
@ -64,17 +64,13 @@ void assert_failed(uint8_t* file, uint32_t line)
printf("[error] asset failed %s %d\r\n", file, line); printf("[error] asset failed %s %d\r\n", file, line);
#endif #endif
while(TRUE) while(TRUE);
{
// empty
}
} }
#endif #endif
void GPIO_setup(void) void GPIO_setup(void)
{ {
GPIO_DeInit(PORT_UART); GPIO_DeInit(PORT_UART);

Wyświetl plik

@ -18,7 +18,7 @@ void MeasurementCollector_Init()
void MeasurementCollector_Tick() void MeasurementCollector_Tick()
{ {
VoltageSensorActualValue_MeasurementData_t sample; VoltageSensorActualValue_MeasurementData_t sample;
VoltageSensorActualValue_GetMeasurementData(&sample); VoltageSensorActualValue_MeasureValue(&sample);
Logger_Print(sample); Logger_Print(sample);
} }

Wyświetl plik

@ -9,11 +9,10 @@
#include "PinoutConfiguration.h" #include "PinoutConfiguration.h"
#include "UserInterface.h" #include "UserInterface.h"
#include "stm8s_i2c.h" #include "stm8s_i2c.h"
//#include <stdio.h>
#include "Logger.h" #include "Logger.h"
#define I2C_OWN_ADDRESS 0x10 #define I2C_MASTER_ADDRESS 0x10
// MCP3425 I2C address is 0x68(104), this 7 bits, they need to be // MCP3425 I2C address is 0x68(104), this 7 bits, they need to be
// shifted by one, to make 8 bits variable, where less signifant bit // shifted by one, to make 8 bits variable, where less signifant bit
// is used to signalize communication direction (rx or tx) // is used to signalize communication direction (rx or tx)
@ -30,17 +29,15 @@ void VoltageSensorActualValue_Init()
GPIO_setup(); GPIO_setup();
I2C_setup(); I2C_setup();
// seleect adc configuration and start measurement // select adc configuration and start measurement
write(0x00); write(0x00);
} }
bool VoltageSensorActualValue_GetMeasurementData(VoltageSensorActualValue_MeasurementData_t *measurementData) bool VoltageSensorActualValue_MeasureValue(VoltageSensorActualValue_MeasurementData_t *measurementData)
{ {
write(0x10); write(0x10);
*measurementData = read(0); *measurementData = read(0);
// read(0);
// getRegisterValue should return false on timeout and this should be later propagated to GUI component. // getRegisterValue should return false on timeout and this should be later propagated to GUI component.
return TRUE; return TRUE;
@ -58,7 +55,7 @@ void I2C_setup(void)
{ {
I2C_DeInit(); I2C_DeInit();
I2C_Init(100000, I2C_Init(100000,
I2C_OWN_ADDRESS, I2C_MASTER_ADDRESS,
I2C_DUTYCYCLE_2, I2C_DUTYCYCLE_2,
I2C_ACK_CURR, I2C_ACK_CURR,
I2C_ADDMODE_7BIT, I2C_ADDMODE_7BIT,