Blame
|
1 | # Machine Library |
||||||
| 2 | ||||||||
| 3 | I've created a library targeting the hardware specific aspects of programming the Sbc-3. I believe that it should work with the other boards from [Mega Micros](https://mega-micros.co.uk/index.htm), but since I don't have access to anything but the Sbc-3, can't confirm that. |
|||||||
| 4 | ||||||||
|
5 | Note. if compiling for the 68000, you'll need to change the target cpu in `src/stdenv.mk` and `src/lib/Makefile` by changing the **CPU** macro. |
||||||
| 6 | ||||||||
|
7 | To use the library, just include the following in your C sourcecode: |
||||||
| 8 | ```c |
|||||||
| 9 | #include <machine.h> |
|||||||
| 10 | ``` |
|||||||
|
11 | |||||||
| 12 | ## Serial I/O |
|||||||
| 13 | ||||||||
|
14 | ```C |
||||||
| 15 | int _char_available(void); |
|||||||
| 16 | char _getchar(void); |
|||||||
| 17 | void _putchar(char c); |
|||||||
| 18 | ``` |
|||||||
| 19 | ||||||||
|
20 | ## LED Control |
||||||
| 21 | There's a block of 10 leds (LD7 on the SBC3-b3), and six of them can be used for anything you like. Led1 is furthest from the cpu: |
|||||||
|
22 | |||||||
|
23 | | LED # | Used for | |
||||||
| 24 | |:------|:---------| |
|||||||
| 25 | | 1 | Indicates that the board is being powered via an external 5v supply. | |
|||||||
| 26 | | 2 | Indicated that the board is being powered via the ATX power connector. | |
|||||||
| 27 | | 3 | Connected to the ~RTS pin on the duart channel B. | |
|||||||
| 28 | | 4 | Connected to the ~RTS pin on the duart channel A. | |
|||||||
| 29 | | 5 | Available to user. | |
|||||||
| 30 | | 6 | Available to user. | |
|||||||
| 31 | | 7 | Available to user. | |
|||||||
| 32 | | 8 | Available to user. | |
|||||||
| 33 | | 9 | Available to user. | |
|||||||
| 34 | | 10 | Available to user. | |
|||||||
|
35 | |||||||
| 36 | Two functions are provided, one to turn on a led, and another to turn it off. |
|||||||
| 37 | ||||||||
| 38 | ```C |
|||||||
| 39 | void set_led(int lednum); |
|||||||
| 40 | void clear_led(int lednum); |
|||||||
| 41 | ``` |
|||||||
| 42 | Where `lednum` is an integer in the range of 5 through to 10, as per the table above. Any other value will be silently ignored. |
|||||||
|
43 | |||||||
|
44 | ## PI/T |
||||||
| 45 | ||||||||
| 46 | ```C |
|||||||
| 47 | void _pit_reset(void); |
|||||||
| 48 | unsigned int _pit_get_counter(void); |
|||||||
| 49 | unsigned int _pit_set_counter(unsigned int); |
|||||||
| 50 | ``` |
|||||||
| 51 | ||||||||
|
52 | ## Compact Flash |
||||||
| 53 | ||||||||
| 54 | ```C |
|||||||
| 55 | void _cf_wait_busy(void); |
|||||||
| 56 | void _cf_wait_data(void); |
|||||||
| 57 | void cf_init(void); |
|||||||
| 58 | int cf_read(uint8_t drive_num, uint32_t sector, uint8_t *buffer); |
|||||||
| 59 | ||||||||
| 60 | ``` |
|||||||
|
61 | |||||||
| 62 | ## Vectors and Interrupts |
|||||||
| 63 | ||||||||
| 64 | ```C |
|||||||
|
65 | unsigned int *_get_vectors_base(void); |
||||||
|
66 | unsigned int get_isr_handler(int vector_number); |
||||||
| 67 | unsigned int set_isr_handler(int vector_number, void isr(void)); |
|||||||
|
68 | ``` |
||||||
|
69 | |||||||
|
70 | ## `$I^2c$` Bus |
||||||
|
71 | |||||||
| 72 | ```C |
|||||||
| 73 | ``` |
|||||||