From 324c5ba9098c1010d0aa8c1e26b95509878ce9f2 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Tue, 11 Oct 2011 21:50:49 +0200 Subject: Mini-Octopus build from r@171 --- firmware/io.h | 269 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 firmware/io.h (limited to 'firmware/io.h') diff --git a/firmware/io.h b/firmware/io.h new file mode 100644 index 0000000..f86314f --- /dev/null +++ b/firmware/io.h @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2007 Embedded Projects (http://www.embedded-projecs.net) + * Author: Benedikt Sauter +#include + + +#define OX_PIN1 PINE +#define OX_PIN2 PINE +#define OX_PIN3 PINE +#define OX_PIN4 PINB +#define OX_PIN5 PINB +#define OX_PIN6 PINB +#define OX_PIN7 PINB +#define OX_PIN8 PINB +#define OX_PIN9 PINB +#define OX_PIN10 PINB +#define OX_PIN11 PINB +#define OX_PIN12 PIND +#define OX_PIN13 PIND +#define OX_PIN14 PIND +#define OX_PIN15 PIND +#define OX_PIN16 PIND +#define OX_PIN17 PIND +#define OX_PIN18 PIND +#define OX_PIN19 PIND + +#define OX_PIN26 PINC +#define OX_PIN27 PINC +#define OX_PIN28 PINC +#define OX_PIN29 PINC +#define OX_PIN30 PINC +#define OX_PIN31 PINC +#define OX_PIN32 PINC +#define OX_PIN33 PINF +#define OX_PIN34 PINF +#define OX_PIN35 PINF +#define OX_PIN36 PINF +#define OX_PIN37 PINF +#define OX_PIN38 PINF +#define OX_PIN39 PINF +#define OX_PIN40 PINF +#define OX_PIN41 PINE +#define OX_PIN42 PINE +#define OX_PIN43 PINE +#define OX_PIN44 PINE + +#define OX_PORT1 PORTE +#define OX_PORT2 PORTE +#define OX_PORT3 PORTE +#define OX_PORT4 PORTB +#define OX_PORT5 PORTB +#define OX_PORT6 PORTB +#define OX_PORT7 PORTB +#define OX_PORT8 PORTB +#define OX_PORT9 PORTB +#define OX_PORT10 PORTB +#define OX_PORT11 PORTB +#define OX_PORT12 PORTD +#define OX_PORT13 PORTD +#define OX_PORT14 PORTD +#define OX_PORT15 PORTD +#define OX_PORT16 PORTD +#define OX_PORT17 PORTD +#define OX_PORT18 PORTD +#define OX_PORT19 PORTD + +#define OX_PORT26 PORTC +#define OX_PORT27 PORTC +#define OX_PORT28 PORTC +#define OX_PORT29 PORTC +#define OX_PORT30 PORTC +#define OX_PORT31 PORTC +#define OX_PORT32 PORTC +#define OX_PORT33 PORTF +#define OX_PORT34 PORTF +#define OX_PORT35 PORTF +#define OX_PORT36 PORTF +#define OX_PORT37 PORTF +#define OX_PORT38 PORTF +#define OX_PORT39 PORTF +#define OX_PORT40 PORTF +#define OX_PORT41 PORTE +#define OX_PORT42 PORTE +#define OX_PORT43 PORTE +#define OX_PORT44 PORTE + +#define OX_DDR1 DDRE +#define OX_DDR2 DDRE +#define OX_DDR3 DDRE +#define OX_DDR4 DDRB +#define OX_DDR5 DDRB +#define OX_DDR6 DDRB +#define OX_DDR7 DDRB +#define OX_DDR8 DDRB +#define OX_DDR9 DDRB +#define OX_DDR10 DDRB +#define OX_DDR11 DDRB +#define OX_DDR12 DDRD +#define OX_DDR13 DDRD +#define OX_DDR14 DDRD +#define OX_DDR15 DDRD +#define OX_DDR16 DDRD +#define OX_DDR17 DDRD +#define OX_DDR18 DDRD +#define OX_DDR19 DDRD + +#define OX_DDR26 DDRC +#define OX_DDR27 DDRC +#define OX_DDR28 DDRC +#define OX_DDR29 DDRC +#define OX_DDR30 DDRC +#define OX_DDR31 DDRC +#define OX_DDR32 DDRC +#define OX_DDR33 DDRF +#define OX_DDR34 DDRF +#define OX_DDR35 DDRF +#define OX_DDR36 DDRF +#define OX_DDR37 DDRF +#define OX_DDR38 DDRF +#define OX_DDR39 DDRF +#define OX_DDR40 DDRF +#define OX_DDR41 DDRE +#define OX_DDR42 DDRE +#define OX_DDR43 DDRE +#define OX_DDR44 DDRE + + +#define OX_P1 PE5 +#define OX_P2 PE6 +#define OX_P3 PE7 +#define OX_P4 PB0 +#define OX_P5 PB1 +#define OX_P6 PB2 +#define OX_P7 PB3 +#define OX_P8 PB4 +#define OX_P9 PB5 +#define OX_P10 PB6 +#define OX_P11 PB7 +#define OX_P12 PD0 +#define OX_P13 PD1 +#define OX_P14 PD2 +#define OX_P15 PD3 +#define OX_P16 PD4 +#define OX_P17 PD5 +#define OX_P18 PD6 +#define OX_P19 PD7 + +#define OX_P26 PC0 +#define OX_P27 PC1 +#define OX_P28 PC2 +#define OX_P29 PC3 +#define OX_P30 PC4 +#define OX_P31 PC5 +#define OX_P32 PC6 +#define OX_P33 PF7 +#define OX_P34 PF6 +#define OX_P35 PF5 +#define OX_P36 PF4 +#define OX_P37 PF3 +#define OX_P38 PF2 +#define OX_P39 PF1 +#define OX_P40 PF0 +#define OX_P41 PE0 +#define OX_P42 PE1 +#define OX_P43 PE2 +#define OX_P44 PE3 + + + +void io_parser(char *buf); + +uint8_t io_init(uint8_t pin); +void io_init_usb(uint8_t pin); + +uint8_t io_init_port(uint8_t port); +void io_init_port_usb(uint8_t port); + +uint8_t io_set_port_direction_out(uint8_t port,uint8_t mask); +uint8_t io_set_port_direction_in(uint8_t port, uint8_t mask); +uint8_t io_set_port_direction_tri(uint8_t port, uint8_t mask); + + +void io_set_port_direction_out_usb (uint8_t port, uint8_t mask); +void io_set_port_direction_in_usb(uint8_t port, uint8_t mask); +void io_set_port_direction_tri_usb(uint8_t port, uint8_t mask); + +uint8_t io_set_pin_direction_out(uint8_t pin); +uint8_t io_set_pin_direction_in(uint8_t pin); +uint8_t io_set_pin_direction_tri(uint8_t pin); + +void io_set_pin_direction_out_usb(uint8_t pin); +void io_set_pin_direction_in_usb(uint8_t pin); +void io_set_pin_direction_tri_usb(uint8_t pin); + +uint8_t io_get_port (uint8_t port, uint8_t *pvalue); +void io_get_port_usb (uint8_t port); + + +uint8_t io_set_port(uint8_t port, uint8_t value); +void io_set_port_usb (uint8_t port, uint8_t value); + +uint8_t io_set_pin(uint8_t pin, uint8_t value); +void io_set_pin_usb(uint8_t pin, uint8_t value); + +uint8_t io_get_pin(uint8_t pin, uint8_t *value); +void io_get_pin_usb(uint8_t pin); + + +#define PORT(port,pin) (PORT##port) +#define DDR(port,pin) (DDR##port) +#define PIN(port,pin) (PIN##port) +#define PIN_MASK(port,pin) (1<<(pin)) + +/* Set a pin */ +#define SETPIN(pindef) PORT pindef |= PIN_MASK pindef + +/* Clear a pin */ +#define CLRPIN(pindef) PORT pindef &= ~PIN_MASK pindef + +/* Get pin value */ +#define GETPIN(pindef) (PIN pindef & PIN_MASK pindef) + +/* Toggle a pin */ +#define TOGGLEPIN(pindef) PIN pindef |= PIN_MASK pindef + +/* Set a IO to output */ +#define SET_DDR_OUT(pindef) DDR pindef |= PIN_MASK pindef + +/* Set a IO to input */ +#define SET_DDR_IN(pindef) DDR pindef &= ~PIN_MASK pindef + + + +#endif /* IO_H */ -- cgit v1.2.1