Merge pull request #103 from RobertGawron/develop

Develop
pull/234/head
Robert 2019-08-04 12:39:21 +02:00 zatwierdzone przez GitHub
commit c0cebadbf1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
72 zmienionych plików z 79 dodań i 9668 usunięć

Wyświetl plik

@ -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_ */

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -32,3 +32,4 @@ void ClockConfigurator_Init()
CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, ENABLE);
CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER1, ENABLE);
}

Wyświetl plik

@ -6,17 +6,17 @@
*/
#include "Logger.h"
#include "stm8s_uart1.h"
#include "PinoutConfiguration.h"
#define USE_PRINTF
//#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);
@ -30,7 +30,7 @@ void putchar(char c)
/* Write a character to the UART1 */
UART1_SendData8(c);
/* Loop until the end of transmission */
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
while(UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
}
@ -45,12 +45,12 @@ void Logger_Print(uint8_t data)
{
#if defined USE_PRINTF
printf("%d\n\r", data);
#else
#else
putchar(data);
putchar('\n');
putchar('\r');
#endif
#endif
}
@ -64,14 +64,12 @@ 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
#endif
void GPIO_setup(void)
{

Wyświetl plik

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

Wyświetl plik

@ -9,10 +9,10 @@
void PulseCounter_Init()
{
}
void PulseCounter_Tick()
{
}

Wyświetl plik

@ -14,3 +14,4 @@ void TimerConfigurator_Init()
TIM1_Cmd(ENABLE);
TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE);
}

Wyświetl plik

@ -27,15 +27,17 @@ void UserInterface_ShowMessage(UserInterface_Status status)
{
switch(status)
{
case USER_INTERFACE_COLLECTING_DATA_MSG:
{
GPIO_WriteHigh(PORT_GPIO_LED, PIN_GPIO_LED_RED);
break;
}
case USER_INTERFAE_STATE_OK_MSG:
{
GPIO_WriteHigh(PORT_GPIO_LED, PIN_GPIO_LED_GREEN);
break;
}
case USER_INTERFACE_COLLECTING_DATA_MSG:
{
GPIO_WriteHigh(PORT_GPIO_LED, PIN_GPIO_LED_RED);
break;
}
case USER_INTERFAE_STATE_OK_MSG:
{
GPIO_WriteHigh(PORT_GPIO_LED, PIN_GPIO_LED_GREEN);
break;
}
}
}

Wyświetl plik

@ -9,8 +9,10 @@
#include "PinoutConfiguration.h"
#include "UserInterface.h"
#include "stm8s_i2c.h"
#include <stdio.h>
#define I2C_OWN_ADDRESS 0x10
#include "Logger.h"
#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)
@ -27,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;
@ -55,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,
@ -84,25 +84,42 @@ static uint16_t read(uint8_t registerId)
{
I2C_GenerateSTART(ENABLE);
while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C_SLAVE_ADDRESS, I2C_DIRECTION_RX);
while(!I2C_CheckEvent(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
uint16_t registerMSB = I2C_ReceiveData();
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
uint16_t registerLSB = I2C_ReceiveData();
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
uint16_t registerLSB1 = I2C_ReceiveData();
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
uint16_t registerLSB2 = I2C_ReceiveData();
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
uint16_t registerLSB3 = I2C_ReceiveData();
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
for(int i=0; i<4; i++)
{
while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
uint16_t registerMSB = I2C_ReceiveData();
printf("%d\n", registerMSB);
}
// while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED));
// uint16_t registerLSB = I2C_ReceiveData();
I2C_AcknowledgeConfig(DISABLE);
I2C_GenerateSTOP(ENABLE);
// while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));
I2C_AcknowledgeConfig(ENABLE);
Logger_Print( registerMSB);
Logger_Print( registerLSB);
Logger_Print( registerLSB1);
Logger_Print( registerLSB2);
Logger_Print( registerLSB3);
// printf("data: %d %d %d %d %d\r\n", registerMSB, registerLSB, registerLSB1, registerLSB2, registerLSB3);
uint16_t registerValue = 0;
return registerValue;

Wyświetl plik

@ -7,3 +7,5 @@
#include "VoltageSensorPeakValue.h"
// placeholder file, this sensor probably won't be used

Wyświetl plik

@ -15,3 +15,4 @@ int main( void )
return 0;
}

Wyświetl plik

@ -8,7 +8,7 @@ SIZE = size
MAKE = make
TARGET = main
STDLIB = STM8S_StdPeriph_Lib/Libraries/STM8S_StdPeriph_Driver
STDLIB = STM8S_StdPeriph_Lib
INCLUDEDIR = $(STDLIB)/inc Inc
LIBSRCDIR = $(STDLIB)/src
SRCS = Src

Wyświetl plik

@ -54,7 +54,7 @@ indent_func_throw = 0
indent_member = 0
indent_sing_line_comments = 0
indent_relative_single_line_comments = false
indent_switch_case = 0
indent_switch_case = 4
indent_case_shift = 0
indent_case_brace = 0
indent_col1_comment = false
@ -82,8 +82,8 @@ indent_min_vbrace_open = 0
indent_vbrace_open_on_tabstop = false
indent_token_after_brace = true
indent_cpp_lambda_body = false
sp_arith = ignore
sp_assign = ignore
sp_arith = add
sp_assign = add
sp_cpp_lambda_assign = ignore
sp_cpp_lambda_paren = ignore
sp_assign_default = ignore
@ -97,7 +97,7 @@ sp_pp_concat = add
sp_pp_stringify = ignore
sp_before_pp_stringify = ignore
sp_bool = ignore
sp_compare = ignore
sp_compare = add
sp_inside_paren = ignore
sp_paren_paren = ignore
sp_cparen_oparen = ignore
@ -127,7 +127,7 @@ sp_angle_paren_empty = ignore
sp_angle_word = ignore
sp_angle_shift = add
sp_permit_cpp11_shift = false
sp_before_sparen = ignore
sp_before_sparen = remove
sp_inside_sparen = ignore
sp_inside_sparen_close = ignore
sp_inside_sparen_open = ignore
@ -365,7 +365,7 @@ nl_switch_brace = ignore
nl_synchronized_brace = ignore
nl_multi_line_cond = false
nl_multi_line_define = false
nl_before_case = false
nl_before_case = true
nl_before_throw = ignore
nl_after_case = false
nl_case_colon_brace = ignore
@ -465,7 +465,7 @@ nl_after_func_class_proto = 0
nl_after_func_class_proto_group = 0
nl_before_func_body_def = 0
nl_before_func_body_proto = 0
nl_after_func_body = 0
nl_after_func_body = 3
nl_after_func_body_class = 0
nl_after_func_body_one_liner = 0
nl_before_block_comment = 0
@ -483,8 +483,8 @@ nl_after_try_catch_finally = 0
nl_around_cs_property = 0
nl_between_get_set = 0
nl_property_brace = ignore
eat_blanks_after_open_brace = false
eat_blanks_before_close_brace = false
eat_blanks_after_open_brace = true
eat_blanks_before_close_brace = true
nl_remove_extra_newlines = 0
nl_before_return = false
nl_after_return = false
@ -502,7 +502,7 @@ mod_full_brace_using = ignore
mod_paren_on_return = ignore
mod_pawn_semicolon = false
mod_full_paren_if_bool = false
mod_remove_extra_semicolon = false
mod_remove_extra_semicolon = true
mod_add_long_function_closebrace_comment = 0
mod_add_long_namespace_closebrace_comment = 0
mod_add_long_class_closebrace_comment = 0