2011-09-03 12:14:29 +03:00
|
|
|
/*
|
|
|
|
* labsw.c - Lab Switch initialization and main loop
|
|
|
|
*
|
|
|
|
* Written 2011 by Werner Almesberger
|
|
|
|
* Copyright 2011 Werner Almesberger
|
|
|
|
*
|
|
|
|
* 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; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "regs.h"
|
|
|
|
#include "usb.h"
|
|
|
|
|
2011-09-03 18:33:43 +03:00
|
|
|
#include "config.h"
|
|
|
|
#include "io.h"
|
|
|
|
|
2011-09-03 12:14:29 +03:00
|
|
|
|
|
|
|
static void init_io(void)
|
|
|
|
{
|
2011-09-03 18:33:43 +03:00
|
|
|
P0SKIP = 0xff;
|
|
|
|
P1SKIP = 0xff;
|
|
|
|
P2SKIP = 0xff;
|
|
|
|
|
|
|
|
LED_MAIN_R_MODE |= 1 << LED_MAIN_R_BIT;
|
|
|
|
LED_MAIN_G_MODE |= 1 << LED_MAIN_G_BIT;
|
|
|
|
CH1_RELAY = 0;
|
|
|
|
CH2_RELAY = 0;
|
|
|
|
CH1_RELAY_MODE |= 1 << CH1_RELAY_BIT;
|
|
|
|
CH2_RELAY_MODE |= 1 << CH2_RELAY_BIT;
|
2011-09-03 12:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
init_io();
|
|
|
|
|
|
|
|
usb_init();
|
|
|
|
// ep0_init();
|
|
|
|
|
|
|
|
while (1) {
|
2011-09-03 18:33:43 +03:00
|
|
|
if (!BUT_MAIN) {
|
|
|
|
LED_MAIN_R = 1;
|
|
|
|
LED_MAIN_G = 0;
|
|
|
|
CH1_RELAY = 1;
|
|
|
|
CH2_RELAY = 1;
|
|
|
|
} else {
|
|
|
|
LED_MAIN_R = 0;
|
|
|
|
LED_MAIN_G = 1;
|
|
|
|
CH1_RELAY = 0;
|
|
|
|
CH2_RELAY = 0;
|
|
|
|
}
|
2011-09-03 12:14:29 +03:00
|
|
|
usb_poll();
|
|
|
|
}
|
|
|
|
}
|