peripherial.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * peripherial.h
  3. *
  4. * Created on: Sep 10, 2024
  5. * Author: jakubski
  6. */
  7. #ifndef INC_PERIPHERIAL_H_
  8. #define INC_PERIPHERIAL_H_
  9. #include "main.h"
  10. #include "cmsis_os.h"
  11. #define DBG_LED1 GPIO_PIN_4
  12. #define DBG_LED2 GPIO_PIN_5
  13. #define DBG_LED3 GPIO_PIN_6
  14. #define DBG_LED4 GPIO_PIN_7
  15. #define CURRENT_SENSOR_L1_GPIO_OFFSET 7
  16. #define CURRENT_SENSOR_L2_GPIO_OFFSET 9
  17. #define CURRENT_SENSOR_L3_GPIO_OFFSET 13
  18. #define MCU_CS_PWR_EN GPIO_PIN_15
  19. enum _CurrentSensor
  20. {
  21. CurrentSensorL1,
  22. CurrentSensorL2,
  23. CurrentSensorL3
  24. };
  25. typedef enum _CurrentSensor CurrentSensor;
  26. enum _CurrentSensorGain
  27. {
  28. csGain1,
  29. csGain2,
  30. csGain3,
  31. csGain0
  32. };
  33. typedef enum _CurrentSensorGain CurrentSensorGain;
  34. enum _MotorDriverState
  35. {
  36. HiZ,
  37. Forward,
  38. Reverse,
  39. Brake
  40. };
  41. typedef enum _MotorDriverState MotorDriverState;
  42. void DbgLEDOn(uint8_t ledNumber);
  43. void DbgLEDOff(uint8_t ledNumber);
  44. void DbgLEDToggle(uint8_t ledNumber);
  45. void EnableCurrentSensors(void);
  46. void DisableCurrentSensors(void);
  47. void SelectCurrentSensorGain(CurrentSensor sensor, CurrentSensorGain gain);
  48. void MotorAction(TIM_HandleTypeDef *tim, TIM_OC_InitTypeDef *timerConf, uint32_t channel1, uint32_t channel2, MotorDriverState setState, uint32_t pulse);
  49. uint8_t MotorControl (TIM_HandleTypeDef* htim, TIM_OC_InitTypeDef* motorTimerConfigOC, uint8_t channel1, uint8_t channel2, osTimerId_t motorTimerHandle,
  50. int32_t motorPWMPulse, int32_t motorTimerPeriod, uint8_t switchLimiterUpStat, uint8_t switchLimiterDownStat) ;
  51. #endif /* INC_PERIPHERIAL_H_ */