hsk_libs-dev  163:b63ae088cc97
High Speed Karlsruhe XC878 library collection
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
hsk_ssc.c File Reference

HSK Synchronous Serial Interface implementation. More...

#include <Infineon/XC878.h>
#include "hsk_ssc.h"
Include dependency graph for hsk_ssc.c:

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...
 

Detailed Description

HSK Synchronous Serial Interface implementation.

Note
The SFRs SSC_CONx_O and SSC_CONx_P refer to the same register address. The different suffixes signify the operation and programming modes in which the register exposes different bits.
Author
kami

Macro Definition Documentation

#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.

Function Documentation

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.

Parameters
baudThe timer reload value for the baud rate generator, use SSC_BAUD to generate this value
configThe SSC configuration byte, use SSC_CONF to generate it
modeSelect master or slave operation
void hsk_ssc_ports ( const ubyte  ports)

Configure the I/O ports of the SSC unit.

Warning
Do not use when the SSC is enabled.
Parameters
portsSelects 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:

char xdata buffer[] = "20 character buffer.";
hsk_ssc_talk(buffer, sizeof(buffer) - 1);

Note that char must not be const and that $sizeof(buffer) - 1$ is used to prevent sending and overwriting the terminal 0 character. There may be cases where a terminal 0 character is desired.

Parameters
bufferThe rx/tx transmission buffer
lenThe length of the buffer
void ISR_hsk_ssc ( void  )

Transmit and receive interrupt.

Variable Documentation

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.