Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

38 Zeilen
829 B

  1. /*
  2. * Code for reseting USB via the SYSINIT mechanism.
  3. *
  4. * Note: This works for both Node151 and BluePill (F1) as PA12 is
  5. * USB_DP on both.
  6. */
  7. #include <sysinit.h>
  8. #include <usbd_cdc_if.h>
  9. #include <usb_device.h>
  10. static void
  11. usb_reset(void)
  12. {
  13. /*
  14. * pretend that the device was newly plugged in
  15. * see: https://stackoverflow.com/a/67336535
  16. */
  17. GPIO_InitTypeDef GPIO_InitStructure;
  18. GPIO_InitStructure = (GPIO_InitTypeDef){
  19. .Pin = GPIO_PIN_11|GPIO_PIN_12,
  20. .Mode = GPIO_MODE_OUTPUT_PP,
  21. .Pull = GPIO_PULLDOWN,
  22. .Speed = GPIO_SPEED_HIGH,
  23. };
  24. __HAL_RCC_GPIOA_CLK_ENABLE();
  25. HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
  26. //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);
  27. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
  28. HAL_Delay(10);
  29. }
  30. SYSINIT_VF(usb_reset, SI_SUB_USB, SI_ORDER_FIRST, usb_reset);