Contiki-NG
Loading...
Searching...
No Matches

Driver for a Generic Servo actuator. More...

Files

file  arch/platform/zoul/dev/servo.c
 Driver for a generic Servo driver.
file  arch/platform/zoul/dev/servo.h
 Header file for a Generic Servo driver.

Servo public funtions

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 long as it is not stopped.
int servo_stop (uint16_t gptab, uint8_t port, uint8_t pin)
 Fully stop a servo and reconfigures back the pin/port as GPIO.

Servo default settings

#define SERVO_DEFAULT_FREQ   50
 50 Hz

Servo general purpose timers mapping

#define SERVO_CHANNEL_1   0x001
 GPT0-B.
#define SERVO_CHANNEL_2   0x100
 GPT1-A.
#define SERVO_CHANNEL_3   0x101
 GPT1-B.
#define SERVO_CHANNEL_4   0x200
 GPT2-A.
#define SERVO_CHANNEL_5   0x201
 GPT2-B.
#define SERVO_CHANNEL_6   0x300
 GPT3-A.
#define SERVO_CHANNEL_7   0x301
 GPT3-B.

Detailed Description

Driver for a Generic Servo actuator.

Function Documentation

◆ servo_position()

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 long as it is not stopped.

Parameters
gptabServo channel (PWM GPT from 1-7)
portPort number to use as PWM
pinPin number to use as PWM
posPosition to map the servo to (0-360ยบ, integer)
Returns
SERVO_SUCCESS if successful, else SERVO_ERROR

< GPT0-B

< GPT3-B

roughly equals to 12% duty cycle

roughly equals to 3% duty cycle

roughly equals to 3% duty cycle

< 50 Hz

Definition at line 55 of file servo.c.

References count, GPIO_D_NUM, pwm_enable(), pwm_start(), SERVO_CHANNEL_1, SERVO_CHANNEL_7, and SERVO_DEFAULT_FREQ.

◆ servo_stop()

int servo_stop ( uint16_t gptab,
uint8_t port,
uint8_t pin )

Fully stop a servo and reconfigures back the pin/port as GPIO.

Parameters
gptabServo channel (PWM GPT from 1-7)
portPort number to use as PWM
pinPin number to use as PWM
Returns
SERVO_SUCCESS if successful, else SERVO_ERROR

< GPT0-B

< GPT3-B

Definition at line 105 of file servo.c.

References GPIO_D_NUM, pwm_disable(), SERVO_CHANNEL_1, and SERVO_CHANNEL_7.