diff --git a/serialInterface.py b/serialInterface.py index 81f9380..664a14f 100755 --- a/serialInterface.py +++ b/serialInterface.py @@ -4,6 +4,7 @@ import serial from sys import argv from datetime import datetime +import time if __name__ == "__main__": ser = serial.Serial(port= argv[1], baudrate=argv[2]) @@ -13,7 +14,8 @@ entry = ser.read(5) totb = 0 - while 1: + time.sleep(1) + while ser.inWaiting() > 5: entry = ser.read(6) totb += 6 # print(entry.hex()) diff --git a/src/comm.c b/src/comm.c index c4d76c2..d2ff957 100644 --- a/src/comm.c +++ b/src/comm.c @@ -11,16 +11,12 @@ static uint8_t buf[0x20]; static uint8_t send_etx = 0; static uint8_t buf_cnt = 0; static volatile uint32_t setValue = 0; -static uint32_t rem; static void txCpltCback(UART_HandleTypeDef *huart) { - static uint8_t ts; if (send_etx > 1) { send_etx--; - rem = phcomm->SrcMemory.size - 0x400; - ts = rem <= 0x400 ? 1 : (rem / 0x400 + 1); - GAL_UART_Transmit_DMA(phcomm->SrcMemory.basePtr, ts == 1 ? rem : 0x400); + GAL_UART_Transmit_DMA(phcomm->SrcMemory.basePtr, send_etx == 1 ? phcomm->SrcMemory.size : 0xffff); } else if (send_etx == 1) { INVOKE_CB(phcomm->Callback.onUARTDownload, true); buf[0] = '\n'; @@ -103,10 +99,8 @@ static void rxCpltCback(UART_HandleTypeDef *huart) { INVOKE_CB(phcomm->Callback.onUARTDownload, false); GAL_UART_Transmit(buf + buf_cnt + 1, 1); - send_etx = phcomm->SrcMemory.size <= 0x400 ? 1 : (phcomm->SrcMemory.size / 0x400 + 1); - rem = phcomm->SrcMemory.size - 0x400; - // send_etx = phcomm->SrcMemory.size / 0x400; - GAL_UART_Transmit_DMA(phcomm->SrcMemory.basePtr, send_etx == 1 ? phcomm->SrcMemory.size : 0x400); + send_etx = (phcomm->SrcMemory.size >> 16) + 1; + GAL_UART_Transmit_DMA(phcomm->SrcMemory.basePtr, send_etx == 1 ? phcomm->SrcMemory.size : 0xffff); len = -2; } diff --git a/src/main.c b/src/main.c index bfce0df..23bdbd0 100644 --- a/src/main.c +++ b/src/main.c @@ -14,13 +14,11 @@ // Static reference for I2C static I2C_HandleTypeDef hi2c1; -static UART_HandleTypeDef huart1; static RTC_HandleTypeDef hrtc; void SystemClock_Config(void); static void MX_I2C1_Init(void); static void MX_GPIO_Init(void); -static void MX_USART1_UART_Init(void); static void MX_RTC_Init(void); static void update_interface(); static void disable_IRQ(); @@ -38,7 +36,6 @@ static RTC_TimeTypeDef gTime; static struct COMM_Handle hcomm; int main(void) { - uint8_t datestamp[23]; SystemInit(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); @@ -48,10 +45,7 @@ int main(void) { MX_GPIO_Init(); // Setup I2C MX_I2C1_Init(); - // MX_USART1_UART_Init(); // TODO: to remove MX_RTC_Init(); - // log_rtc_setup(&hrtc, &gTime, &gDate, "20/12/2021 16/04/00"); - // Initilization of the counters number_people = 0; @@ -138,20 +132,6 @@ ONUART_DOWNLOAD_CB(onUartDownload, xferDone) { } } -static void MX_USART1_UART_Init(void) { - huart1.Instance = USART1; - huart1.Init.BaudRate = 115200; - huart1.Init.WordLength = UART_WORDLENGTH_8B; - huart1.Init.StopBits = UART_STOPBITS_1; - huart1.Init.Parity = UART_PARITY_NONE; - huart1.Init.Mode = UART_MODE_TX_RX; - huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart1.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart1) != HAL_OK) { - Error_Handler(); - } -} - static void MX_I2C1_Init(void) { hi2c1.Instance = I2C1; hi2c1.Init.ClockSpeed = 100000;