atx_control.ino 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. atx_control.ino
  3. author: tobychui
  4. This file include functions that handles
  5. ATX power control and switching.
  6. Note: Not all versions of RemdesKVM have
  7. ATX hardware populated
  8. */
  9. void update_atx_led_status() {
  10. led_tmp = digitalRead(ATX_PWR_LED);
  11. atx_status[0] = led_tmp;
  12. led_tmp = digitalRead(ATX_HDD_LED);
  13. atx_status[1] = led_tmp;
  14. }
  15. void report_status() {
  16. //Report status of ATX and USB mass storage switch in 1 byte
  17. //Bit 0: PWR LED status
  18. //Bit 1: HDD LED status
  19. //Bit 2: USB Mass Storage mounted side
  20. //Bit 3 - 7: Reserved
  21. uint8_t status = 0x00;
  22. status |= (atx_status[0] & 0x01);
  23. status |= (atx_status[1] & 0x01) << 1;
  24. status |= (usb_ms_side & 0x01) << 2;
  25. #if ENABLE_DEBUG == 1
  26. USBSerial_print("[DEBUG] ATX State");
  27. USBSerial_print("PWR=");
  28. USBSerial_print(atx_status[0]);
  29. USBSerial_print(" HDD=");
  30. USBSerial_print(atx_status[1]);
  31. USBSerial_print(" USB_MS=");
  32. USBSerial_println(usb_ms_side);
  33. #endif
  34. USBSerial_print(status);
  35. }