X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ssr%2FSrc%2Fmain.c;h=490bcf171669946241f292df4ce184125357c7ea;hb=832142c0afc865e125a978f590ba5f5dcce17219;hp=9d6a7530d32ea7568c72bd8aca8d89c75d9f5988;hpb=9d04b18ba06d1f57fee5d04c1ee1c47261023183;p=home-hw.git diff --git a/ssr/Src/main.c b/ssr/Src/main.c index 9d6a753..490bcf1 100644 --- a/ssr/Src/main.c +++ b/ssr/Src/main.c @@ -52,11 +52,11 @@ /* Private variables ---------------------------------------------------------*/ PCD_HandleTypeDef hpcd_USB_FS; -volatile byte led_trigger; /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ struct usb usb; +volatile byte timer_ticked; /* USER CODE END PV */ @@ -109,6 +109,11 @@ static void process_packet(void) put_u32_be(tx_packet, 0); } break; + + case 2: + put_u32_be(tx_packet, 0); + put_u32_be(tx_packet+4, ds_current_temp); + break; } debug_printf(">> status %08x\n", get_u32_be(tx_packet)); @@ -170,21 +175,24 @@ int main(void) LL_TIM_EnableIT_UPDATE(TIM4); LL_TIM_GenerateEvent_UPDATE(TIM4); + ds_init(); + /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { - if (led_trigger) + if (timer_ticked) { - led_trigger = 0; + timer_ticked = 0; static byte led_state; if (led_state) LL_GPIO_SetOutputPin(LED_GPIO_Port, LED_Pin); else LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin); led_state ^= 1; + ds_step(); } if (rx_packet_state == 1 && !tx_packet_state) @@ -337,7 +345,7 @@ static void MX_TIM3_Init(void) GPIO_InitStruct.Pin = THERMO_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; LL_GPIO_Init(THERMO_GPIO_Port, &GPIO_InitStruct); } @@ -443,8 +451,9 @@ static void MX_USB_PCD_Init(void) */ static void MX_DMA_Init(void) { + /* Init with LL driver */ /* DMA controller clock enable */ - __HAL_RCC_DMA1_CLK_ENABLE(); + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); /* DMA interrupt init */ /* DMA1_Channel6_IRQn interrupt configuration */ @@ -491,6 +500,10 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + // XXX: By some magic, the above initialization does not always work, + // so we repeat it here. + LL_GPIO_SetOutputPin(GPIOB, SSR3_Pin|SSR4_Pin|SSR1_Pin|SSR2_Pin); + } /* USER CODE BEGIN 4 */