49 #define PRINTF(...) printf(__VA_ARGS__) 62 PRINTF(
"Servo: invalid servo channel\n");
68 PRINTF(
"Servo: Invalid pin/port settings\n");
72 if(pos > SERVO_MAX_DEGREES) {
73 PRINTF(
"Servo: invalid position (max %u)\n", SERVO_MAX_DEGREES);
77 count = (SERVO_MAX_VAL - SERVO_MIN_VAL) * pos;
78 count /= SERVO_MAX_DEGREES;
79 count += SERVO_MIN_VAL;
81 gpt_num = (uint8_t)(gptab >> 8);
82 gpt_ab = (uint8_t)(gptab & 0x00FF);
89 PRINTF(
"Servo: failed to configure the pwm channel\n");
96 if(
pwm_start(gpt_num, gpt_ab, port, pin) != PWM_SUCCESS) {
97 PRINTF(
"Servo: failed to initialize the pwm channel\n");
101 return SERVO_SUCCESS;
111 PRINTF(
"Servo: invalid servo channel\n");
117 PRINTF(
"Servo: Invalid pin/port settings\n");
121 gpt_num = (uint8_t)((gptab & 0xFF00) >> 8);
122 gpt_ab = (uint8_t)(gptab & 0x00FF);
124 if(
pwm_disable(gpt_num, gpt_ab, port, pin) != PWM_SUCCESS) {
125 PRINTF(
"Servo: unable to disable the pwm channel\n");
129 return SERVO_SUCCESS;
Header file for the CC2538 PWM driver.
int servo_stop(uint16_t gptab, uint8_t port, uint8_t pin)
Fully stop a servo and reconfigures back the pin/port as GPIO.
Header file with register and macro declarations for the cc2538 GPIO module.
int8_t pwm_start(uint8_t timer, uint8_t ab, uint8_t port, uint8_t pin)
Once configured, starts the PWM.
Header file for a Generic Servo driver.
#define SERVO_CHANNEL_7
GPT3-B.
#define SERVO_DEFAULT_FREQ
50 Hz
#define GPIO_D_NUM
GPIO_D: 3.
#define SERVO_CHANNEL_1
GPT0-B.
int servo_position(uint16_t gptab, uint8_t port, uint8_t pin, uint16_t pos)
Configures and positions a servo in a given position (by degrees) The servo will lock its position as...
int8_t pwm_enable(uint32_t freq, uint8_t duty, uint32_t count, uint8_t timer, uint8_t ab)
Configures the general purpose timer in PWM mode.
int8_t pwm_disable(uint8_t timer, uint8_t ab, uint8_t port, uint8_t pin)
Disables a previously PWM configured GPTn.