Silicon Laboratories SI2493/57/34/15/04, SI2494/39 Software Description, Hardware Access Layer

Models: SI2493/57/34/15/04 SI2494/39

1 304
Download 304 pages 21.65 Kb
Page 292
Image 292

AN93

Software Description

Hardware Access Layer

This layer contains all the routines to access the MCU and modem hardware at the most basic level. The application layer typically does not need to access these functions directly. It consists of two source files:

MCU_hardware.c

modem_hardware.c

MCU_hardware.c

This sample code will work only on the Silicon Labs MCU C8051F12xx platform used for this example. This file contains code specific to the MCU hardware configuration such as port configuration, oscillator configuration, timers, UART, GPIOs, etc.

modem_hardware.c

This code can be ported to other applications with minimal changes needed to compile on a given host platform. This file contains code to read from or write to the modem. The two functions below provide basic access to the modem's Hardware Interface Registers:

char readModem( tHIRREG eHIR ): This is the main access point for unconditionally reading the modem's data and status registers in parallel or SPI mode. The function reads the HIR0 when eHIR is HIR0 (0) and the HIR1 when eHIR is HIR1 (1).

void writeModem( tHIRREG eHIR, char val, char mask ): This is the main access point for unconditionally writing the modem's data and control registers in parallel or SPI mode. The parameter eHIR can be HIR0 (0) or HIR1 (1). When writing to the HIR1, an optional mask value allows first reading the HIR1 from the modem by calling readModem(), and then setting or clearing only those bits that are high in mask. Defined values for mask are:

#define SiCTSb 0x01 // Clear to

send (active low)

#define SiRTSb

0x02

// Request to send (active low)

#define SiESC

0x04

// Escape to command mode

#define SiINT

0x08

// Software

interrupt

#define SiINTM

0x10

// Enable software interrupt

#define SiREM

0x20

// Receive FIFO empty

#define SiTXE

0x40

// Transmit

FIFO almost empty interrupt

#define SiRXF

0x80

// Receive FIFO almost full interrupt

Boolean-OR combinations of the above are possible. This allows setting and/or clearing several bits simultaneously. Thus a mask value of 0xFF results in all bits of val being written to the HIR1, and a mask value of zero reads the HIR1 and simply rewrites the value just read, ignoring val. The mask parameter is ignored when writing to the HIR0.

Interrupt Service and Polling Layer

Sample code for this layer can be found in the ISR_and_Polling.c file. This code can be ported to other applications with minimal changes needed to compile on the host platform. This block contains the interrupt service routines for both modem access and MCU to PC UART access. Except for modemCommunicationUpdate(), the application layer typically does not need to access these functions directly. The access mode is interrupt driven by default. In order to select polling mode, the system must set the global variable pollingNotInterruptMode to a nonzero value. The software is designed to allow switching back and forth between polling and interrupt modes. If only one mode is ever used, the code can be simplified accordingly. The next two sections detail out the functioning of the polling and interrupt modes.

292

Rev. 1.3

Page 292
Image 292
Silicon Laboratories SI2493/57/34/15/04 Software Description, Hardware Access Layer, Interrupt Service and Polling Layer