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 "config.h"
23#include "types.h"
24
25#if (MODULE_MEGAWIFI == 1 && MODULE_EVERDRIVE == 1)
26//#define SSF_CTRL_P 0x8000 //register accesss protection bit. should be set, otherwise register will ignore any attempts to write
27//#define SSF_CTRL_X 0x4000 //32x mode
28//#define SSF_CTRL_W 0x2000 //ROM memory write protection
29//#define SSF_CTRL_L 0x1000 //led
30
31//#define USB_RD_BUSY while ((REG_STE & STE_USB_RD_RDY) == 0)
32//#define USB_WR_BUSY while ((REG_STE & STE_USB_WR_RDY) == 0)
33/**************************************** */
34
35
37#define UART_BASE 0xA13000
38
40#define UART_TX_FIFO_LEN 1
41
43#define UART_DATA (*((volatile u16*)(UART_BASE + 226)))
44#define UART_STE (*((volatile u16*)(UART_BASE + 228)))
45#define UART_REG_CFG (*((volatile u16*)(UART_BASE + 230)))
46#define UART_REG_SSF_CTRL (*((volatile u16*)(UART_BASE + 240)))
47
48#define SSF_CTRL_P 0x8000 //register accesss protection bit. should be set, otherwise register will ignore any attempts to write
49#define SSF_CTRL_X 0x4000 //32x mode
50#define SSF_CTRL_W 0x2000 //ROM memory write protection
51#define SSF_CTRL_L 0x1000 //led
52
53#define UART_SPR UART_DATA
54
55#define UART_STE_WR_RDY 2//usb write ready bit
56#define UART_STE_RD_RDY 4//usb read ready bit
57
58//spi chip select signal
59#define CFG_SPI_SS 1
60#define CFG_SPI_QRD 6
61#define CFG_SPI_QWR 2
62
63/************************************************************************/
68void uart_init(void);
69
70/************************************************************************/
76#define uart_tx_ready() (UART_STE & UART_STE_WR_RDY)
77
78/************************************************************************/
83#define uart_rx_ready() (UART_STE & UART_STE_RD_RDY)
84
85/************************************************************************/
91#define uart_putc(c) do{UART_DATA = (c);}while(0);
92
93/************************************************************************/
99#define uart_getc() (UART_DATA)
100
101/************************************************************************/
107#define uart_set(reg, val) while(0);
108
109/************************************************************************/
115#define uart_get(reg) while(0);
116
117/************************************************************************/
123#define uart_set_bits(reg, val) while(0)
124
125/************************************************************************/
131#define uart_clr_bits(reg, val) while(0)
132
133/************************************************************************/
139#define uart_test(reg, val) while(0)
140
141/************************************************************************/
144#define uart_reset_fifos() while(0)
145void ssf_set_rom_bank(u8 bank, u8 val);
146#endif
147#endif /*_SSF_H_*/
148
Basic SGDK library configuration file.
Types definition.
unsigned char u8
Definition types.h:95