Line 35... |
Line 35... |
//
|
//
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
//
|
//
|
|
#include <stdio.h>
|
|
|
|
#include "artyboard.h"
|
#include "zipcpu.h"
|
#include "zipcpu.h"
|
#include "zipsys.h"
|
#include "zipsys.h"
|
#include "artyboard.h"
|
|
|
#define sys _sys
|
|
|
void idle_task(void) {
|
void idle_task(void) {
|
while(1)
|
while(1)
|
zip_idle();
|
zip_idle();
|
}
|
}
|
Line 50... |
Line 54... |
zip->z_pic = DALLPIC|mask;
|
zip->z_pic = DALLPIC|mask;
|
zip->z_pic = EINT(mask);
|
zip->z_pic = EINT(mask);
|
zip_rtu();
|
zip_rtu();
|
}
|
}
|
|
|
|
|
void main(int argc, char **argv) {
|
void main(int argc, char **argv) {
|
const unsigned red = 0x0ff0000, green = 0x0ff00, blue = 0x0ff,
|
const unsigned red = 0x0ff0000, green = 0x0ff00, blue = 0x0ff,
|
white = 0x070707, black = 0, dimgreen = 0x1f00,
|
white = 0x070707, black = 0, dimgreen = 0x1f00,
|
second = CLOCKFREQHZ;
|
second = CLOCKFREQHZ;
|
int i, sw;
|
int i, sw;
|
Line 63... |
Line 66... |
for(i=0; i<15; i++)
|
for(i=0; i<15; i++)
|
user_context[i] = 0;
|
user_context[i] = 0;
|
user_context[15] = (unsigned)idle_task;
|
user_context[15] = (unsigned)idle_task;
|
zip_restore_context(user_context);
|
zip_restore_context(user_context);
|
|
|
|
printf("Starting exstartup\r\n");
|
|
|
for(i=0; i<4; i++)
|
for(i=0; i<4; i++)
|
sys->io_clrled[i] = red;
|
_sys->io_b.i_clrled[i] = red;
|
sys->io_ledctrl = 0x0ff;
|
sys->io_b.i_leds = 0x0ff;
|
|
|
// Clear the PIC
|
// Clear the PIC
|
//
|
//
|
// Acknowledge all interrupts, turn off all interrupts
|
// Acknowledge all interrupts, turn off all interrupts
|
//
|
//
|
zip->z_pic = CLEARPIC;
|
zip->z_pic = CLEARPIC;
|
while(sys->io_pwrcount < (second >> 4))
|
while(sys->io_b.i_pwrcount < (second >> 4))
|
;
|
;
|
|
|
// Repeating timer, every 250ms
|
// Repeating timer, every 250ms
|
zip->z_tma = TMR_INTERVAL | (second/4);
|
zip->z_tma = TMR_INTERVAL | (second/4);
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
sys->io_clrled[0] = green;
|
sys->io_b.i_clrled[0] = green;
|
sys->io_ledctrl = 0x010;
|
sys->io_b.i_leds = 0x010;
|
|
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
sys->io_clrled[0] = dimgreen;
|
sys->io_b.i_clrled[0] = dimgreen;
|
sys->io_clrled[1] = green;
|
sys->io_b.i_clrled[1] = green;
|
sys->io_scope[0].s_ctrl = SCOPE_NO_RESET | 32;
|
sys->io_scope[0].s_ctrl = WBSCOPE_NO_RESET | 32;
|
sys->io_ledctrl = 0x020;
|
sys->io_b.i_leds = 0x020;
|
|
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
sys->io_clrled[1] = dimgreen;
|
sys->io_b.i_clrled[1] = dimgreen;
|
sys->io_clrled[2] = green;
|
sys->io_b.i_clrled[2] = green;
|
sys->io_ledctrl = 0x040;
|
sys->io_b.i_leds = 0x040;
|
|
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
sys->io_clrled[2] = dimgreen;
|
sys->io_b.i_clrled[2] = dimgreen;
|
sys->io_clrled[3] = green;
|
sys->io_b.i_clrled[3] = green;
|
sys->io_ledctrl = 0x080;
|
sys->io_b.i_leds = 0x080;
|
|
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
sys->io_clrled[3] = dimgreen;
|
sys->io_b.i_clrled[3] = dimgreen;
|
|
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
for(i=0; i<4; i++)
|
for(i=0; i<4; i++)
|
sys->io_clrled[i] = black;
|
sys->io_b.i_clrled[i] = black;
|
|
|
// Wait one second ...
|
// Wait one second ...
|
for(i=0; i<4; i++)
|
for(i=0; i<4; i++)
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
sw = sys->io_btnsw & 0x0f;
|
sw = sys->io_b.i_btnsw & 0x0f;
|
for(int i=0; i<4; i++)
|
for(int i=0; i<4; i++)
|
sys->io_clrled[i] = (sw & (1<<i)) ? white : black;
|
sys->io_b.i_clrled[i] = (sw & (1<<i)) ? white : black;
|
|
|
|
|
// Wait another two seconds ...
|
// Wait another two seconds ...
|
for(i=0; i<8; i++)
|
for(i=0; i<8; i++)
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
// Blink all the LEDs
|
// Blink all the LEDs
|
// First turn them on
|
// First turn them on
|
sys->io_ledctrl = 0x0ff;
|
sys->io_b.i_leds = 0x0ff;
|
// Then wait a quarter second
|
// Then wait a quarter second
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
// Then turn the back off
|
// Then turn the back off
|
sys->io_ledctrl = 0x0f0;
|
sys->io_b.i_leds = 0x0f0;
|
// and wait another quarter second
|
// and wait another quarter second
|
wait_on_interrupt(SYSINT_TMA);
|
wait_on_interrupt(SYSINT_TMA);
|
|
|
// Now, read buttons, and flash an LED on any button being held
|
// Now, read buttons, and flash an LED on any button being held
|
// down ... ? neat?
|
// down ... ? neat?
|
Line 145... |
Line 150... |
zip->z_pic = EINT(SYSINT_TMA)|SYSINT_TMA;
|
zip->z_pic = EINT(SYSINT_TMA)|SYSINT_TMA;
|
// If the button is pressed, toggle the LED
|
// If the button is pressed, toggle the LED
|
// Otherwise, turn the LED off.
|
// Otherwise, turn the LED off.
|
//
|
//
|
// First, get all the pressed buttons
|
// First, get all the pressed buttons
|
btn = (sys->io_btnsw >> 4) & 0x0f;
|
btn = (sys->io_b.i_btnsw >> 4) & 0x0f;
|
// Now, acknowledge the button presses that we just read
|
// Now, acknowledge the button presses that we just read
|
sys->io_btnsw = (btn<<4);
|
sys->io_b.i_btnsw = (btn<<4);
|
|
|
// Of any LEDs that are on, or buttons on, toggle their values
|
// Of any LEDs that are on, or buttons on, toggle their values
|
ledc = (sys->io_ledctrl)&0x0f;
|
ledc = (sys->io_b.i_leds)&0x0f;
|
ledc = (ledc | btn)&0x0f ^ ledc;
|
ledc = (ledc | btn)&0x0f ^ ledc;
|
// Make sure we set everything
|
// Make sure we set everything
|
ledc |= 0x0f0;
|
ledc |= 0x0f0;
|
// Now issue the command
|
// Now issue the command
|
sys->io_ledctrl = ledc;
|
sys->io_b.i_leds = ledc;
|
// That way, at the end, the toggle will leave them in the
|
// That way, at the end, the toggle will leave them in the
|
// off position.
|
// off position.
|
// sys->io_ledctrl = 0xf0 | ((sys->io_ledctrl&1)^1);
|
// sys->io_b.i_leds = 0xf0 | ((sys->io_b.i_leds&1)^1);
|
|
|
sw = sys->io_btnsw & 0x0f;
|
sw = sys->io_b.i_btnsw & 0x0f;
|
for(int i=0; i<4; i++)
|
for(int i=0; i<4; i++)
|
sys->io_clrled[i] = (sw & (1<<i)) ? white : black;
|
sys->io_b.i_clrled[i] = (sw & (1<<i)) ? white : black;
|
|
|
}
|
}
|
|
|
zip_halt();
|
zip_halt();
|
}
|
}
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|