hal.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef CX_CHLCD_HAL_H_INCLUDED
  2. #define CX_CHLCD_HAL_H_INCLUDED
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "cx/chlcd/types.h"
  6. #ifdef CHLCD_ON_ESP
  7. static inline chlcd_error_t chlcd_pin_set_output(chlcd_pin_t target) {
  8. }
  9. static inline chlcd_error_t chlcd_pin_write(chlcd_pin_t target, bool state) {
  10. }
  11. static inline chlcd_error_t chlcd_pin_set_pwm(chlcd_pin_t target) {
  12. }
  13. static inline chlcd_error_t chlcd_pin_write_pwm(
  14. chlcd_pin_t target,
  15. uint16_t pwm
  16. ) {
  17. }
  18. static inline chlcd_error_t chlcd_sleep_us(uint32_t time) {
  19. }
  20. #elifdef CHLCD_STDIO_TESTING
  21. #include <stdio.h>
  22. static inline chlcd_error_t chlcd_pin_set_output(chlcd_pin_t target) {
  23. printf("Pin %u mode set to output.\n", (uint32_t) target);
  24. return CHLCD_SUCCESS;
  25. }
  26. static inline chlcd_error_t chlcd_pin_write(chlcd_pin_t target, bool state) {
  27. printf("Pin %u set to %s.\n", (uint32_t) target, state ? "HIGH" : "LOW");
  28. return CHLCD_SUCCESS;
  29. }
  30. static inline chlcd_error_t chlcd_pin_set_pwm(chlcd_pin_t target) {
  31. printf("Pin %u mode set to PWM.\n", (uint32_t) target);
  32. return CHLCD_SUCCESS;
  33. }
  34. static inline chlcd_error_t chlcd_pin_write_pwm(
  35. chlcd_pin_t target,
  36. uint16_t pwm
  37. ) {
  38. printf("Pin %u write to PWM %i.\n", (uint32_t) target, pwm);
  39. return CHLCD_SUCCESS;
  40. }
  41. static inline chlcd_error_t chlcd_sleep_us(uint32_t time) {
  42. printf("Wait for %u ns.\n", time);
  43. return CHLCD_SUCCESS;
  44. }
  45. #endif
  46. #endif