Point 0 - resync with Lephe's gint@dev

This commit is contained in:
Sylvain PILLOT 2022-12-04 21:36:59 +01:00
parent a4cf3516e7
commit 4789fbf459
7 changed files with 526 additions and 0 deletions

View File

@ -12,6 +12,84 @@ extern "C" {
#include <gint/defs/attributes.h>
#include <gint/defs/types.h>
//---
// SH7705 But State Controller. Refer to:
// Renesas SH7705 Group Hardware Manual
// Section 7: Bus State Controller (BSC)
//---
typedef volatile lword_union(sh7705_bsc_CSnBCR_t,
uint32_t :2;
uint32_t IWW :2;
uint32_t :1;
uint32_t IWRWD :2;
uint32_t :1;
uint32_t IWRWS :2;
uint32_t :1;
uint32_t IWRRD :2;
uint32_t :1;
uint32_t IWRRS :2;
uint32_t :1;
uint32_t TYPE :3;
uint32_t :1;
uint32_t BSZ :2;
uint32_t :9;
);
typedef volatile lword_union(sh7705_bsc_CSnWCR_t,
uint32_t :13;
uint32_t WW :3;
uint32_t :3;
uint32_t SW :2;
uint32_t WR :4;
uint32_t WM :1;
uint32_t :4;
uint32_t HW :2;
);
typedef volatile struct
{
lword_union(CMNCR,
uint32_t :24; /* reserved */
uint32_t DMAIW : 2; /* Wait State*/
uint32_t DMAIWA : 1; /* Method of Inserting Wait state bewteen cycles */
uint32_t :1; /* reserved */
uint32_t ENDIAN : 1; /* Endian Flag*/
uint32_t :1; /* reserved */
uint32_t HIZMEM : 1; /* High Z memory Control*/
uint32_t HIZCNT : 1; /* High Z Control*/
);
sh7705_bsc_CSnBCR_t CS0BCR;
sh7705_bsc_CSnBCR_t CS2BCR;
sh7705_bsc_CSnBCR_t CS3BCR;
sh7705_bsc_CSnBCR_t CS4BCR;
sh7705_bsc_CSnBCR_t CS5ABCR;
sh7705_bsc_CSnBCR_t CS5BBCR;
sh7705_bsc_CSnBCR_t CS6ABCR;
sh7705_bsc_CSnBCR_t CS6BBCR;
sh7705_bsc_CSnWCR_t CS0WCR;
sh7705_bsc_CSnWCR_t CS2WCR;
sh7705_bsc_CSnWCR_t CS3WCR;
sh7705_bsc_CSnWCR_t CS4WCR;
sh7705_bsc_CSnWCR_t CS5AWCR;
sh7705_bsc_CSnWCR_t CS5BWCR;
sh7705_bsc_CSnWCR_t CS6AWCR;
sh7705_bsc_CSnWCR_t CS6BWCR;
/* TODO : there are several other registers not described yet
as they are not used for overclocking the SH7705 processor.
To be done later on when needed.*/
} GPACKED(4) sh7705_bsc_t;
#define SH7705_BSC (*(sh7705_bsc_t *)0xa4fd0000)
//---
// SH7305 But State Controller. Refer to:
// Renesas SH7730 Group Hardware Manual

View File

@ -31,6 +31,12 @@ typedef volatile struct
uint16_t :2;
uint16_t PFC :2; /* Peripheral clock divider */
);
byte_union(UCLKCR,
uint8_t USSCS :2; /* Source Clock Selection Bit*/
uint8_t USBEN :1; /* USB On-Chip Oscillator Enable*/
uint8_t :5; /* reserved */
);
} GPACKED(4) sh7705_cpg_t;

View File

