You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SITARA_PWMSS_HEADER__
  2. #define __SITARA_PWMSS_HEADER__
  3. #include <stdio.h>
  4. #include <fcntl.h>
  5. #include <unistd.h>
  6. #include <errno.h>
  7. #include <string.h>
  8. #include <sys/mman.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include "../../general/sitara-am437x.h"
  12. #include "../../general/am437x_cm.h"
  13. #include "sys_pwmss.h"
  14. #include "hw_ehrpwm.h"
  15. #ifdef CLI_NCURSES
  16. #include "../../../../cli/cli.h"
  17. #endif
  18. #define SOC_EHRPWM_1_MODULE_FREQ 100000000 // SYSCLKOUT [10 ns/tick]
  19. #define PWM_PRESCALE 224 // pwm clk divider - TBCLK
  20. #define TICKS_PER_MS 446 // ticks per msec pwm output period
  21. #define PWM_PERIOD_MS 20 // desired pwm output period in ms
  22. // PWM_PRESCALE of 224 = 14 * X (X = 1, 2, 4...128), see TBCTL Register
  23. // TICKS_PER_MS * PWM_PERIOD_MS = period of pwm output in ticks = TBPRD (only 16 bits)
  24. // FINITO
  25. bool init_PWM_SS0( void );
  26. bool init_PWM_SS1( void );
  27. bool init_PWM_SS2( void );
  28. bool pwm_disable( uint8_t system );
  29. bool pwm_enable( uint8_t system );
  30. bool pwm_clk_disable( uint8_t system );
  31. bool pwm_clk_enable( uint8_t system, uint8_t preScaler, uint32_t pwmPeriod );
  32. bool pwm_set( uint8_t system, uint32_t dutyCycle );
  33. bool pwm_run( uint8_t system, uint32_t dutyCycle );
  34. bool pwm_stop( uint8_t system );
  35. #ifdef CLI_NCURSES
  36. void print_PWM_info( uint8_t system );
  37. void wprint_PWM_info( WINDOW *wnd, int shX, int shY, uint8_t system );
  38. #endif
  39. void close_PWM_SS0( void );
  40. void close_PWM_SS1( void );
  41. void close_PWM_SS2( void );
  42. #endif