Skip to content

Instantly share code, notes, and snippets.

View gamazeps's full-sized avatar

Félix Raimundo gamazeps

View GitHub Profile
static PWMConfig pwmcfg = {
200000, /* 200Khz PWM clock frequency*/
1024, /* PWM period of 1024 ticks ~ 0.005 second */
NULL, /* No callback */
/* Only channel 1 enabled */
{
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL}
#include "ch.h"
#include "hal.h"
int main(void) {
halInit(); // Initializes ChibiOS/RT's Hardware Abstraction Layer (HAL)
chSysInit(); // Initializes ChibiOS/RT kernel
// Configures GPIOD pin 15 as output (the blue LED on the board)
palSetPadMode(GPIOD, 15, PAL_MODE_OUTPUT_PUSHPULL);
#include "ch.h"
#include "hal.h"
#include "servo.h"
#define SERVO_PWM PWMD3
static PWMConfig pwm_servo = {
100000, /* 100Khz PWM clock frequency*/
2000, /* PWM period of 2000 ticks ~ 20ms */
NULL, /* No callback at the end of the timer count */