This document describes the HCL elements of the STW8110x HCL API included in the
STW8110x evaluation kit. This document is intended for people using the STW8110x digital
bus interfaces. It proposes an abstraction of the hardware in order to allow a user to use all
the facilities provided by the HW IP.
The document provides:
■ A brief description of the hardware
■ An overview of concepts on which the STW8110x HCL API is based
■ A description and explanation of all API types and functions
It is highly recommended to read the STW81101, STW81102 or STW81103 datasheet
before continuing to read this document. This API is a simple abstraction of the principles
presented in these datasheet s.
The STW8110x device has two embedded digital bus interfaces (I
their internal registers to be programmed. Each of these interfaces has its own dedicated
protocol which must be followed to program the device correctly. For details of the
STW8110x register and SPI and I
1.1 Content
2
C protocols, refer to the relevant datasheet.
2
C and SPI) which allow
Three files are available in this package. A fourth file must be created by the user with
implementation of I
Figure 1.Files available with this package
2
C and SPI functions according to the master interface.
1.1.1 Digital bus interface header file
Contains declarations of functions to be implemented by the user (refer to
complete listing). This subsection describes the tasks that the functions must accomplish.
For more details about the digital bus protocol flow and configuration to apply to your master
interface (as frequency) please refer to the STW81101, STW81102 or STW81103
datasheet.
I2C mode
t_I2C_Ack I2C_Send_data(unsigned char *data, int nb_bytes)
{
// 1 - Send Start Bit
// 2 - loop i=1 to i=nb_bytes
//a - send data[i]
//b - wait acknowledge of slave
// 3 - Send Stop Bit
// return ACK, or NO_ACK if acknowledge hasn’t been received
// 1 - Send Start Bit
// 2 - send Add
// 3 - wait acknowledge of slave
5/32
STW8110x API packageAN2491
// 4 - read received data and affect it to *data
// 3 - Send Stop Bit
// return ACK, or NO_ACK if acknowledge hasn’t been received
}
SPI mode
void SPI_Send_data(unsigned int data)
{
// Send data (32bits) on SPI bus
}
1.1.2 STW8110x API header file
Contains declaration of functions, structures and defines necessary to the device driver.
(Refer to
Section 7
for a complete listing).
1.1.3 STW8110x API source file
Contains the C code of device driver.
1.2 How to use the STW8110x API
1.Add the API in your project (STW8110x.c, STW8110x.h, Digital_Bus_interface.h).
2. Create a file (Digital_Bus_interface.c) with functions to implement according your
master interface.
3. Include the STW8110x header file (#include “STW8110x.h”) in the file which uses the
API functions.
4. Use dedicated functions to program the device (see examples in
Section 6
).
6/32
AN2491API overview
2 API overview
Note:To ensure the correct usage of this HCL API, it is HIGHLY recommended to use this API in
the debug mode first (by use of __DEBUG preprocessor as described in Section 2.5). Only
after the application has executed successfully in debug mode should the STW8110x driver
be run in release mode.
The API contains 4 types of functions:
●Functions related to the global initialization of STW8110x
●Functions related to the configuration of STW8110x
●Functions related to extraction of the STW8110x configuration information
●Functions related to STW8110x debug management
2.1 Global initialization functions
STW8110x_Init(); initializes the data structures of the STW8110x HCL.
2.2 Configuration functions
Configure_STW8110x(); configures the STW8110x device.
●STW8110x_Get_Fout_value(); gets output frequency according selected configuration.
●I2C_Read_Status_Register(); obtains information about read-only register (I
2.4 Debug management functions
STW8110x_ProcessError (); manages possible errors of the STW8110x device driver.
2
C mode).
7/32
API overviewAN2491
2.5 Driver targets and compilation options
The driver source files can work in several environments. There are three possible targets
for which the driver compilation options (#define) customize the code for the target.
●The platform - represents the IC (STW81101, STW81102, STW81103).
●The interface - represents digital interface used to program the device (I
●The mode - identifies if the code is being compiled for debug or release mode.