hsk-libs-dev  270
High Speed Karlsruhe XC878 library collection
Macros | Functions | Variables
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

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

§ BIT_CIS

#define BIT_CIS   4

MODPISEL3 Slave Mode Clock Input Select bits.

§ BIT_EIR

#define BIT_EIR   0

IRCON1 Error Interrupt Flag for SSC bit.

§ BIT_EIREN

#define BIT_EIREN   0

MODIEN Error Interrupt Enable Bit for SSC.

§ BIT_EN

#define BIT_EN   7

SSC_CONH_O Enable Bit.

§ BIT_LB

#define BIT_LB   7

SSC_CONL Loop Back Control bit.

Half-duplex mode when set.

§ BIT_MIS

#define BIT_MIS   0

MODPISEL3 Master Mode Input Select bits.

§ BIT_MS

#define BIT_MS   6

SSC_CONH_P Master Select bit.

§ BIT_RIR

#define BIT_RIR   2

IRCON1 Receive Interrupt Flag for SSC bit.

§ BIT_RIREN

#define BIT_RIREN   2

MODIEN Receive Interrupt Enable Bit for SSC.

§ BIT_RMAP

#define BIT_RMAP   0

SYSCON0 Special Function Register Map Control bit.

§ BIT_SIS

#define BIT_SIS   2

MODPISEL3 Slave Mode Input Select bits.

§ BIT_SSC_DIS

#define BIT_SSC_DIS   1

PMCON1 Disable Request bit.

§ BIT_TIR

#define BIT_TIR   1

IRCON1 Transmit Interrupt Flag for SSC bit.

§ BIT_TIREN

#define BIT_TIREN   1

MODIEN Transmit Interrupt Enable Bit for SSC.

§ CNT_SEL

#define CNT_SEL   2

Input Select bit count.

Function Documentation

§ hsk_ssc_disable()

void hsk_ssc_disable ( )

Turn the SSC module off.

§ hsk_ssc_enable()

void hsk_ssc_enable ( )

Turn the SSC module on.

§ hsk_ssc_init()

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

§ hsk_ssc_ports()

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

§ hsk_ssc_talk()

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

§ ISR_hsk_ssc()

void ISR_hsk_ssc ( void  )

Transmit and receive interrupt.

Variable Documentation

§ bufState

bufState
static

Keeps the SSC communication state.

§ rcount

ubyte rcount

Bytes left to read from the connection.

§ rptr

char* rptr

Pointer used for storing data read from the serial connection.

§ wcount

ubyte wcount

Bytes left to write on the connection.

§ wptr

char* wptr

Pointer used to fetch data for writing on the serial connection.