kopia lustrzana https://github.com/RobertGawron/IonizationChamber
minor code cleanup
rodzic
afb2e745d9
commit
ff48a187f3
|
@ -10,16 +10,11 @@
|
|||
|
||||
#include "CommonDataTypes.h"
|
||||
|
||||
#define VoltageSensorActualValue_MeasurementData_t uint8_t
|
||||
|
||||
typedef struct MCP3425A0TConfig_t {
|
||||
int i2cAddress;
|
||||
} MCP3425A0TConfig_t;
|
||||
|
||||
typedef uint8_t VoltageSensorActualValue_MeasurementData_t;
|
||||
|
||||
void VoltageSensorActualValue_Init();
|
||||
|
||||
bool VoltageSensorActualValue_GetMeasurementData(VoltageSensorActualValue_MeasurementData_t *measurementData);
|
||||
bool VoltageSensorActualValue_MeasureValue(VoltageSensorActualValue_MeasurementData_t *measurementData);
|
||||
|
||||
|
||||
#endif /* SRC_VOLTAGESENSORACTUALVALUE_H_ */
|
||||
|
|
|
@ -20,7 +20,6 @@ void ApplicationBuilder_Init()
|
|||
{
|
||||
ClockConfigurator_Init();
|
||||
TimerConfigurator_Init();
|
||||
|
||||
Logger_Init();
|
||||
PulseCounter_Init();
|
||||
UserInterface_Init();
|
||||
|
@ -29,7 +28,7 @@ void ApplicationBuilder_Init()
|
|||
|
||||
enableInterrupts();
|
||||
|
||||
// UserInterface_ShowMessage(USER_INTERFAE_STATE_OK_MSG);
|
||||
UserInterface_ShowMessage(USER_INTERFAE_STATE_OK_MSG);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
|
||||
#include "Logger.h"
|
||||
#include "stm8s_uart1.h"
|
||||
#include "PinoutConfiguration.h"
|
||||
|
||||
//#define USE_PRINTF
|
||||
#if defined USE_PRINTF
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "stm8s_uart1.h"
|
||||
#include "PinoutConfiguration.h"
|
||||
|
||||
#define UART_SPEED 9600
|
||||
|
||||
|
||||
static void GPIO_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);
|
||||
#endif
|
||||
|
||||
while(TRUE)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
while(TRUE);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void GPIO_setup(void)
|
||||
{
|
||||
GPIO_DeInit(PORT_UART);
|
||||
|
|
|
@ -18,7 +18,7 @@ void MeasurementCollector_Init()
|
|||
void MeasurementCollector_Tick()
|
||||
{
|
||||
VoltageSensorActualValue_MeasurementData_t sample;
|
||||
VoltageSensorActualValue_GetMeasurementData(&sample);
|
||||
VoltageSensorActualValue_MeasureValue(&sample);
|
||||
|
||||
Logger_Print(sample);
|
||||
}
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
#include "PinoutConfiguration.h"
|
||||
#include "UserInterface.h"
|
||||
#include "stm8s_i2c.h"
|
||||
//#include <stdio.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
|
||||
// shifted by one, to make 8 bits variable, where less signifant bit
|
||||
// is used to signalize communication direction (rx or tx)
|
||||
|
@ -30,17 +29,15 @@ void VoltageSensorActualValue_Init()
|
|||
GPIO_setup();
|
||||
I2C_setup();
|
||||
|
||||
// seleect adc configuration and start measurement
|
||||
// select adc configuration and start measurement
|
||||
write(0x00);
|
||||
}
|
||||
|
||||
|
||||
bool VoltageSensorActualValue_GetMeasurementData(VoltageSensorActualValue_MeasurementData_t *measurementData)
|
||||
bool VoltageSensorActualValue_MeasureValue(VoltageSensorActualValue_MeasurementData_t *measurementData)
|
||||
{
|
||||
write(0x10);
|
||||
*measurementData = read(0);
|
||||
// read(0);
|
||||
|
||||
|
||||
// getRegisterValue should return false on timeout and this should be later propagated to GUI component.
|
||||
return TRUE;
|
||||
|
@ -58,7 +55,7 @@ void I2C_setup(void)
|
|||
{
|
||||
I2C_DeInit();
|
||||
I2C_Init(100000,
|
||||
I2C_OWN_ADDRESS,
|
||||
I2C_MASTER_ADDRESS,
|
||||
I2C_DUTYCYCLE_2,
|
||||
I2C_ACK_CURR,
|
||||
I2C_ADDMODE_7BIT,
|
||||
|
|
Ładowanie…
Reference in New Issue