hsk_libs-dev
163:b63ae088cc97
High Speed Karlsruhe XC878 library collection
|
HSK Synchronous Serial Interface implementation. More...
Macros | |
#define | BIT_RMAP 0 |
SYSCON0 Special Function Register Map Control bit. More... | |
#define | BIT_EIR 0 |
IRCON1 Error Interrupt Flag for SSC bit. More... | |
#define | BIT_TIR 1 |
IRCON1 Transmit Interrupt Flag for SSC bit. More... | |
#define | BIT_RIR 2 |
IRCON1 Receive Interrupt Flag for SSC bit. More... | |
#define | BIT_SSC_DIS 1 |
PMCON1 Disable Request bit. More... | |
#define | BIT_MS 6 |
SSC_CONH_P Master Select bit. More... | |
#define | BIT_EIREN 0 |
MODIEN Error Interrupt Enable Bit for SSC. More... | |
#define | BIT_TIREN 1 |
MODIEN Transmit Interrupt Enable Bit for SSC. More... | |
#define | BIT_RIREN 2 |
MODIEN Receive Interrupt Enable Bit for SSC. More... | |
#define | BIT_MIS 0 |
MODPISEL3 Master Mode Input Select bits. More... | |
#define | BIT_SIS 2 |
MODPISEL3 Slave Mode Input Select bits. More... | |
#define | BIT_CIS 4 |
MODPISEL3 Slave Mode Clock Input Select bits. More... | |
#define | CNT_SEL 2 |
Input Select bit count. More... | |
#define | BIT_LB 7 |
SSC_CONL Loop Back Control bit. More... | |
#define | BIT_EN 7 |
SSC_CONH_O Enable Bit. More... | |
Functions | |
void | ISR_hsk_ssc (void) |
Transmit and receive interrupt. More... | |
void | hsk_ssc_init (const uword baud, const ubyte config, const bool mode) |
The maximum baud rate in master mode is 12000000 bits/s, and 6000000 bits/s in slave mode. More... | |
void | hsk_ssc_ports (const ubyte ports) |
Configure the I/O ports of the SSC unit. More... | |
void | hsk_ssc_talk (char *buffer, ubyte len) |
Send and receive data. More... | |
void | hsk_ssc_enable () |
Turn the SSC module on. More... | |
void | hsk_ssc_disable () |
Turn the SSC module off. More... | |
Variables | |
bool | hsk_ssc_master = 1 |
Master mode storage bit, so it does not need to be extracted from SSC_CONH all the time. More... | |
struct { | |
char * rptr | |
Pointer used for storing data read from the serial connection. More... | |
char * wptr | |
Pointer used to fetch data for writing on the serial connection. More... | |
ubyte rcount | |
Bytes left to read from the connection. More... | |
ubyte wcount | |
Bytes left to write on the connection. More... | |
} | hsk_ssc_buffer |
Keeps the SSC communication state. More... | |
HSK Synchronous Serial Interface implementation.
#define BIT_CIS 4 |
MODPISEL3 Slave Mode Clock Input Select bits.
#define BIT_EIR 0 |
IRCON1 Error Interrupt Flag for SSC bit.
#define BIT_EIREN 0 |
MODIEN Error Interrupt Enable Bit for SSC.
#define BIT_EN 7 |
SSC_CONH_O Enable Bit.
#define BIT_LB 7 |
SSC_CONL Loop Back Control bit.
Half-duplex mode when set.
#define BIT_MIS 0 |
MODPISEL3 Master Mode Input Select bits.
#define BIT_MS 6 |
SSC_CONH_P Master Select bit.
#define BIT_RIR 2 |
IRCON1 Receive Interrupt Flag for SSC bit.
#define BIT_RIREN 2 |
MODIEN Receive Interrupt Enable Bit for SSC.
#define BIT_RMAP 0 |
SYSCON0 Special Function Register Map Control bit.
#define BIT_SIS 2 |
MODPISEL3 Slave Mode Input Select bits.
#define BIT_SSC_DIS 1 |
PMCON1 Disable Request bit.
#define BIT_TIR 1 |
IRCON1 Transmit Interrupt Flag for SSC bit.
#define BIT_TIREN 1 |
MODIEN Transmit Interrupt Enable Bit for SSC.
#define CNT_SEL 2 |
Input Select bit count.
void hsk_ssc_disable | ( | ) |
Turn the SSC module off.
void hsk_ssc_enable | ( | ) |
Turn the SSC module on.
void hsk_ssc_init | ( | const uword | baud, |
const ubyte | config, | ||
const bool | mode | ||
) |
The maximum baud rate in master mode is 12000000 bits/s, and 6000000 bits/s in slave mode.
Calling this function turns the SSC off until hsk_ssc_enable() is called.
void hsk_ssc_ports | ( | const ubyte | ports | ) |
Configure the I/O ports of the SSC unit.
ports | Selects an SSC I/O Ports I/O port configuration |
void hsk_ssc_talk | ( | char * | buffer, |
ubyte | len | ||
) |
Send and receive data.
The buffer with the given length should contain the data to transceive and will be filled with the received data upon completion.
The provided buffer needs to reside in xdata memory, e.g. to create and use a string buffer the following should work:
Note that char must not be const and that is used to prevent sending and overwriting the terminal 0 character. There may be cases where a terminal 0 character is desired.
buffer | The rx/tx transmission buffer |
len | The length of the buffer |
void ISR_hsk_ssc | ( | void | ) |
Transmit and receive interrupt.
hsk_ssc_buffer |
Keeps the SSC communication state.
bool hsk_ssc_master = 1 |
Master mode storage bit, so it does not need to be extracted from SSC_CONH all the time.
ubyte rcount |
Bytes left to read from the connection.
char* rptr |
Pointer used for storing data read from the serial connection.
ubyte wcount |
Bytes left to write on the connection.
char* wptr |
Pointer used to fetch data for writing on the serial connection.