From d5072ffff5c03983a288bb65ba0524866d9e7144 Mon Sep 17 00:00:00 2001 From: StefansE Date: Fri, 3 Apr 2026 22:40:08 +0200 Subject: [PATCH] more comms to be implemented --- Core/Inc/myComms.h | 24 ++++++++++++++++-- Core/Src/dma.c | 2 +- Core/Src/myComms.c | 57 +++++++++++++++++++++++++++++++++++-------- Core/Src/tim.c | 2 +- Core/Src/ws2812_drv.c | 2 +- LedRing.ioc | 4 +-- 6 files changed, 74 insertions(+), 17 deletions(-) diff --git a/Core/Inc/myComms.h b/Core/Inc/myComms.h index 40a12a3..cc29b30 100644 --- a/Core/Inc/myComms.h +++ b/Core/Inc/myComms.h @@ -10,14 +10,26 @@ typedef enum { com_WhoAmI, - com_setTime, + com_getTime, + com_getMonthDay, + com_getYear, + com_getTimeZone, + + com_setTime, + com_setMonthDay, + com_setYear, + com_setColour_hour, com_setColour_minute, com_setColour_second, com_setColour_background, + + com_setTimeZone, + com_readNV, com_writeNV, + com_MAX_command } commands_e; @@ -32,8 +44,16 @@ void cmd_RunCommand(commands_e cmd, uint32_t * input); void cmd_WhoAmI(uint32_t); -void cmd_SetTime(uint32_t time); + void cmd_GetTime(uint32_t time); +void cmd_GetMonthDay(uint32_t d); +void cmd_GetYear(uint32_t d); +void cmd_GetTimeZone(uint32_t d); + +void cmd_SetTime(uint32_t time); +void cmd_SetYear(uint32_t year); +void cmd_SetMonthDay(uint32_t); +void cmd_Set_TimeZone(uint32_t); void cmd_setColour_hour(uint32_t colour); void cmd_setColour_minute(uint32_t colour); void cmd_setColour_second(uint32_t colour); diff --git a/Core/Src/dma.c b/Core/Src/dma.c index ebfc348..1d6068c 100644 --- a/Core/Src/dma.c +++ b/Core/Src/dma.c @@ -44,7 +44,7 @@ void MX_DMA_Init(void) /* DMA interrupt init */ /* DMA1_Channel5_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 14, 0); + HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn); } diff --git a/Core/Src/myComms.c b/Core/Src/myComms.c index 2eb24f2..486d555 100644 --- a/Core/Src/myComms.c +++ b/Core/Src/myComms.c @@ -42,18 +42,55 @@ uint8_t UART_RxBuf[6] = {0}; uint8_t RxComplete_fl = 0; void (*commands[])(uint32_t) = { - cmd_WhoAmI, - cmd_SetTime, - cmd_GetTime, - cmd_setColour_hour, - cmd_setColour_minute, - cmd_setColour_second, - cmd_setColour_background, - cmd_readNV, - cmd_writeNV, - cmd_setColour_second + cmd_WhoAmI, // 0 + + cmd_GetTime, // 1 + cmd_GetMonthDay, // 2 + cmd_GetYear, // 3 + cmd_GetTimeZone, // 4 + + cmd_SetTime, // 5 + cmd_SetMonthDay, // 6 + cmd_SetYear, // 7 + + cmd_setColour_hour, // 8 + cmd_setColour_minute, // 9 + cmd_setColour_second, // 10 + cmd_setColour_background, // 11 + + cmd_Set_TimeZone, // 12 + + cmd_readNV, // 13 + cmd_writeNV, // 14 + }; +void cmd_GetTimeZone(uint32_t d){ + + +} + +void cmd_GetYear(uint32_t d){ + +} + +void cmd_GetMonthDay(uint32_t d){ + +} + +void cmd_SetYear(uint32_t year){ + + +} + +void cmd_SetMonthDay(uint32_t){ + +} + +void cmd_Set_TimeZone(uint32_t){ + +} + static void cmd_readNV(uint32_t data){ HAL_StatusTypeDef status = HAL_ERROR; diff --git a/Core/Src/tim.c b/Core/Src/tim.c index bf885ff..b56067e 100644 --- a/Core/Src/tim.c +++ b/Core/Src/tim.c @@ -111,7 +111,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) __HAL_LINKDMA(tim_baseHandle,hdma[TIM_DMA_ID_CC1],hdma_tim2_ch1); /* TIM2 interrupt Init */ - HAL_NVIC_SetPriority(TIM2_IRQn, 14, 0); + HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0); HAL_NVIC_EnableIRQ(TIM2_IRQn); /* USER CODE BEGIN TIM2_MspInit 1 */ diff --git a/Core/Src/ws2812_drv.c b/Core/Src/ws2812_drv.c index dc08741..d2ef8c8 100644 --- a/Core/Src/ws2812_drv.c +++ b/Core/Src/ws2812_drv.c @@ -30,7 +30,7 @@ void ws2812_Init(void){ } void ws2812_update(void){ - HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_1, ledStripBuffer, sizeof(ledStripBuffer)); + HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_1, (const uint32_t*) ledStripBuffer, sizeof(ledStripBuffer)); } void ws2812_set_colour(uint8_t led, uint8_t red, uint8_t green, uint8_t blue){ diff --git a/LedRing.ioc b/LedRing.ioc index 45c25ef..53726b5 100644 --- a/LedRing.ioc +++ b/LedRing.ioc @@ -49,7 +49,7 @@ Mcu.UserName=STM32F103C6Tx MxCube.Version=6.14.1 MxDb.Version=DB.6.0.141 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DMA1_Channel5_IRQn=true\:14\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA1_Channel5_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false @@ -59,7 +59,7 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false -NVIC.TIM2_IRQn=true\:14\:0\:true\:false\:true\:true\:true\:true +NVIC.TIM2_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PA0-WKUP.Signal=S_TIM2_CH1_ETR