Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
949 B

  1. /*
  2. * Code for initalizing USB CDC via the SYSINIT mechanism.
  3. */
  4. #include <sysinit.h>
  5. #include <stm32f1xx_hal_gpio.h>
  6. #include <stm32f1xx_hal_pcd.h>
  7. #include <usb_device.h>
  8. static void
  9. usb_cdc_init(const void *foo)
  10. {
  11. /*
  12. * pretend that the device was newly plugged in
  13. * see: https://stackoverflow.com/a/67336535
  14. */
  15. GPIO_InitTypeDef GPIO_InitStructure;
  16. GPIO_InitStructure = (GPIO_InitTypeDef){
  17. .Pin = GPIO_PIN_11|GPIO_PIN_12,
  18. .Mode = GPIO_MODE_OUTPUT_PP,
  19. .Pull = GPIO_PULLDOWN,
  20. .Speed = GPIO_SPEED_HIGH,
  21. };
  22. __HAL_RCC_GPIOA_CLK_ENABLE();
  23. HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
  24. //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);
  25. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
  26. HAL_Delay(10);
  27. MX_USB_DEVICE_Init();
  28. }
  29. extern PCD_HandleTypeDef hpcd_USB_FS;
  30. void
  31. USB_LP_IRQHandler(void)
  32. {
  33. HAL_PCD_IRQHandler(&hpcd_USB_FS);
  34. }
  35. SYSINIT(usb_cdc_init, SI_SUB_CONSOLE, SI_ORDER_FIRST, usb_cdc_init, NULL);