@ -79,6 +79,199 @@ typedef volatile struct
// TODO: Document the SH7305 Pin Function Controller
//---
typedef volatile word_union( sh7305_Port_Control_Register_t,
uint16_t P7MD :2;
uint16_t P6MD :2;
uint16_t P5MD :2;
uint16_t P4MD :2;
uint16_t P3MD :2;
uint16_t P2MD :2;
uint16_t P1MD :2;
uint16_t P0MD :2;
);
typedef volatile byte_union( sh7305_port_data_register_t,
uint8_t P7DT :1;
uint8_t P6DT :1;
uint8_t P5DT :1;
uint8_t P4DT :1;
uint8_t P3DT :1;
uint8_t P2DT :1;
uint8_t P1DT :1;
uint8_t P0DT :1;
);
typedef volatile word_union( sh7305_pin_select_register_t,
uint16_t PS15 :1;
uint16_t PS14 :1;
uint16_t PS13 :1;
uint16_t PS12 :1;
uint16_t PS11 :1;
uint16_t PS10 :1;
uint16_t PS9 :1;
uint16_t PS8 :1;
uint16_t PS7 :1;
uint16_t PS6 :1;
uint16_t PS5 :1;
uint16_t PS4 :1;
uint16_t PS3 :1;
uint16_t PS2 :1;
uint16_t PS1 :1;
uint16_t PS0 :1;
);
typedef volatile word_union( sh7305_IO_buffer_hiz_control_register_t,
uint16_t HIZ15 :1;
uint16_t HIZ14 :1;
uint16_t HIZ13 :1;
uint16_t HIZ12 :1;
uint16_t HIZ11 :1;
uint16_t HIZ10 :1;
uint16_t HIZ9 :1;
uint16_t HIZ8 :1;
uint16_t HIZ7 :1;
uint16_t HIZ6 :1;
uint16_t HIZ5 :1;
uint16_t HIZ4 :1;
uint16_t HIZ3 :1;
uint16_t HIZ2 :1;
uint16_t HIZ1 :1;
uint16_t HIZ0 :1;
);
typedef volatile word_union( sh7305_module_function_select_register_t,
uint16_t MSEL15 :1;
uint16_t MSEL14 :1;
uint16_t MSEL13 :1;
uint16_t MSEL12 :1;
uint16_t MSEL11 :1;
uint16_t MSEL10 :1;
uint16_t MSEL9 :1;
uint16_t MSEL8 :1;
uint16_t MSEL7 :1;
uint16_t MSEL6 :1;
uint16_t MSEL5 :1;
uint16_t MSEL4 :1;
uint16_t MSEL3 :1;
uint16_t MSEL2 :1;
uint16_t MSEL1 :1;
uint16_t MSEL0 :1;
);
typedef volatile word_union( sh7305_IO_buffer_drive_control_register_t,
uint16_t DRV15 :1;
uint16_t DRV14 :1;
uint16_t DRV13 :1;
uint16_t DRV12 :1;
uint16_t DRV11 :1;
uint16_t DRV10 :1;
uint16_t DRV9 :1;
uint16_t DRV8 :1;
uint16_t DRV7 :1;
uint16_t DRV6 :1;
uint16_t DRV5 :1;
uint16_t DRV4 :1;
uint16_t DRV3 :1;
uint16_t DRV2 :1;
uint16_t DRV1 :1;
uint16_t DRV0 :1;
);
typedef volatile struct
{
// List of all PORT CONTROL REGISTERS (PCRs)
sh7305_Port_Control_Register_t PACR;
sh7305_Port_Control_Register_t PBCR;
sh7305_Port_Control_Register_t PCCR;
sh7305_Port_Control_Register_t PDCR;
sh7305_Port_Control_Register_t PECR;
sh7305_Port_Control_Register_t PFCR;
sh7305_Port_Control_Register_t PGCR;
sh7305_Port_Control_Register_t PHCR;
sh7305_Port_Control_Register_t PJCR;
sh7305_Port_Control_Register_t PKCR;
sh7305_Port_Control_Register_t PLCR;
sh7305_Port_Control_Register_t PMCR;
sh7305_Port_Control_Register_t PNCR;
sh7305_Port_Control_Register_t PQCR;
sh7305_Port_Control_Register_t PRCR;
sh7305_Port_Control_Register_t PSCR;
// List of all PORT DATA REGISTERS (PDRs)
sh7305_port_data_register_t PADR;
sh7305_port_data_register_t PBDR;
sh7305_port_data_register_t PCDR;
sh7305_port_data_register_t PDDR;
sh7305_port_data_register_t PEDR;
sh7305_port_data_register_t PFDR;
sh7305_port_data_register_t PGDR;
sh7305_port_data_register_t PHDR;
sh7305_port_data_register_t PJDR;
sh7305_port_data_register_t PKDR;
sh7305_port_data_register_t PLDR;
sh7305_port_data_register_t PMDR;
sh7305_port_data_register_t PNDR;
sh7305_port_data_register_t PQDR;
sh7305_port_data_register_t PRDR;
sh7305_port_data_register_t PSDR;
sh7305_Port_Control_Register_t PTCR;
sh7305_Port_Control_Register_t PUCR;
sh7305_Port_Control_Register_t PVCR;
//Missing ports ?
//sh7305_Port_Control_Register_t PWCR;
//sh7305_Port_Control_Register_t PXCR;
//sh7305_Port_Control_Register_t PYCR;
//sh7305_Port_Control_Register_t PZCR;
pad( 0x08 );
// List of all PIN SELECT REGISTERS (PSELs)
sh7305_pin_select_register_t PSELA;
sh7305_pin_select_register_t PSELB;
sh7305_pin_select_register_t PSELC;
sh7305_pin_select_register_t PSELD;
sh7305_pin_select_register_t PSELE;
// List of all IO BUFFER HI-Z CONTROL REGISTERS (HIZCRs)
sh7305_IO_buffer_hiz_control_register_t HIZCRA;
sh7305_IO_buffer_hiz_control_register_t HIZCRB;
sh7305_IO_buffer_hiz_control_register_t HIZCRC;
// the next one is not clearly listed, can be aither PSELF or HIZCRD so we skip it with pad
//sh7305_pin_select_register_t PSELF;
//sh7305_IO_buffer_hiz_control_register_t HIZCRD;
pad( 0x02 );
sh7305_port_data_register_t PTDR;
sh7305_port_data_register_t PUDR;
sh7305_port_data_register_t PVDR;
//Missing ports ?
//sh7305_port_data_register_t PWDR;
//sh7305_port_data_register_t PXDR;
//sh7305_port_data_register_t PYDR;
//sh7305_port_data_register_t PZDR;
pad( 0x08 );
pad( 0x12 ); // jump from address 0xa405016e to 0xa4050180
// List of all MODULE FUNCTION SELECT REGISTERS (MSELs)
sh7305_module_function_select_register_t MSELCRA;
sh7305_module_function_select_register_t MSELCRB;
} sh7305_pfc_t;
#define SH7305_PFC (*((sh7305_pfc_t *)0xa4050100))
#ifdef __cplusplus
}
#endif

