change to more generic IO mapping

This commit is contained in:
King Kévin 2015-02-28 13:21:33 +01:00
parent 76385bc076
commit 8de6b2c199
2 changed files with 9 additions and 27 deletions

9
main.c
View File

@ -12,6 +12,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include <stdint.h> // Standard Integer Types #include <stdint.h> // Standard Integer Types
#include <stdio.h> // Standard IO facilities #include <stdio.h> // Standard IO facilities
#include <stdlib.h> // General utilities #include <stdlib.h> // General utilities
@ -31,19 +32,19 @@
/* switch off LED */ /* switch off LED */
void led_off(void) void led_off(void)
{ {
PORTB &= ~(1<<LED); // remove power to LED LED_PORT &= ~(1<<LED_IO); // remove power to LED
} }
/* switch on LED */ /* switch on LED */
void led_on(void) void led_on(void)
{ {
PORTB |= (1<<LED); // provide power to LED LED_PORT |= (1<<LED_IO); // provide power to LED
} }
/* toggle LED */ /* toggle LED */
void led_toggle(void) void led_toggle(void)
{ {
PINB |= (1<<LED); LED_PIN |= (1<<LED_IO);
} }
/* disable watchdog when booting */ /* disable watchdog when booting */
@ -66,7 +67,7 @@ void io_init(void)
/* gpio */ /* gpio */
/* LED */ /* LED */
DDRB |= (1<<LED); // LED is driven by pin (set as output) LED_DDR |= (1<<LED_IO); // LED is driven by pin (set as output)
led_off(); led_off();
sei(); /* enable interrupts */ sei(); /* enable interrupts */

27
main.h
View File

@ -12,31 +12,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
/* This is the main part of the waschkarte auflader program.
*/
/* peripherals */ /* peripherals */
/* LED to indicate scale reading /* LED to indicate scale reading
* pin: PB5, LED L * pin: PB5, LED L
*/ */
#define LED PB5 #define LED_PORT PORTB
/* high when the scale is on #define LED_DDR DDRB
* pin: PD5, PCINT21, D5 #define LED_PIN PINB
*/ #define LED_IO PB5
#define SCALE_ON PD5
/* PWM weight signal
* PWM frequency is ~3Hz
* high time increases with increasing weight (propotionnally)
* low time decreases with increasing weight
* signal level is 1V
* positive pin of analog comparator used to measure PWM
* pin: PD6, AIN0, D6
*/
#define SCALE_PWM PD6
/* negative pin of analog comparator
* set at 0.2-0.8V using voltage divider
* used to detect PWM signal change
* pin: PD7, AIN1, D7
*/
#define REF_PWM PD7