Microchip Technology DM164130-2 User Manual

Page of 42
F1 EVALUATION PLATFORM
USER’S GUIDE
 2010 Microchip Technology Inc.
DS41401B-page 21
Chapter 5.  Hardware Libraries and Drivers
5.1
INTRODUCTION
All of the demo code uses a common set of libraries to provide I
2
C, real-time clock, 
MCP9800 and LCD services. These libraries may be useful for other applications so 
they are documented here. These drivers are located at 
www.microchip.com/F1Eval
.
5.2
I
2
C™ DRIVER
The I
2
C driver allows I
2
C requests to be queued and then handled either by interrupts 
or by polling. The driver is configured during compilation to support polling or interrupts. 
The I
2
C and LCD demos configure the driver for interrupt mode. The Combined demo 
polls the I
2
C handler within the MCP9800 driver.
5.3
MCP9800 DRIVER
The MCP9800 driver uses the I
2
C driver to get the current temperature. The 
mcp9800_get_temp
 function is fully blocking, so once a request is queued, the driver 
polls the I
2
C subsystem until the data is complete. If the I
2
C driver is operating without 
interrupts, the mcp9800_get_temp function repeatedly calls the I2C_handler 
function to process all the I
2
C events. If the I
2
C driver is operating with interrupts, the 
mcp9800_get_temp
 function simply inserts an I2C_TRANSACTION_T into the I
2
transaction queue and waits for the transaction to complete.
5.4
RTCC DRIVER
A software RTCC is managed by the supplied RTCC driver. This driver implements the 
time()
 function required by the C compiler. Time is internally kept as seconds since 
January 1, 1970. Standard C functions can be used to convert the time to the current 
date. This driver has two modes. In the first mode, it expects to be called once per 
second by the Timer1 interrupt. In the second mode, it expects to be called on every 
LCD mode B frame. This allows the RTCC to keep accurate time even if Timer1 is 
being used by some other function, such as the BLDC motor driver.
5.5
LCD DRIVER
The LCD driver contains the initialization code required for the LCD peripheral and the 
mapping code required to control the 3.5-digit LCD supplied with this demo board. It is 
a good starting point for the LCD driver your unique application will require.