From 0f227683e29062224a612c4a2ab5c8b2fc166059 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 2 Apr 2016 22:40:23 -0700 Subject: altos: Add detherm product Signed-off-by: Keith Packard --- src/detherm/.gitignore | 2 + src/detherm/Makefile | 81 ++++++++++++++++++++++++++++ src/detherm/ao_detherm.c | 48 +++++++++++++++++ src/detherm/ao_pins.h | 105 ++++++++++++++++++++++++++++++++++++ src/detherm/flash-loader/.gitignore | 2 + src/detherm/flash-loader/Makefile | 8 +++ src/detherm/flash-loader/ao_pins.h | 36 +++++++++++++ 7 files changed, 282 insertions(+) create mode 100644 src/detherm/.gitignore create mode 100644 src/detherm/Makefile create mode 100644 src/detherm/ao_detherm.c create mode 100644 src/detherm/ao_pins.h create mode 100644 src/detherm/flash-loader/.gitignore create mode 100644 src/detherm/flash-loader/Makefile create mode 100644 src/detherm/flash-loader/ao_pins.h (limited to 'src/detherm') diff --git a/src/detherm/.gitignore b/src/detherm/.gitignore new file mode 100644 index 00000000..4f11d9a0 --- /dev/null +++ b/src/detherm/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +detherm-* diff --git a/src/detherm/Makefile b/src/detherm/Makefile new file mode 100644 index 00000000..35df6c96 --- /dev/null +++ b/src/detherm/Makefile @@ -0,0 +1,81 @@ +# +# AltOS build +# +# + +include ../stmf0/Makefile.defs + +INC = \ + ao.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_pins.h \ + ao_product.h \ + ao_task.h \ + stm32f0.h + +# +# Common AltOS sources +# +ALTOS_SRC = \ + ao_interrupt.c \ + ao_timer.c \ + ao_panic.c \ + ao_mutex.c \ + ao_dma_stm.c \ + ao_usb_stm.c \ + ao_spi_stm.c \ + ao_exti_stm.c \ + ao_stdio.c \ + ao_led.c \ + ao_log.c \ + ao_log_mini.c \ + ao_sample.c \ + ao_data.c \ + ao_kalman.c \ + ao_flight.c \ + ao_report.c \ + ao_storage.c \ + ao_m25.c \ + ao_romconfig.c \ + ao_boot_chain.c \ + ao_ms5607.c \ + ao_convert_pa.c \ + ao_pwm.c \ + ao_task.c \ + ao_config.c \ + ao_cmd.c \ + ao_product.c + +PRODUCT=Detherm-v1.0 +PRODUCT_DEF=-DDETHERM_V_1_0 +IDPRODUCT=0x0013 + +CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -g -Os + +PROGNAME=detherm-v1.0 +PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx + +SRC=$(ALTOS_SRC) ao_detherm.c +OBJ=$(SRC:.c=.o) + +all: $(PROG) $(HEX) + +$(PROG): Makefile $(OBJ) altos.ld + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + +ao_product.h: ao-make-product.5c ../Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) -o $@ + +$(OBJ): $(INC) + +distclean: clean + +clean: + rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx + rm -f ao_product.h + +install: + +uninstall: diff --git a/src/detherm/ao_detherm.c b/src/detherm/ao_detherm.c new file mode 100644 index 00000000..cc013753 --- /dev/null +++ b/src/detherm/ao_detherm.c @@ -0,0 +1,48 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include +#include +#include + +void main(void) +{ + ao_led_init(LEDS_AVAILABLE); + + ao_led_on(AO_LED_RED); + + ao_clock_init(); + ao_task_init(); + ao_timer_init(); + ao_exti_init(); + + ao_dma_init(); + ao_spi_init(); + ao_usb_init(); + + ao_storage_init(); +// ao_flight_init(); +// ao_ms5607_init(); + ao_pwm_init(); + ao_log_init(); + ao_report_init(); + ao_config_init(); + + ao_cmd_init(); + + ao_start_scheduler(); +} diff --git a/src/detherm/ao_pins.h b/src/detherm/ao_pins.h new file mode 100644 index 00000000..9b623627 --- /dev/null +++ b/src/detherm/ao_pins.h @@ -0,0 +1,105 @@ +/* + * Copyright © 2015 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +#define LED_PORT_ENABLE STM_RCC_AHBENR_IOPAEN +#define LED_PORT (&stm_gpioa) +#define LED_PIN_RED 3 +#define AO_LED_RED (1 << LED_PIN_RED) + +#define LEDS_AVAILABLE (AO_LED_RED) + +#define HAS_BEEP 0 + +/* 48MHz clock based on USB */ +//#define AO_HSI48 1 +#define AO_HSE 16000000 +#define AO_RCC_CFGR_PLLMUL STM_RCC_CFGR_PLLMUL_3 +#define AO_PLLMUL 3 +#define AO_PLLDIV 1 + +/* HCLK = 48MHz */ +#define AO_AHB_PRESCALER 1 +#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 + +/* APB = 48MHz */ +#define AO_APB_PRESCALER 1 +#define AO_RCC_CFGR_PPRE_DIV STM_RCC_CFGR_PPRE_DIV_1 + +#define HAS_USB 1 +#define AO_USB_DIRECTIO 0 +#define AO_PA11_PA12_RMP 1 + +#define IS_FLASH_LOADER 0 + +#define AO_DATA_RING 16 + +#define HAS_ADC 0 +#define HAS_ACCEL 0 +#define HAS_GPS 0 +#define HAS_RADIO 0 +#define HAS_FLIGHT 1 +#define HAS_EEPROM 1 +#define HAS_LOG 1 + +#define AO_LOG_FORMAT AO_LOG_FORMAT_DETHERM + +#define USE_INTERNAL_FLASH 0 + +/* SPI */ +#define HAS_SPI_1 1 +#define HAS_SPI_2 0 +#define SPI_1_PA5_PA6_PA7 1 +#define SPI_1_PB3_PB4_PB5 1 +#define SPI_1_OSPEEDR STM_OSPEEDR_HIGH + +/* MS5607 */ +#define HAS_MS5607 1 + +#define AO_MS5607_CS_PORT (&stm_gpiob) +#define AO_MS5607_CS_PIN 6 +#define AO_MS5607_SPI_INDEX AO_SPI_1_PB3_PB4_PB5 +#define AO_MS5607_MISO_PORT (&stm_gpiob) +#define AO_MS5607_MISO_PIN 4 + +/* Flash */ + +#define M25_MAX_CHIPS 1 +#define AO_M25_SPI_CS_PORT (&stm_gpioa) +#define AO_M25_SPI_CS_MASK (1 << 4) +#define AO_M25_SPI_BUS AO_SPI_1_PA5_PA6_PA7 + +/* PWM */ + +#define NUM_PWM 1 +#define AO_PWM_TIMER (&stm_tim3) +#define AO_PWM_0_GPIO (&stm_gpiob) +#define AO_PWM_0_PIN 1 +#define AO_PWM_0_CH 4 +#define PWM_MAX 20000 +#define AO_PWM_TIMER_ENABLE STM_RCC_APB1ENR_TIM3EN +#define AO_PWM_TIMER_SCALE 32 + +/* Motor */ + +#define AO_MOTOR_DIR_GPIO (&stm_gpiob) +#define AO_MOTOR_DIR_PIN 0 +#define AO_MOTOR_SPEED_PWM 0 + +#endif /* _AO_PINS_H_ */ diff --git a/src/detherm/flash-loader/.gitignore b/src/detherm/flash-loader/.gitignore new file mode 100644 index 00000000..d0d4657e --- /dev/null +++ b/src/detherm/flash-loader/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +detherm* diff --git a/src/detherm/flash-loader/Makefile b/src/detherm/flash-loader/Makefile new file mode 100644 index 00000000..5210aa09 --- /dev/null +++ b/src/detherm/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=detherm-v1.0 +include $(TOPDIR)/stmf0/Makefile-flash.defs diff --git a/src/detherm/flash-loader/ao_pins.h b/src/detherm/flash-loader/ao_pins.h new file mode 100644 index 00000000..570800ca --- /dev/null +++ b/src/detherm/flash-loader/ao_pins.h @@ -0,0 +1,36 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +#include + +/* Pin 5 on debug connector */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpioa +#define AO_BOOT_APPLICATION_PIN 15 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +/* USB */ +#define HAS_USB 1 +#define AO_USB_DIRECTIO 0 +#define AO_PA11_PA12_RMP 1 + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From cfb91ec7ef6ef485d813af96a0f206bb7a2204dd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 5 Apr 2016 22:03:37 -0700 Subject: altos/detherm: Add ms5607 to detherm Signed-off-by: Keith Packard --- src/detherm/ao_detherm.c | 2 +- src/detherm/ao_pins.h | 6 ++++-- src/drivers/ao_ms5607.c | 6 +++++- src/stmf0/ao_arch_funcs.h | 22 +++++++++++----------- 4 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src/detherm') diff --git a/src/detherm/ao_detherm.c b/src/detherm/ao_detherm.c index cc013753..64dee586 100644 --- a/src/detherm/ao_detherm.c +++ b/src/detherm/ao_detherm.c @@ -35,8 +35,8 @@ void main(void) ao_usb_init(); ao_storage_init(); + ao_ms5607_init(); // ao_flight_init(); -// ao_ms5607_init(); ao_pwm_init(); ao_log_init(); ao_report_init(); diff --git a/src/detherm/ao_pins.h b/src/detherm/ao_pins.h index 9b623627..8cd4a9c4 100644 --- a/src/detherm/ao_pins.h +++ b/src/detherm/ao_pins.h @@ -72,11 +72,13 @@ /* MS5607 */ #define HAS_MS5607 1 -#define AO_MS5607_CS_PORT (&stm_gpiob) -#define AO_MS5607_CS_PIN 6 +#define AO_MS5607_CS_PORT (&stm_gpioa) +#define AO_MS5607_CS_PIN 0 #define AO_MS5607_SPI_INDEX AO_SPI_1_PB3_PB4_PB5 #define AO_MS5607_MISO_PORT (&stm_gpiob) #define AO_MS5607_MISO_PIN 4 +#define AO_MS5607_PRIVATE_PINS 1 +#define AO_MS5607_SPI_SPEED AO_SPI_SPEED_6MHz /* Flash */ diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 6098699e..ef31882e 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -24,9 +24,13 @@ __xdata struct ao_ms5607_prom ao_ms5607_prom; static __xdata uint8_t ms5607_configured; +#ifndef AO_MS5607_SPI_SPEED +#define AO_MS5607_SPI_SPEED AO_SPI_SPEED_FAST +#endif + static void ao_ms5607_start(void) { - ao_spi_get_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_CS, AO_MS5607_SPI_INDEX, AO_SPI_SPEED_FAST); + ao_spi_get_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_CS, AO_MS5607_SPI_INDEX, AO_MS5607_SPI_SPEED); } static void diff --git a/src/stmf0/ao_arch_funcs.h b/src/stmf0/ao_arch_funcs.h index 4e3ef018..ccfa3fc7 100644 --- a/src/stmf0/ao_arch_funcs.h +++ b/src/stmf0/ao_arch_funcs.h @@ -23,22 +23,22 @@ /* ao_spi_stm.c */ -/* PCLK is set to 16MHz (HCLK 32MHz, APB prescaler 2) */ +/* PCLK is set to 48MHz (HCLK 48MHz, HPRE 1, PPRE 1) */ -#define AO_SPI_SPEED_8MHz STM_SPI_CR1_BR_PCLK_2 -#define AO_SPI_SPEED_4MHz STM_SPI_CR1_BR_PCLK_4 -#define AO_SPI_SPEED_2MHz STM_SPI_CR1_BR_PCLK_8 -#define AO_SPI_SPEED_1MHz STM_SPI_CR1_BR_PCLK_16 -#define AO_SPI_SPEED_500kHz STM_SPI_CR1_BR_PCLK_32 -#define AO_SPI_SPEED_250kHz STM_SPI_CR1_BR_PCLK_64 -#define AO_SPI_SPEED_125kHz STM_SPI_CR1_BR_PCLK_128 -#define AO_SPI_SPEED_62500Hz STM_SPI_CR1_BR_PCLK_256 +#define AO_SPI_SPEED_24MHz STM_SPI_CR1_BR_PCLK_2 +#define AO_SPI_SPEED_12MHz STM_SPI_CR1_BR_PCLK_4 +#define AO_SPI_SPEED_6MHz STM_SPI_CR1_BR_PCLK_8 +#define AO_SPI_SPEED_3MHz STM_SPI_CR1_BR_PCLK_16 +#define AO_SPI_SPEED_1500kHz STM_SPI_CR1_BR_PCLK_32 +#define AO_SPI_SPEED_750kHz STM_SPI_CR1_BR_PCLK_64 +#define AO_SPI_SPEED_375kHz STM_SPI_CR1_BR_PCLK_128 +#define AO_SPI_SPEED_187500Hz STM_SPI_CR1_BR_PCLK_256 -#define AO_SPI_SPEED_FAST AO_SPI_SPEED_8MHz +#define AO_SPI_SPEED_FAST AO_SPI_SPEED_24MHz /* Companion bus wants something no faster than 200kHz */ -#define AO_SPI_SPEED_200kHz AO_SPI_SPEED_125kHz +#define AO_SPI_SPEED_200kHz AO_SPI_SPEED_187500Hz #define AO_SPI_CONFIG_1 0x00 #define AO_SPI_1_CONFIG_PA5_PA6_PA7 AO_SPI_CONFIG_1 -- cgit v1.2.3 From b8a19e83b7b1b8e2a1fcbdd58e41f9f974ae28ff Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 13 Apr 2016 06:16:01 -0700 Subject: altos/detherm: Add servo driver This just provides commands to test the servo with. Signed-off-by: Keith Packard --- src/detherm/Makefile | 1 + src/detherm/ao_detherm.c | 2 + src/detherm/ao_pins.h | 16 +++++-- src/drivers/ao_servo.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++ src/drivers/ao_servo.h | 41 ++++++++++++++++ 5 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 src/drivers/ao_servo.c create mode 100644 src/drivers/ao_servo.h (limited to 'src/detherm') diff --git a/src/detherm/Makefile b/src/detherm/Makefile index 35df6c96..6b0e0bf8 100644 --- a/src/detherm/Makefile +++ b/src/detherm/Makefile @@ -42,6 +42,7 @@ ALTOS_SRC = \ ao_ms5607.c \ ao_convert_pa.c \ ao_pwm.c \ + ao_servo.c \ ao_task.c \ ao_config.c \ ao_cmd.c \ diff --git a/src/detherm/ao_detherm.c b/src/detherm/ao_detherm.c index 64dee586..fba9195e 100644 --- a/src/detherm/ao_detherm.c +++ b/src/detherm/ao_detherm.c @@ -18,6 +18,7 @@ #include #include #include +#include void main(void) { @@ -38,6 +39,7 @@ void main(void) ao_ms5607_init(); // ao_flight_init(); ao_pwm_init(); + ao_servo_init(); ao_log_init(); ao_report_init(); ao_config_init(); diff --git a/src/detherm/ao_pins.h b/src/detherm/ao_pins.h index 8cd4a9c4..1c577b6e 100644 --- a/src/detherm/ao_pins.h +++ b/src/detherm/ao_pins.h @@ -98,10 +98,18 @@ #define AO_PWM_TIMER_ENABLE STM_RCC_APB1ENR_TIM3EN #define AO_PWM_TIMER_SCALE 32 -/* Motor */ +/* Servo */ -#define AO_MOTOR_DIR_GPIO (&stm_gpiob) -#define AO_MOTOR_DIR_PIN 0 -#define AO_MOTOR_SPEED_PWM 0 +#define AO_SERVO_DIR_PORT (&stm_gpiob) +#define AO_SERVO_DIR_BIT 0 +#define AO_SERVO_SPEED_PWM 0 + +/* limit 2 */ +#define AO_SERVO_LIMIT_FORE_PORT (&stm_gpiob) +#define AO_SERVO_LIMIT_FORE_BIT 6 + +/* limit 1 */ +#define AO_SERVO_LIMIT_BACK_PORT (&stm_gpiob) +#define AO_SERVO_LIMIT_BACK_BIT 7 #endif /* _AO_PINS_H_ */ diff --git a/src/drivers/ao_servo.c b/src/drivers/ao_servo.c new file mode 100644 index 00000000..b48a4112 --- /dev/null +++ b/src/drivers/ao_servo.c @@ -0,0 +1,118 @@ +/* + * Copyright © 2016 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include "ao_servo.h" +#include "ao_pwm.h" +#include "ao_exti.h" + +static uint8_t limit_wakeup; + +static void +ao_limit_isr(void) +{ + ao_wakeup(&limit_wakeup); +} + +static void +ao_limit_enable(uint8_t dir) +{ + if (dir == AO_SERVO_FORE) + ao_exti_enable(AO_SERVO_LIMIT_FORE_PORT, AO_SERVO_LIMIT_FORE_BIT); + else + ao_exti_enable(AO_SERVO_LIMIT_BACK_PORT, AO_SERVO_LIMIT_BACK_BIT); +} + +static void +ao_limit_disable(uint8_t dir) +{ + if (dir == AO_SERVO_FORE) + ao_exti_disable(AO_SERVO_LIMIT_FORE_PORT, AO_SERVO_LIMIT_FORE_BIT); + else + ao_exti_disable(AO_SERVO_LIMIT_BACK_PORT, AO_SERVO_LIMIT_BACK_BIT); +} + +static uint8_t +ao_limit_get(uint8_t dir) +{ + if (dir == AO_SERVO_FORE) + return !ao_gpio_get(AO_SERVO_LIMIT_FORE_PORT, AO_SERVO_LIMIT_FORE_BIT, PIN); + else + return !ao_gpio_get(AO_SERVO_LIMIT_BACK_PORT, AO_SERVO_LIMIT_BACK_BIT, PIN); +} + +void +ao_servo_run(uint16_t speed, uint8_t dir, uint16_t timeout) +{ + printf ("speed %d dir %d\n", speed, dir); + + /* Turn on the motor */ + ao_gpio_set(AO_SERVO_DIR_PORT, AO_SERVO_DIR_BIT, AO_SERVO_DIR_PIN, dir); + ao_pwm_set(AO_SERVO_SPEED_PWM, speed); + + /* Wait until the limit sensor is triggered */ + ao_arch_block_interrupts(); + ao_limit_enable(dir); + while (!ao_limit_get(dir)) + if (ao_sleep_for(&limit_wakeup, timeout)) + break; + ao_limit_disable(dir); + ao_arch_release_interrupts(); + + /* Turn off the motor */ + ao_pwm_set(AO_SERVO_SPEED_PWM, 0); +} + +#define init_limit(p,b) do { \ + ao_enable_port(p); \ + ao_exti_setup(p, b, \ + AO_EXTI_MODE_PULL_UP|AO_EXTI_MODE_FALLING|AO_EXTI_PRIORITY_MED, \ + ao_limit_isr); \ + } while (0) + + +static void +ao_servo_cmd(void) +{ + uint8_t dir; + uint16_t speed; + + ao_cmd_decimal(); + dir = ao_cmd_lex_u32; + ao_cmd_decimal(); + speed = ao_cmd_lex_u32; + if (ao_cmd_status != ao_cmd_success) + return; + + printf("Run servo %d\n", dir); + ao_servo_run(speed, dir, AO_MS_TO_TICKS(200)); +} + +static const struct ao_cmds ao_servo_cmds[] = { + { ao_servo_cmd, "S \0Run servo in indicated direction" }, + { 0, NULL }, +}; + + +void +ao_servo_init(void) +{ + init_limit(AO_SERVO_LIMIT_FORE_PORT, AO_SERVO_LIMIT_FORE_BIT); + init_limit(AO_SERVO_LIMIT_BACK_PORT, AO_SERVO_LIMIT_BACK_BIT); + ao_enable_output(AO_SERVO_DIR_PORT, AO_SERVO_DIR_BIT, AO_SERVO_DIR_PIN, 0); + ao_cmd_register(&ao_servo_cmds[0]); +} diff --git a/src/drivers/ao_servo.h b/src/drivers/ao_servo.h new file mode 100644 index 00000000..e1df347a --- /dev/null +++ b/src/drivers/ao_servo.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2016 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_SERVO_H_ +#define _AO_SERVO_H_ + +void +ao_servo_run(uint16_t speed, uint8_t dir, uint16_t timeout); + +void +ao_servo_init(void); + +#define AO_SERVO_FORE 0 +#define AO_SERVO_BACK 1 + +/* To configure the servo: + * + * #define AO_SERVO_PWM + * #define AO_SERVO_DIR_PORT + * #define AO_SERVO_DIR_PIN + * #define AO_SERVO_LIMIT_FORE_PORT + * #define AO_SERVO_LIMIT_FORE_PIN + * #define AO_SERVO_LIMIT_BACK_PORT + * #define AO_SERVO_LIMIT_BACK_PIN + */ + +#endif /* _AO_SERVO_H_ */ -- cgit v1.2.3