108
include/gint/mpu/scif.h Normal file
View File

@ -0,0 +1,108 @@
//---
// gint:mpu:scif - Serial Communication Interface with FIFO (SCIF)
//---
#ifndef GINT_MPU_SCIF
#define GINT_MPU_SCIF
#ifdef __cplusplus
extern "C" {
#endif
#include <gint/defs/attributes.h>
#include <gint/defs/types.h>
typedef volatile struct
{
// Serial Mode
word_union(SCSMR,
uint16_t :8; //Reserved
uint16_t CA :1; //Communication Mode.
uint16_t CHR :1; //Character Length.
uint16_t PE :1; //Parity Enable
uint16_t OE :1; //Parity Mode
uint16_t STOP :1; //Bit Stop Length
uint16_t :1; //Reserved
uint16_t CKS :2; //Clock Select
);
pad(0x2);
// Serial Bit Rate
uint8_t SCBRD; //set the bit rate of serial transmission/reception in relation to the operating clock of the baud rate generator
pad(0x3);
// Serial Control
word_union(SCSCR,
uint16_t :8; //Reserved
uint16_t TIE :1; //Transmit Interrupt Enable
uint16_t RIE :1; //Receive Interrupt Enable
uint16_t TE :1; //Transmit Enable
uint16_t RE :1; //Receive Mode
uint16_t REIE :1; //Receive Error Interrupt Enable
uint16_t :1; //Reserved
uint16_t CKE :2; //Clock Enable
);
pad(0x2);
// Serial Transmit data
uint8_t SCFTD; // FIFO for serial transmit data
pad(0x3);
// Serial Status
word_union(SCFSR,
uint16_t PERC :4; //Number of Parity Errors
uint16_t FERC :4; //Number of Framing Errors
uint16_t ER :1; //Receive Error
uint16_t TEND :1; //Transmit End
uint16_t TDFE :1; //Transmit FIFO Data Empty
uint16_t BRK :1; //Break Detection
uint16_t FER :1; //Framing Error Indication
uint16_t PER :1; //Parity Error Indication
uint16_t RDF :1; //Receive FIFO Data Full
uint16_t DR :1; //Received data Ready
);
pad(0x2);
// Serial Receive data
uint8_t SCFRD; // FIFO for serial received data
pad(0x3);
// Serial FIFO Control
word_union(SCFCR,
uint16_t :8; //Reserved
uint16_t RTRG :2; //Receive FIFO Data Trigger
uint16_t TTRG :2; //Transmit FIFO Data Trigger
uint16_t :1; //Reserved
uint16_t TFRST :1; //Transmit FIFO Data Register Reset
uint16_t RFRST :1; //Receive FIFO Data Register Reset
uint16_t LOOP :1; //Loopback Test
);
pad(0x2);
// Serial FIFO Count
word_union(SCFDR,
uint16_t :3; //Reserved
uint16_t TFDC :5; //Number of Data Bytes in Transmit FIFO
uint16_t :3; //Reserved
uint16_t RFDC :5; //Number of Data Bytes in Receive FIFO
);
pad(0x2);
// Serial Line Status
word_union(SCLSR,
uint16_t :15; //Reserved
uint16_t ORER :1; //Overrun Error
);
pad(0x2);
} GPACKED(4) sh7305_scif_t;
#define SH7305_SCIF (*((sh7305_scif_t *)0x0xa4410000))
#ifdef __cplusplus
}
#endif
#endif /* GINT_MPU_SCIF */

