SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
ssf.h
1/************************************************************************
2 * \brief Simple SSF driver.
3 *
4 * \author Juan Antonio Ruiz (PaCHoN)
5 * \date 2024
6 * \defgroup SSF SSF
7 * \brief
8 * USB IO
9 * 0xA130E2 [........ DDDDDDDD] read/write
10 * D data bits
11 *
12 * IO status
13 * 0xA130E4 [.C...... .....RWS] read only
14 * S SPI controller ready. Not used on WIFI.
15 * W USB fifo ready to write
16 * R USB fifo ready to read
17 * C SD card type. 0=SD, 1=SDHC. Not used on WIFI.
18*************************************** */
19#ifndef _SSF_H_
20#define _SSF_H
21
22#include "types.h"
23
24//#define SSF_CTRL_P 0x8000 //register accesss protection bit. should be set, otherwise register will ignore any attempts to write
25//#define SSF_CTRL_X 0x4000 //32x mode
26//#define SSF_CTRL_W 0x2000 //ROM memory write protection
27//#define SSF_CTRL_L 0x1000 //led
28
29//#define USB_RD_BUSY while ((REG_STE & STE_USB_RD_RDY) == 0)
30//#define USB_WR_BUSY while ((REG_STE & STE_USB_WR_RDY) == 0)
31/**************************************** */
32
33
35#define UART_BASE 0xA13000
36
38#define UART_TX_FIFO_LEN 1
39
41#define UART_DATA (*((volatile u16*)(UART_BASE + 226)))
42#define UART_STE (*((volatile u16*)(UART_BASE + 228)))
43#define UART_REG_CFG (*((volatile u16*)(UART_BASE + 230)))
44#define UART_REG_SSF_CTRL (*((volatile u16*)(UART_BASE + 240)))
45
46#define SSF_CTRL_P 0x8000 //register accesss protection bit. should be set, otherwise register will ignore any attempts to write
47#define SSF_CTRL_X 0x4000 //32x mode
48#define SSF_CTRL_W 0x2000 //ROM memory write protection
49#define SSF_CTRL_L 0x1000 //led
50
51#define UART_SPR UART_DATA
52
53#define UART_STE_WR_RDY 2//usb write ready bit
54#define UART_STE_RD_RDY 4//usb read ready bit
55
56//spi chip select signal
57#define CFG_SPI_SS 1
58#define CFG_SPI_QRD 6
59#define CFG_SPI_QWR 2
60
61/************************************************************************/
66void uart_init(void);
67
68/************************************************************************/
74#define uart_tx_ready() (UART_STE & UART_STE_WR_RDY)
75
76/************************************************************************/
81#define uart_rx_ready() (UART_STE & UART_STE_RD_RDY)
82
83/************************************************************************/
89#define uart_putc(c) do{UART_DATA = (c);}while(0);
90
91/************************************************************************/
97#define uart_getc() (UART_DATA)
98
99/************************************************************************/
105#define uart_set(reg, val) while(0);
106
107/************************************************************************/
113#define uart_get(reg) while(0);
114
115/************************************************************************/
121#define uart_set_bits(reg, val) while(0)
122
123/************************************************************************/
129#define uart_clr_bits(reg, val) while(0)
130
131/************************************************************************/
137#define uart_test(reg, val) while(0)
138
139/************************************************************************/
142#define uart_reset_fifos() while(0)
143
144void ssf_set_rom_bank(u8 bank, u8 val);
145
146#endif /*_SSF_H_*/
147
void uart_init(void)
Initializes the driver. The baud rate is set to UART_BR, and the UART FIFOs are enabled....
Types definition.
unsigned char u8
Definition types.h:95