bit operations moved to a spearate file

pull/104/head
RobertGawron 2019-08-04 11:26:25 +01:00
rodzic aaba71a028
commit eb1df327f6
4 zmienionych plików z 13 dodań i 7 usunięć

Wyświetl plik

@ -0,0 +1,8 @@
#ifndef SRC_BITHANDLER_H_
#define SRC_BITHANDLER_H_
// TODO a bit of type checking?
#define GET_MSB(data) (data >> 8)
#define GET_LSB(data) (data & 0xff)
#endif

2
software/Firmware/Inc/Logger.h 100755 → 100644
Wyświetl plik

@ -10,7 +10,7 @@
#include "CommonDataTypes.h"
typedef uint16_t Logger_DataFormat_t;
typedef uint16_t Logger_DataFormat_t;
void Logger_Init();

Wyświetl plik

@ -8,6 +8,7 @@
#include "Logger.h"
#include "stm8s_uart1.h"
#include "PinoutConfiguration.h"
#include "BitHandler.h"
//#define USE_PRINTF
#if defined USE_PRINTF
@ -46,11 +47,8 @@ void Logger_Print(Logger_DataFormat_t data)
#if defined USE_PRINTF
printf("%d\n\r", data);
#else
uint8_t msb = (data >> 8);
uint8_t lsb = (data & 0xff);
putchar(msb);
putchar(lsb);
putchar(GET_MSB(data));
putchar(GET_LSB(data));
putchar('\n');
putchar('\r');
#endif

Wyświetl plik

@ -117,7 +117,7 @@ static uint16_t read(uint8_t registerId)
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 = (registerMSB << 8) + registerLSB;