![](/media/cache/profiles/e5815151957be36ad2085b7a1a02c5cc.jpg.50x50_q85.jpg)
Controlor for Humanoid. Walking trajectory generator, sensor reflection etc.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
PWM.h@11:1539d181e159, 2012-09-22 (annotated)
- Committer:
- syundo0730
- Date:
- Sat Sep 22 10:24:14 2012 +0000
- Revision:
- 11:1539d181e159
- Parent:
- 9:d9ce965299d2
- Child:
- 16:e65c192b7ecf
16bit version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
syundo0730 | 9:d9ce965299d2 | 1 | #ifndef PWM_H_2012_08_28_ |
syundo0730 | 9:d9ce965299d2 | 2 | #define PWM_H_2012_08_28_ |
syundo0730 | 9:d9ce965299d2 | 3 | |
syundo0730 | 9:d9ce965299d2 | 4 | #include "LPC17xx.h" |
syundo0730 | 9:d9ce965299d2 | 5 | #include "mbed.h" |
syundo0730 | 9:d9ce965299d2 | 6 | |
syundo0730 | 9:d9ce965299d2 | 7 | const uint32_t SRV_PERIOD = 2500 - 1;// |
syundo0730 | 9:d9ce965299d2 | 8 | const uint32_t SRV_MAX_DUTY = 2100 - 1;// |
syundo0730 | 9:d9ce965299d2 | 9 | const uint32_t SRV_MIN_DUTY = 900 - 1;// |
syundo0730 | 9:d9ce965299d2 | 10 | |
syundo0730 | 9:d9ce965299d2 | 11 | const uint8_t SRV_IDX_SHIFT = 3;// |
syundo0730 | 9:d9ce965299d2 | 12 | const uint8_t SRV_IDX_NUM = 1 << SRV_IDX_SHIFT;// |
syundo0730 | 9:d9ce965299d2 | 13 | const uint8_t SRV_IDX_MASK = SRV_IDX_NUM - 1;// |
syundo0730 | 9:d9ce965299d2 | 14 | const uint8_t SRV_BANK_NUM = 3;// |
syundo0730 | 9:d9ce965299d2 | 15 | const uint8_t SRV_CH_NUM = SRV_IDX_NUM * SRV_BANK_NUM;// |
syundo0730 | 9:d9ce965299d2 | 16 | |
syundo0730 | 11:1539d181e159 | 17 | const uint32_t SRV_PWMTable[SRV_BANK_NUM][SRV_IDX_NUM] = { |
syundo0730 | 11:1539d181e159 | 18 | {0,SRV_PERIOD,0,SRV_PERIOD,0,SRV_PERIOD,0,SRV_PERIOD}, |
syundo0730 | 11:1539d181e159 | 19 | {0,0,SRV_PERIOD,SRV_PERIOD,0,0,SRV_PERIOD,SRV_PERIOD}, |
syundo0730 | 11:1539d181e159 | 20 | {0,0,0,0,SRV_PERIOD,SRV_PERIOD,SRV_PERIOD,SRV_PERIOD} |
syundo0730 | 11:1539d181e159 | 21 | }; |
syundo0730 | 11:1539d181e159 | 22 | |
syundo0730 | 9:d9ce965299d2 | 23 | class PWM { |
syundo0730 | 9:d9ce965299d2 | 24 | public: |
syundo0730 | 9:d9ce965299d2 | 25 | PWM(); |
syundo0730 | 9:d9ce965299d2 | 26 | public: |
syundo0730 | 9:d9ce965299d2 | 27 | void InitPWM(); |
syundo0730 | 9:d9ce965299d2 | 28 | void SetDuty(uint8_t ch, uint32_t duty); |
syundo0730 | 9:d9ce965299d2 | 29 | public: |
syundo0730 | 9:d9ce965299d2 | 30 | static volatile uint8_t SRV_Idx; |
syundo0730 | 9:d9ce965299d2 | 31 | static volatile uint32_t SRV_dutyTable[SRV_BANK_NUM][SRV_IDX_NUM]; |
syundo0730 | 9:d9ce965299d2 | 32 | }; |
syundo0730 | 9:d9ce965299d2 | 33 | |
syundo0730 | 9:d9ce965299d2 | 34 | #ifdef __cplusplus |
syundo0730 | 9:d9ce965299d2 | 35 | extern "C" { |
syundo0730 | 9:d9ce965299d2 | 36 | void PWM1_IRQHandler(); |
syundo0730 | 9:d9ce965299d2 | 37 | } |
syundo0730 | 9:d9ce965299d2 | 38 | #endif |
syundo0730 | 9:d9ce965299d2 | 39 | |
syundo0730 | 9:d9ce965299d2 | 40 | #endif //PWM_H_2012_08_28_ |