Gert van der Knokke
/
C1541III
C1541-III mbed edition
hardware.c@1:0cbbb66a6100, 2011-08-22 (annotated)
- Committer:
- gertk
- Date:
- Mon Aug 22 21:11:59 2011 +0000
- Revision:
- 1:0cbbb66a6100
- Parent:
- 0:28557a4d2215
updated the nRESET pin to an interrupt capable pin (p29)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gertk | 0:28557a4d2215 | 1 | /*----------------------------------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 2 | /* 1541-III, Hardware control routines, Written by Jan Derogee */ |
gertk | 0:28557a4d2215 | 3 | /*----------------------------------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 4 | /*----------------------------------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 5 | |
gertk | 0:28557a4d2215 | 6 | /* History: |
gertk | 0:28557a4d2215 | 7 | -------- |
gertk | 0:28557a4d2215 | 8 | 2007-03-08 status of LED output was set to 1 (LED-ON) during config, must be 0 (LED-OFF) |
gertk | 0:28557a4d2215 | 9 | 2006-06-22 changed baudrate to 115K2, this is more practical/compatible with the bootloader (currently) |
gertk | 0:28557a4d2215 | 10 | 2006-06-21 added complete device configuration word, witout it the source is not complete |
gertk | 0:28557a4d2215 | 11 | in previous versions the user had to set the configuration word within MPLAB |
gertk | 0:28557a4d2215 | 12 | but to make this source independent, the configuration word must be included here!! |
gertk | 0:28557a4d2215 | 13 | and NOT in the development environment. Doing it within the source also documents it. |
gertk | 0:28557a4d2215 | 14 | 2006-04-12 enabled interrupt on RB0 (for ATN handling under interrupt) |
gertk | 0:28557a4d2215 | 15 | 2006-03-28 change in IO-pin definiions required for new PCB design |
gertk | 0:28557a4d2215 | 16 | 2006-02-04 added timer-0 (for the led blinking routines) |
gertk | 0:28557a4d2215 | 17 | 2006-02-02 improvements in code layout... i.o.w. making it more readable |
gertk | 0:28557a4d2215 | 18 | |
gertk | 0:28557a4d2215 | 19 | */ |
gertk | 0:28557a4d2215 | 20 | |
gertk | 0:28557a4d2215 | 21 | /* TO DO: |
gertk | 0:28557a4d2215 | 22 | ------ |
gertk | 0:28557a4d2215 | 23 | */ |
gertk | 0:28557a4d2215 | 24 | |
gertk | 0:28557a4d2215 | 25 | /*----------------------------------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 26 | |
gertk | 0:28557a4d2215 | 27 | |
gertk | 0:28557a4d2215 | 28 | /*--------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 29 | /* includes */ |
gertk | 0:28557a4d2215 | 30 | /*--------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 31 | #include <mbed.h> |
gertk | 0:28557a4d2215 | 32 | //#include <IEC_bus.h> |
gertk | 0:28557a4d2215 | 33 | |
gertk | 0:28557a4d2215 | 34 | #include <hardware.h> |
gertk | 0:28557a4d2215 | 35 | |
gertk | 0:28557a4d2215 | 36 | /*--------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 37 | /* globals */ |
gertk | 0:28557a4d2215 | 38 | /*--------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 39 | bool std_out; /*this holds the destination of the putch- and printf-routines*/ |
gertk | 0:28557a4d2215 | 40 | /*--------------------------------------------------------*/ |
gertk | 0:28557a4d2215 | 41 | |
gertk | 0:28557a4d2215 | 42 | /*****************************************************************************************************************/ |
gertk | 0:28557a4d2215 | 43 | /*****************************************************************************************************************/ |
gertk | 0:28557a4d2215 | 44 | |
gertk | 0:28557a4d2215 | 45 | void HardwareInit(void) /*initialize processor here*/ |
gertk | 0:28557a4d2215 | 46 | { |
gertk | 0:28557a4d2215 | 47 | |
gertk | 0:28557a4d2215 | 48 | |
gertk | 0:28557a4d2215 | 49 | |
gertk | 0:28557a4d2215 | 50 | // INTEDG0 = 0; /*set interrupt trigger to falling edge*/ |
gertk | 0:28557a4d2215 | 51 | // INT0IE = 0; /*disable interrupts on pin RB0 (INT0), this line is connected to the ATN line*/ |
gertk | 0:28557a4d2215 | 52 | |
gertk | 0:28557a4d2215 | 53 | // IPEN=1; /*enable priority for interrrupts*/ |
gertk | 0:28557a4d2215 | 54 | // PEIE=1; |
gertk | 0:28557a4d2215 | 55 | // GIE=1; |
gertk | 0:28557a4d2215 | 56 | } |
gertk | 0:28557a4d2215 | 57 | |
gertk | 0:28557a4d2215 | 58 | extern void enable_ATN_interrupt(void); |
gertk | 0:28557a4d2215 | 59 | |
gertk | 0:28557a4d2215 | 60 | #define RS232 1 |
gertk | 0:28557a4d2215 | 61 | #define LCD 0 |
gertk | 0:28557a4d2215 | 62 | |
gertk | 0:28557a4d2215 | 63 | /*redirect standard output to serial or LCD*/ |
gertk | 0:28557a4d2215 | 64 | void putch(unsigned char ch) |
gertk | 0:28557a4d2215 | 65 | { |
gertk | 0:28557a4d2215 | 66 | |
gertk | 0:28557a4d2215 | 67 | putchar(ch); |
gertk | 0:28557a4d2215 | 68 | } |
gertk | 0:28557a4d2215 | 69 | |
gertk | 0:28557a4d2215 | 70 | |
gertk | 0:28557a4d2215 | 71 | |
gertk | 0:28557a4d2215 | 72 | /* |
gertk | 0:28557a4d2215 | 73 | The author of sourcecode without comments is the only one to fully understand the written code... for the first 3 months. |
gertk | 0:28557a4d2215 | 74 | */ |