56
include/gint/mpu/wdt.h Normal file
View File

@ -0,0 +1,56 @@
/---
// gint:mpu:wdt - Watchdog Timer
//---
#ifndef GINT_MPU_WDT
#define GINT_MPU_WDT
#ifdef __cplusplus
extern "C" {
#endif
#include <gint/defs/attributes.h>
#include <gint/defs/types.h>
//---
// SH7705 WatchDog Timer. Refer to:
// "Renesas SH7705 Group Hardware Manual"
// Section 10: "WatchDog Timer (WDT)"
//---
/* sh7705_wdt_t - Watch Dog Timer */
typedef volatile struct
{
/* WDT registers are unique in access size; reads are performed with 8-bit
accesses, but writes are performed with 16-bit accesses. */
union {
uint8_t READ;
uint16_t WRITE;
} WTCNT;
union {
byte_union(READ,
uint8_t TME :1; /* ... description of TME */
uint8_t WTIT :1; /* ... description of WT/IT */
uint8_t RSTS :1; /* ... description of RSTS */
uint8_t WOVF :1; /* ... description of WOVF */
uint8_t IOVF :1; /* ... description of IOVF */
uint8_t CKS :3; /* ... description of CKS */
);
uint16_t WRITE;
} WTCSR;
} sh7705_wdt_t;
#define SH7705_WDT (*((sh7705_wdt_t *)0xFFFFFF84))
#ifdef __cplusplus
}
#endif
#endif /* GINT_MPU_WDT */

41
include/gint/serial.h Normal file
View File

@ -0,0 +1,41 @@
//---
// gint:serial - Serial operation
//---
#ifndef GINT_SERIAL
#define GINT_SERIAL
#ifdef __cplusplus
extern "C" {
#endif
#include <gint/mpu/scif.h>
#include <gint/mpu/pfc.h>
#include <gint/hardware.h>
#include <gint/defs/types.h>
#include <gint/defs/call.h>
// Prototypes of functions expected to appear in the serial module
// aims at reproducing the OS syscalls
int gint_serial_read_one_byte(unsigned char *dest);
int gint_serial_write_one_byte(unsigned char byte);
int gint_serial_write_bytes(unsigned char *src, int size);
int gint_serial_clear_receive_buffer(void);
int gint_serial_clear_transmit_buffer(void);
int gint_serial_open(unsigned char *conf);
int gint_serial_close(int mode);
#ifdef __cplusplus
}
#endif
#endif /* GINT_SERIAL */

44
src/scif/scif.c Normal file
View File

@ -0,0 +1,44 @@
//---
// gint:serial - Serial operation
//---
#include <gint/serial.h>
#define SCIF SH7305_SCIF
#define PFC SH7305_PFC
int gint_serial_read_one_byte(unsigned char *dest)
{
};
int gint_serial_write_one_byte(unsigned char byte)
{
};
int gint_serial_write_bytes(unsigned char *src, int size)
{
};
int gint_serial_clear_receive_buffer(void)
{
};
int gint_serial_clear_transmit_buffer(void)
{
};
int gint_serial_open(unsigned char *conf)
{
};
int gint_serial_close(int mode)
{
};