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.
Note:If the field DEFAULT_CONFIG is marked as BOOL_TRUE then the remaining fields
following it may not be used and may not be filled up. Instead the default configuration for
the device (as programmed in STW8110x_Init) will be used. The default configuration is
described in the STW81101, STW81102 and STW81103 datasheets.
12/32
AN2491Structures
4.2 I2C mode
t_stw8110x_I2C_RO_reg
Defines the structure of STW8110x read-only register.
typedef struct
{
t_stw8110x_Device_TypeDEV_TYPE; // Device identifier bit
t_stw8110x_PLL_StatusLOCK_DET; // '1' when PLL is locked
t_uint8INT_CAL; //VCO ctrl word internal value
} t_stw8110x_I2C_RO_reg ;
13/32
FunctionsAN2491
5 Functions
STW8110x has 3 bits which are programmable in I2C mode. This means that eight
STW8110x devices should be connected to the same I
The choice of device is performed via the 3 programmable address bits (A2, A1, A0 set to
0V (0) or 3.3V (1)). This is why, if I
supplementary parameter which specifies the address of the device to access I2C_ADD (0
to 7).
The routine initializes the device configuration descriptor. If I
selected, a read of the read only register is performed to check if the selected
target matches with the accessed device.
STW8110x_ProcessError(st_error);
}
//******* Configuration I **********
// Set configuration structure of device
// Default config is selected
Device_config.DEFAULT_CONFIG = BOOL_TRUE;
// Configure the device
st_error = Configure_STW8110x(Device_config, DEVICE_ADD);
if(st_error != OK)
{
STW8110x_ProcessError(st_error);
}
//******* Configuration II **********
// Set configuration structure of device.
// Config is set to ouput frequency 843.75MHz, reference clock 60MHz
Device_config.DEFAULT_CONFIG = BOOL_FALSE;
Device_config.DEVICE_FUNCTIONAL_MODE = VCO_A_FREQ_DIV_4;
Device_config.VCO_CALIBRATION_EN = VCO_CAL_ENABLED;
Device_config.SWALLOW_COUNTER = 8;
Device_config.MAIN_COUNTER = 562;
Device_config.REF_CLOCK_DIV_RATIO = 160;
Device_config.VCO_AMPLITUDE_VOLTAGE = AMPL_2V1;
Device_config.CHARGE_PUMP_CURRENT = CURRENT_8_I_MIN;
Device_config.PRESCALER_MODULUS = PRESCALER_16;
// Configure the device
st_error = Configure_STW8110x(Device_config, DEVICE_ADD);
if(st_error != OK)
{
STW8110x_ProcessError(st_error);
}
// Get output frequency(MHz) according config and reference clock
st_error = STW8110x_Get_Fout_value(Device_config,60,&Fout);
if(st_error != OK)
{
STW8110x_ProcessError(st_error);
19/32
User scenariosAN2491
}
printf("With selected configuration and input freq=60MHz, output
Freq = %fMHz\n",Fout);
// Reading Read Only register of device
st_error = I2C_Read_Status_Register(&ReadOnlyReg, DEVICE_ADD);
if(st_error != OK)
{
STW8110x_ProcessError(st_error);
}
printf("Device Read Only Register Status:\n");
printf("Device ID : %d\n", ReadOnlyReg.DEV_TYPE);
printf("PLL: %s\n", (ReadOnlyReg.LOCK_DET)?"Locked":"Unlocked");
printf("Internal VCO value: %d\n", ReadOnlyReg.INT_CAL);
// Note: If you have selected the DEBUG mode, information is
// automatically displayed, so no printf is needed
#ifdef __INTERFACE_I2C
//
// Definition of the STW8110x I2C ReadOnly register
typedef struct
{
t_stw8110x_Device_TypeDEV_TYPE; // Device identifier bit
t_stw8110x_PLL_StatusLOCK_DET; // '1' when PLL is locked
t_uint8INT_CAL; // internal value of VCO control word
#define bwREF_CLK_DIV_RATIO 10 // Reference clock divider ratio
#define bwPLL_A2 // VCO Amplitude control
#define bwCPSEL3 // charge pump output current control
#define bwPSC_SEL1 // Prescaler modulus select
#define bwINITCAL1 // Test purpose only,must be set to 0
#define bwSERCAL 1 // VCO Calibration Enable
#define bwSELEXTCAL1 // Test purpose only,must be set to 0
#define bwCAL5 // Test purpose only,must be set to 0
#define bsREF_CLK_DIV_RATIO 14 // Reference clock divider ratio
#define bsPLL_A12 // VCO Amplitude control
#define bsCPSEL9 // charge pump output current control
#define bsPSC_SEL8 // Prescaler modulus select
#define bsINITCAL7 // Test purpose only,must be set to 0
#define bsSERCAL 6 // VCO Calibration Enable
#define bsSELEXTCAL5 // Test purpose only,must be set to 0
#define bsCAL0 // Test purpose only,must be set to 0
#define bwPD7 // Reference clock divider ratio
#define bwcount_B111 // main counter
#define bsPD1 // Test purpose only, must be set to 0
#define bscount_B110 // main counter
27/32
STW8110x public header fileAN2491
// REG1
#define bwcount_B10_38 // main counter
#define bscount_B10_30 // main counter
// REG2
#define bwcount_B2_03 // main counter
#define bwcount_A5 // swallow counter
#define bscount_B2_05 // main counter
#define bscount_A0 // swallow counter
// REG3
#define bwREF_CLK_DIV_RATIO9_2 8 // Ref clock divider ratio
#define bsREF_CLK_DIV_RATIO9_2 0 // Ref clock divider ratio
// REG4
#define bwREF_CLK_DIV_RATIO1_0 2 // Ref clock divider ratio
#define bwPLL_A 2 // VCO Amplitude control
#define bwCPSEL 3 // charge pump output current control
#define bwPSC_SEL1 // Prescaler modulus select
#define bsREF_CLK_DIV_RATIO1_0 6 // Reference clock divider ratio
#define bsPLL_A4 // VCO Amplitude control
#define bsCPSEL1 // charge pump output current control
#define bsPSC_SEL0 // Prescaler modulus select
// REG5
#define bwINITCAL1 // Test purpose only,must be set to 0
#define bwSERCAL 1 // VCO Calibration Enable
#define bwSELEXTCAL1 // Test purpose only,must be set to 0
#define bwCAL5 // Test purpose only,must be set to 0
#define bsINITCAL7 // Test purpose only,must be set to 0
#define bsSERCAL 6 // VCO Calibration Enable
#define bsSELEXTCAL5 // Test purpose only,must be set to 0
#define bsCAL0 // Test purpose only,must be set to 0
// REGRO
#define bwDEV_ID 2 // VCO Calibration Enable
#define bwLOCK_DET1 // '1' when PLL is locked
#define bwINTCAL5 // Internal value of VCO control word
#define bsDEV_ID 6 // Dev ID:'00'-> 81101,'01' -> 81102
#define bsLOCK_DET5 // '1' when PLL is locked
#define bsINTCAL0 // Internal value of VCO control word
#endif
// Errors management
void STW8110x_ProcessError(t_stw8110x_error error);
#ifdef __cplusplus
} // allow C++ to use these headers
#endif// __cplusplus
#endif // _STW8110x.H
/**************** End of file – STW8110x.h*************************
#ifdef __INTERFACE_I2C
// Type enumeration regarding Acknowledge of I2C mode
typedef enum
{
NO_ACK,
ACK
} t_I2C_Ack ;
// Function dedicated to send data on I2C bus
// Parameters:
// data: Table of Bytes to send (in)
// nb_bytes: number of bytes to send (in)
// Return:
// ACK if acknowledge is received by master
// NO_ACK if acknowledge isn't received by master
t_I2C_Ack I2C_Send_data(unsigned char *data, int nb_bytes);
// Function dedicated to read data on I2C bus
// Parameters:
// Add: Slave Address to read (in)
// data: Countain the byte read (out)
// Return:
// ACK if acknowledge is received by master
// NO_ACK if acknowledge isn't received by master
t_I2C_Ack I2C_Read_data(unsigned char Add, unsigned char *data);
#endif //__INTERFACE_I2C
#ifdef __INTERFACE_SPI
// Function dedicated to send data on SPI bus
// Parameters:
// data: Data (32 bits) to send (in)
void SPI_Send_data(unsigned int data);
#endif //__INTERFACE_SPI
#endif // _DBI_H
//*********** End of file -Digital_Bus_interface.h**************
30/32
AN2491Definitions
9 Definitions
Table 4.Acronyms used in this document
AcronymDefinition
APIApplication programming interface
HCLHardware component layer
WIDWireless infrastructure division
ICIntegrated circui t
SPI Serial peripheral interface
2
I
CInter-integrated circuit
STW8110xSTW81101, STW81102 or STW81103
10 Revision history
Table 5.Document revision history
DateRevisionChanges
10-Aug-20071Initia l release.
31/32
AN2491
Please Read Carefully:
Information in this document is provided sole ly in connecti on with ST produ cts. STMicro electroni cs NV and its subsi diaries (“ST ”) reserve the
right to make changes , cor recti ons , modif ic ations or improv ement s, t o th is documen t, and the prod ucts an d servic es des crib ed he rein a t any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever rel ating to the choice, selection or use of the ST products and services descri bed herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any pa rt of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with prov isions differen t from the state ments and/or tec hnical featur es set forth in th is document shall immediatel y void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademark s or registered trademarks of ST in various countries.
Information in this document su persedes and replaces all informati on previously supplied.
The ST logo is a registered trade mark of STMicroelectronics. All ot her names are the property of their r es pective owners.