mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 15:03:08 +02:00
86 lines
1.6 KiB
C
86 lines
1.6 KiB
C
/*
|
|
* 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"
|
|
|
|
#include "config.h"
|
|
#include "io.h"
|
|
|
|
|
|
static void init_io(void)
|
|
{
|
|
P0SKIP = 0xff;
|
|
P1SKIP = 0xff;
|
|
P2SKIP = 0xff;
|
|
|
|
LED_MAIN_R_MODE |= 1 << LED_MAIN_R_BIT;
|
|
LED_MAIN_G_MODE |= 1 << LED_MAIN_G_BIT;
|
|
LED_CH1_R_MODE |= 1 << LED_CH1_R_BIT;
|
|
LED_CH1_G_MODE |= 1 << LED_CH1_G_BIT;
|
|
LED_CH2_R_MODE |= 1 << LED_CH2_R_BIT;
|
|
LED_CH2_G_MODE |= 1 << LED_CH2_G_BIT;
|
|
CH1_RELAY = 0;
|
|
CH2_RELAY = 0;
|
|
CH1_RELAY_MODE |= 1 << CH1_RELAY_BIT;
|
|
CH2_RELAY_MODE |= 1 << CH2_RELAY_BIT;
|
|
|
|
/* @@@ we need this while using the boot loader of cntr */
|
|
CH1_OPT_MODE &= ~(1 << CH1_OPT_BIT);
|
|
CH2_OPT_MODE &= ~(1 << CH2_OPT_BIT);
|
|
}
|
|
|
|
|
|
void main(void)
|
|
{
|
|
init_io();
|
|
|
|
usb_init();
|
|
// ep0_init();
|
|
|
|
while (1) {
|
|
if (!BUT_MAIN) {
|
|
LED_MAIN_R = 1;
|
|
LED_MAIN_G = 0;
|
|
} else {
|
|
LED_MAIN_R = 0;
|
|
LED_MAIN_G = 1;
|
|
}
|
|
if (!BUT_CH1) {
|
|
LED_CH1_R = 1;
|
|
LED_CH1_G = 0;
|
|
CH1_RELAY = 1;
|
|
CH1_OPT = 0;
|
|
} else {
|
|
LED_CH1_R = 0;
|
|
LED_CH1_G = 1;
|
|
CH1_RELAY = 0;
|
|
CH1_OPT = 1;
|
|
}
|
|
if (!BUT_CH2) {
|
|
LED_CH2_R = 1;
|
|
LED_CH2_G = 0;
|
|
CH2_RELAY = 1;
|
|
CH2_OPT = 0;
|
|
} else {
|
|
LED_CH2_R = 0;
|
|
LED_CH2_G = 1;
|
|
CH2_RELAY = 0;
|
|
CH2_OPT = 1;
|
|
}
|
|
usb_poll();
|
|
}
|
|
}
|