URL
https://opencores.org/ocsvn/s6soc/s6soc/trunk
Subversion Repositories s6soc
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 14 to Rev 15
- ↔ Reverse comparison
Rev 14 → Rev 15
/s6soc/trunk/sw/dev/rtcsim.c
0,0 → 1,153
//////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: rtcsim.c |
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: Since we lost the real-time clock on board due to space |
// constraints, this unit attempts to replace that functionality |
// in software. |
// |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): 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 3 of the License, or (at |
// your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, but WITHOUT |
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with this program. (It's in the $(ROOT)/doc directory, run make with no |
// target there if the PDF file isn't present.) If not, see |
// <http://www.gnu.org/licenses/> for a copy. |
// |
// License: GPL, v3, as defined and found on www.gnu.org, |
// http://www.gnu.org/licenses/gpl.html |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
#include "rtcsim.h" |
|
unsigned rtcclock, rtcalarm, rtcdate; |
#ifdef ZIPOS |
SEMAPHORE SEMDATE, SEMCLOCK; |
#endif |
|
unsigned rtcnext(unsigned now) { |
now = now+1; |
if ((now & 0x0f)>=0x0a) { |
now += 0x06; // Seconds |
if ((now & 0x0f0)> 0x050) { |
now += 0x0a0; // Increment minutes |
if ((now & 0x0f00)>= 0x0a00) { |
now += 0x0600; |
if ((now & 0x0f000)> 0x05000) { |
now += 0x0a000; // Increment hours |
if ((now & 0x0f0000)>= 0x0a0000) |
now += 0x060000; |
if (now >= 0x0240000) |
now = 0; |
} |
} |
} |
} |
|
return now; |
} |
|
static const int days_per_month[] = { |
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
}; |
|
unsigned rtcdatenext(unsigned today) { |
int dy, mo; |
|
dy = (today&0x0f)+((today>>4)&0x03)*10; |
mo = ((today>>8)&0x0f)+(today&0x0100)?10:0; |
dy = dy+1; |
if ((mo>12)||(dy > days_per_month[mo-1])) { |
if (mo == 2) { |
// If its a leap year |
// If it is divisible by four |
// But not a century year |
// unless it's a fourth century yr |
int tst; |
if ((today&0x0ff0000) == 0) { |
tst = (today >> 24) & 0x03f; |
} else { |
tst = (today >> 20) & 0x0ff; |
} tst &= 0x013; |
if ((tst==0)||(tst==0x012)) { |
// Divisible by four |
if (dy >= 29) |
dy = 1; |
} else dy = 1; |
} else dy = 1; |
} if (dy == 1) { |
// Set to the first day of the month |
today &= (~0x0ff); |
today |= 1; |
mo++; |
if (mo > 12) { |
// Set to the first month of the year |
today &= ~(0x0ff00); |
today |= 0x0100; |
// Increment the year |
today += 0x010000; |
if ((today & 0x0f0000)>=0x0a0000) { |
today += 0x060000; |
if ((today& 0x0f00000)>= 0x0a00000) { |
today += 0x0600000; |
if ((today & 0x0f000000)>= 0x0a000000) { |
today += 0x06000000; |
if ((today & 0x0f0000000)>=0x0a0000000) |
today += 0x060000000; |
} |
} |
} |
} |
} else { |
today += 1; |
if ((today & 0x0f)>=0x0a) |
today += 0x06; |
} |
|
return today; |
} |
|
#ifdef ZIPOS |
void rtctask(void) { |
rtcdate = 0x20160430; |
rtctime = 0; |
while(1) { |
unsigned event = wait(SWINT_RTCPPS); |
if (event&INT_TIMA) { |
unsigned v, nextevent = SWINT_PPS; |
semget(SEMCLOCK); |
rtctime = v = rtcnext(rtctime); |
semput(SEMCLOCK); |
if (v == rtcalarm) |
nextevent |= SWINT_ALARM; |
if (v == 0) { |
semget(SEMDATE); |
rtcdate = rtcdatenext(rtcdate); |
semput(SEMDATE); |
|
nextevent |= SWINT_PPD; |
} swthrow(nextevent); |
} |
} |
} |
#endif |
|
/s6soc/trunk/sw/dev/doorbell.c
4,7 → 4,7
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: To test the PWM device by playing a doorbell sound every five |
// Purpose: To test the PWM device by playing a doorbell sound every ten |
// seconds. |
// |
// Creator: Dan Gisselquist, Ph.D. |
/s6soc/trunk/sw/dev/doorbell2.c
0,0 → 1,368
//////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: doorbell2.c |
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: A modification to the original doorbell.c program. |
// seconds. Listening to that test is ... getting old. |
// |
// Let's let this one do the following: |
// 1. Display the time on the display (it will be impossible to |
// change the time, sadly, but we can at least display it.) |
// 2. On button press ... |
// - Play the doorbell sound |
// - Display "Doorbell!\n" on the Display, clearing the |
// time |
// - Send "Doorbell\n" to the UART, and then keeping the |
// UART silent for 30 seconds. |
// 4. Send the time to the UART as well, but only once a minute. |
// (and that if the Doorbell hasn't been rung in the last |
// 30 seconds ...) |
// |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): 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 3 of the License, or (at |
// your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, but WITHOUT |
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with this program. (It's in the $(ROOT)/doc directory, run make with no |
// target there if the PDF file isn't present.) If not, see |
// <http://www.gnu.org/licenses/> for a copy. |
// |
// License: GPL, v3, as defined and found on www.gnu.org, |
// http://www.gnu.org/licenses/gpl.html |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
#include "asmstartup.h" |
#include "board.h" |
#include "rtcsim.h" |
#include "display.h" |
|
#include "samples.c" |
|
void zip_halt(void); |
|
void build_dpymsg(char *msg, unsigned clkval); |
void build_uartmsg(char *msg, unsigned clkval); |
void showval(int val); |
void txval(int val); |
|
void entry(void) { |
register IOSPACE *sys = (IOSPACE *)0x0100; |
char dpymsg[16], *dpyptr; |
char uartmsg[40], *uartptr; |
int newmsgtime = 0, leastmsgtime = -1, lstmsgtime = 0; |
|
dpymsg[0] = 0; |
dpyptr = dpymsg; |
|
uartmsg[0] = 0; |
build_uartmsg(uartmsg, 0); |
uartptr = uartmsg; |
|
sys->io_timb = 0; |
sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts |
|
sys->io_spio = 0x0f4; |
newmsgtime = sys->io_tima; |
leastmsgtime = -1; |
lstmsgtime = newmsgtime; |
while(1) { |
int seconds, pic; |
const int *sptr; |
|
// LED's off ... nothing to report |
sys->io_spio = 0x0f0; |
|
// Turn the audio off (initially) |
sys->io_pwm_audio = 0x0018000; |
|
// Set for one ticks per second, 80M clocks per tick |
sys->io_tima = TM_ONE_SECOND | TM_REPEAT; |
|
// We start by waiting for a doorbell |
while(((pic=sys->io_pic) & INT_BUTTON)==0) { |
if (uartmsg[10] == 0) { |
sys->io_spio = 0x0fe; |
zip_halt(); |
} |
if (pic & INT_TIMA) {// top of second |
sys->io_pic = INT_TIMA; |
rtcclock = rtcnext(rtcclock); |
|
// Turn all LED off (again) |
sys->io_spio = 0x0f0; |
if (*dpyptr == '\0') { |
// Build a message for the display |
build_dpymsg(dpymsg, rtcclock); |
dpyptr = dpymsg; |
}if(((rtcclock & 0x0ff)==0)&&(*uartptr=='\0')){ |
build_uartmsg(uartmsg, rtcclock); |
uartptr = uartmsg; |
|
// Turn one LED on--top of minute |
sys->io_spio = 0x0f1; |
newmsgtime = sys->io_tima; |
lstmsgtime = -1; |
leastmsgtime = -1; |
} |
} |
/* |
if (uartmsg[10] == 0) { |
sys->io_spio = 0x0fc; |
zip_halt(); |
} |
*/ |
if (*uartptr) { |
if (pic & INT_UARTTX) { |
sys->io_uart = *uartptr++; |
sys->io_spio = 0x22; |
sys->io_pic = INT_UARTTX; |
if (uartptr > &uartmsg[13]) { |
sys->io_spio = 0x0fd; |
zip_halt(); |
} |
|
if (lstmsgtime != -1) { |
int tmp; |
tmp = (lstmsgtime-sys->io_tima); |
if ((leastmsgtime<0)||(tmp<leastmsgtime)) |
leastmsgtime = tmp; |
} lstmsgtime = sys->io_tima; |
} |
} else { |
sys->io_spio = 0x20; |
/* |
if (newmsgtime != 0) { |
int thistime = sys->io_tima; |
thistime = newmsgtime - thistime; |
showval(thistime); |
txval(thistime); |
txval(leastmsgtime); |
txval(lstmsgtime); |
zip_halt(); |
newmsgtime = 0; |
} |
for(int i=0; i<12; i++) |
if (uartmsg[i] == 0) { |
sys->io_spio = i+0xf0; |
zip_halt(); |
} |
*/ |
} |
if (*dpyptr) { |
// This will take a long time. It should be an |
// interruptable task ... but, sigh, we're not |
// there yet. |
dispchar(*dpyptr++); |
sys->io_spio = 0x44; |
} else { |
sys->io_spio = 0x40; |
} // sys->io_pic = (pic & (INT_TIMA|INT_UARTTX)); |
} |
|
// DOORBELL!!!!!! |
// Set the Display message |
dpymsg[0] = (0x1b<<24)|('['<<16)|('j'<<8)|'D'; |
dpymsg[1] = ('o'<<24)|('o'<<16)|('r'<<8)|'b'; |
dpymsg[2] = ('e'<<24)|('l'<<16)|('l'<<8)|'!'; |
dpymsg[3] = 0; |
dpyptr = dpymsg; |
// And the UART message / 18 characters |
uartptr = uartmsg; |
*uartptr++ = '\r'; *uartptr++ = '\n'; |
*uartptr++ = 'D'; |
*uartptr++ = 'o'; |
*uartptr++ = 'o'; |
*uartptr++ = 'r'; |
*uartptr++ = 'b'; |
*uartptr++ = 'e'; |
*uartptr++ = 'l'; |
*uartptr++ = 'l'; |
*uartptr++ = '!'; |
*uartptr++ = '\r'; *uartptr++ = '\n'; |
*uartptr++ = '\r'; *uartptr++ = '\n'; |
*uartptr++ = '\0'; |
uartptr = uartmsg; |
|
|
seconds = 0; |
sys->io_spio = 0x0ff; // All LED's on: we got one! |
sptr = sound_data; |
sys->io_pwm_audio = 0x0310000; // Turn on the audio |
while(sptr < &sound_data[NSAMPLE_WORDS]) { |
do { |
pic = sys->io_pic; |
if (pic & INT_TIMA) { |
sys->io_pic = INT_TIMA; |
seconds++; |
rtcclock = rtcnext(rtcclock); |
} if ((pic & INT_UARTTX)&&(*uartptr)) { |
sys->io_uart = *uartptr++; |
sys->io_pic = INT_UARTTX; |
sys->io_spio = 0x22; |
} else if (!*uartptr) |
sys->io_spio = 0x20; |
if (*dpyptr) { |
// This will take a long time. It should be an |
// interruptable task ... but, sigh, we're not |
// there yet. |
dispchar(*dpyptr++); |
sys->io_spio = 0x44; |
} else |
sys->io_spio = 0x40; |
} while((pic & INT_AUDIO)==0); |
sys->io_pwm_audio = (*sptr >> 16)&0x0ffff; |
// Now, turn off the audio interrupt since it doesn't |
// reset itself ... |
sys->io_pic = INT_AUDIO; |
|
do { |
pic = sys->io_pic; |
|
if (pic & INT_TIMA) { |
sys->io_pic = INT_TIMA; |
seconds++; |
rtcclock = rtcnext(rtcclock); |
} if ((pic & INT_UARTTX)&&(*uartptr)) { |
sys->io_uart = *uartptr++; |
sys->io_pic = INT_UARTTX; |
sys->io_spio = 0x22; |
} else if (!*uartptr) |
sys->io_spio = 0x20; |
if (*dpyptr) { |
// This will take a long time. It should be an |
// interruptable task ... but, sigh, we're not |
// there yet. |
dispchar(*dpyptr++); |
sys->io_spio = 0x44; |
} else |
sys->io_spio = 0x40; |
} while((pic & INT_AUDIO)==0); |
sys->io_pwm_audio = (*sptr++) & 0x0ffff; |
|
// and turn off the audio interrupt again ... |
sys->io_pic = INT_AUDIO; |
} sys->io_pic = INT_BUTTON; |
|
// Now we wait for the end of our 30 second window |
sys->io_spio = 0x0f8; |
sys->io_pwm_audio = 0x018000; // Turn off the Audio device |
while(seconds < 30) { |
pic = sys->io_pic; |
if (pic & INT_TIMA) { |
sys->io_pic = INT_TIMA; |
seconds++; |
rtcclock = rtcnext(rtcclock); |
} if (pic & INT_BUTTON) { |
sys->io_pic = INT_BUTTON; |
seconds = 0; |
} |
} sys->io_pic = INT_BUTTON; |
} |
} |
|
void build_dpymsg(char *msg, unsigned clk) { |
*msg++ = (0x1b<<24)|('['<<16)|('j'<<8)|'C'; // Clear, and start 'C' |
*msg++ = ('l'<<24)|('o'<<16)|('c'<<8)|'k'; |
*msg = (' '<<24)|(':'<<16)|(' '<<8); |
if ((clk>>20)&0x0f) |
*msg++ |= (((clk>>20)&0x0f)+'0'); |
else |
*msg++ |= ' '; |
*msg++ = ((((clk>>16)&0x0f)+'0')<<24) |
|(':'<<16) |
|((((clk>>12)&0x0f)+'0')<< 8) // Minutes |
|((((clk>> 8)&0x0f)+'0') ); |
*msg++ = (':'<<24) |
|((((clk>> 4)&0x0f)+'0')<<16) // Seconds |
|((((clk )&0x0f)+'0')<< 8); |
*msg++ = 0; |
*msg++ = 0; |
*msg++ = 0; |
*msg++ = 0; |
} |
|
void build_uartmsg(char *msg, unsigned clk) { |
*msg++ = 'T'; // 0 |
*msg++ = 'i'; // 1 |
*msg++ = 'm'; // 2 |
*msg++ = 'e'; // 3 |
*msg++ = ':'; // 4 |
*msg++ = ' '; |
*msg++ = ((clk>>20)&0x03)+'0'; // Hrs |
*msg++ = ((clk>>16)&0x0f)+'0'; |
*msg++ = ':'; |
*msg++ = ((clk>>12)&0x0f)+'0'; // Mins |
*msg++ = ((clk>> 8)&0x0f)+'0'; |
*msg++ = '\r'; // 11 |
*msg++ = '\n'; // 12 |
*msg++ = '\0'; |
*msg++ = '\0'; |
} |
|
void showval(int val) { |
// Clear and home |
dispchar(0x1b); |
dispchar('['); |
dispchar('j'); |
for(int i=28; i>=0; i-=4) { |
int ch = ((val>>i)&0x0f)+'0'; |
if (ch > '9') |
ch = ch - '0'+'A'-10; |
dispchar(ch); |
} |
} |
|
void txch(int val) { |
register IOSPACE *sys = (IOSPACE *)0x0100; |
|
// To read whether or not the transmitter is ready, you must first |
// clear the interrupt bit. |
sys->io_pic = INT_UARTTX; |
for(int i=0; i<5000; i++) |
asm("noop"); |
sys->io_pic = INT_UARTTX; |
// If the interrupt bit sets itself again immediately, the transmitter |
// is ready. Otherwise, wait until the transmitter becomes ready. |
while((sys->io_pic&INT_UARTTX)==0) |
; |
sys->io_uart = (val&0x0ff); |
// Give the transmitter a chance to finish, and then to create an |
// interrupt when done |
sys->io_pic = INT_UARTTX; |
} |
|
void txval(int val) { |
txch('\r'); |
txch('\n'); |
txch('0'); |
txch('x'); |
for(int i=28; i>=0; i-=4) { |
int ch = ((val>>i)&0x0f)+'0'; |
if (ch > '9') |
ch = ch - '0'+'A'-10; |
txch(ch); |
} |
} |
|
// PPONP16P |
// 00120O91 |
// 00120NM3 |
// 00120E91 = 1183377 ~= 91029 / char, at 0x208d 8333/baud, 83,330 per char |
/s6soc/trunk/sw/dev/display.c
0,0 → 1,104
//////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: display.c |
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: A device driver for the SPI controlled display. The primary |
// purpose of this "device" is to output SPI instructions, though, |
// not to handle screen position or to optimize data set to the display. |
// |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): 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 3 of the License, or (at |
// your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, but WITHOUT |
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with this program. (It's in the $(ROOT)/doc directory, run make with no |
// target there if the PDF file isn't present.) If not, see |
// <http://www.gnu.org/licenses/> for a copy. |
// |
// License: GPL, v3, as defined and found on www.gnu.org, |
// http://www.gnu.org/licenses/gpl.html |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
#include "board.h" |
|
static void dispwait(void) { |
// Slow us down to the speed the display can handle |
// We want to delay about 0x800 clocks. |
// Three instructions per loop, |
// LBL: |
// NOOP |
// ADD -1,CTR |
// BNZ LBL |
// 40 clocks per instruction, as required by the SPI flash memory |
int i = 18; |
do { |
asm("noop"); |
} while(i-->0); |
} |
|
void dispchar(int ch) { |
if (!ch) // Don't display null characters |
return; |
if (ch&(~0x0ff)) { // Multiple characters to display |
int v = (ch>>24)&0x0ff; |
if (v) { |
dispchar(v); |
v = (ch>>16)&0x0ff; |
if (v) { |
dispchar(v); |
v = (ch>> 8)&0x0ff; |
if (v) { |
dispchar(v); |
dispchar(ch&0x0ff); |
} |
} |
} |
} else { |
IOSPACE *sys = (IOSPACE *)IOADDR; |
// Send the character |
for(int i=0; i<8; i++) { |
int gpiov = GPOCLRV(GPO_MOSI|GPO_SCK|GPO_SS); |
if (ch&0x80) |
gpiov |= GPOSETV(GPO_MOSI); |
sys->io_gpio = gpiov; |
dispwait(); |
sys->io_gpio = GPOSETV(GPO_SCK); |
dispwait(); |
ch<<=1; |
} |
// Turn off the clock |
sys->io_gpio = GPOCLRV(GPO_SCK); |
dispwait(); |
// Then the port |
sys->io_gpio = GPOSETV(GPO_SS); |
dispwait(); |
} |
} |
|
#ifdef ZIPOS |
void displaytask(void) { |
while(1) { |
int ch; |
read(FILENO_STDIN, &ch, 1); |
dispchar(ch); |
} |
} |
#endif |
/s6soc/trunk/sw/dev/rtcsim.h
0,0 → 1,55
//////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: rtcsim.h |
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: Since we lost the real-time clock on board due to space |
// constraints, this unit attempts to replace that functionality |
// in software. |
// |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): 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 3 of the License, or (at |
// your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, but WITHOUT |
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with this program. (It's in the $(ROOT)/doc directory, run make with no |
// target there if the PDF file isn't present.) If not, see |
// <http://www.gnu.org/licenses/> for a copy. |
// |
// License: GPL, v3, as defined and found on www.gnu.org, |
// http://www.gnu.org/licenses/gpl.html |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
#ifndef RTCSIM_H |
#define RTCSIM_H |
|
extern unsigned rtcclock, rtcalarm, rtcdate; |
#ifdef ZIPOS |
SEMAPHORE SEMDATE, SEMCLOCK; |
#endif |
|
extern unsigned rtcnext(unsigned now); |
extern unsigned rtcdatenext(unsigned today); |
|
#ifdef ZIPOS |
extern void rtctask(void); |
#endif // ZIPOS |
#endif // RTCSIM_H |
|
/s6soc/trunk/sw/dev/display.h
0,0 → 1,48
//////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: display.h |
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: A device driver for the SPI controlled display. The primary |
// purpose of this "device" is to output SPI instructions, though, |
// not to handle screen position or to optimize data set to the display. |
// |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): 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 3 of the License, or (at |
// your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, but WITHOUT |
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with this program. (It's in the $(ROOT)/doc directory, run make with no |
// target there if the PDF file isn't present.) If not, see |
// <http://www.gnu.org/licenses/> for a copy. |
// |
// License: GPL, v3, as defined and found on www.gnu.org, |
// http://www.gnu.org/licenses/gpl.html |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
#ifndef DISPLAY_H |
#define DISPLAY_H |
|
extern void dispchar(int ch); |
|
#ifdef ZIPOS |
extern void displaytask(void); |
#endif // ZIPOS |
#endif // DISPLAY_H |
/s6soc/trunk/sw/dev/Makefile
60,9 → 60,11
|
# Not for build, for for building tags and dependency files, we need to know |
# what the sources and headers are |
SOURCES:= helloworld.c doorbell.c |
DEVDRVR:= keypad.c display.c rtcsim.c |
SOURCES:= helloworld.c doorbell.c doorbell2.c $(DEVDRVR) |
HEADERS:= board.h |
# OBJECTS:= $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(SOURCES))) |
OBJDRVR := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(DEVDRVR))) |
|
|
CPPFLAGS := -I../zipos -I. |
89,6 → 91,11
$(OBJDIR)/helloworld.txt: helloworld |
$(OBJDUMP) -dr $^ > $@ |
|
doorbell2: $(OBJDIR)/ $(OBJDIR)/doorbell2.o $(OBJDRVR) cmod.ld |
$(CC) $(LDFLAGS) $(OBJDIR)/doorbell2.o $(OBJDRVR) -o $@ |
$(OBJDIR)/doorbell2.txt: doorbell2 |
$(OBJDUMP) -dr $^ > $@ |
|
define build-depends |
@echo "Building dependency file(s)" |
$(CC) $(CPPFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdep.txt |
/s6soc/trunk/sw/dev/board.h
39,10 → 39,27
#ifndef BOARD_H |
#define BOARD_H |
|
// GPIO PINS |
// first the outputs ... |
#define GPO_SDA 0x000001 |
#define GPO_SCL 0x000002 |
#define GPO_MOSI 0x000004 |
#define GPO_SCK 0x000008 |
#define GPO_SS 0x000010 |
// then the inputs. |
#define GPI_SDA 0x010000 |
#define GPI_SCL 0x020000 |
#define GPI_MISO 0x040000 |
|
#define GPOSETV(PINS) ((PINS)|((PINS)<<16)) |
#define GPOCLRV(PINS) ((PINS)<<16) |
|
// Interrupts |
#define INT_ENABLE 0x80000000 |
#define INT_BUTTON 0x001 |
#define INT_BUSERR 0x002 // Kind of useless, a buserr will kill us anyway |
#define INT_SCOPE 0x004 |
#define INT_RTC 0x008 |
#define INT_RTC 0x008 // May not be available, due to lack of space |
#define INT_TIMA 0x010 |
#define INT_TIMB 0x020 |
#define INT_UARTRX 0x040 |
50,7 → 67,10
#define INT_KEYPAD 0x100 |
#define INT_AUDIO 0x200 |
#define INT_GPIO 0x400 |
// #define INT_FLASH 0x800 |
// #define INT_FLASH 0x800 // Not available due to lack of space |
#define INT_ENABLEV(IN) (INT_ENABLE|((IN)<<16)) |
#define INT_DISABLEV(IN) (INT_ENABLE|((IN)<<16)) |
#define INT_CLEAR(IN) (IN) |
|
// Clocks per second, for use with the timer |
#define TM_ONE_SECOND 80000000 |