flipper_hal.c 952 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Flipper devices inc.
  3. GPIO and HAL implementations
  4. */
  5. #include "main.h"
  6. #include "flipper_hal.h"
  7. #include <stdio.h>
  8. void app_gpio_init(GpioPin gpio, GpioMode mode) {
  9. if(gpio.pin != 0) {
  10. switch(mode) {
  11. case GpioModeInput:
  12. printf("[GPIO] %s%d input\n", gpio.port, gpio.pin);
  13. break;
  14. case GpioModeOutput:
  15. printf("[GPIO] %s%d push pull\n", gpio.port, gpio.pin);
  16. break;
  17. case GpioModeOpenDrain:
  18. printf("[GPIO] %s%d open drain\n", gpio.port, gpio.pin);
  19. break;
  20. }
  21. gpio.mode = mode;
  22. } else {
  23. printf("[GPIO] no pin\n");
  24. }
  25. }
  26. void delay_us(uint32_t time) {
  27. // How to deal with it
  28. printf("[DELAY] %d us\n", time);
  29. }
  30. void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) {
  31. printf("[TIM] set pwm %d:%d %f Hz, %f%%\n", *tim, channel, freq, value * 100.);
  32. }