I2C peripheral handling for BC&MP.
More...
#include "lpc17xx.h"
#include "lpc17xx_clkpwr.h"
#include "bmp.h"
|
|
#define | I2C_EE 0xa0 |
| | I2C address of 24LC08 (EEPROM)
|
| |
|
#define | I2C_LCD 0x78 |
| | I2C address of ST7036 (LCD)
|
| |
|
#define | I2C_TS 0x90 |
| | I2C base address of LM75B (temp sensors)
|
| |
|
#define | LCD_SIZE 32 |
| | Size of LCD character buffer.
|
| |
|
|
void | configure_i2c (void) |
| | Set up I2C0 and I2C2 - 25MHz PCLK.
|
| |
| static void | wait_i2c (LPC_I2C_TypeDef *restrict i2c) |
| | Wait for I2C to be ready.
|
| |
| uint32_t | i2c_poll (LPC_I2C_TypeDef *restrict i2c, uint32_t ctrl) |
| | Poll an I2C port.
|
| |
| uint32_t | i2c_send (LPC_I2C_TypeDef *restrict i2c, uint32_t ctrl, uint32_t addr, uint32_t length, const void *buf) |
| | Send a buffer over I2C.
|
| |
| uint32_t | i2c_receive (LPC_I2C_TypeDef *restrict i2c, uint32_t ctrl, uint32_t addr, uint32_t length, void *buf) |
| | Receive a buffer over I2C.
|
| |
| int16_t | read_ts (LPC_I2C_TypeDef *restrict i2c, uint32_t addr) |
| | Read temperature sensor.
|
| |
| uint32_t | read_ee (uint32_t addr, uint32_t count, void *buf) |
| | Read from EEPROM.
|
| |
| uint32_t | write_ee (uint32_t addr, uint32_t count, const void *buf) |
| | Write to EEPROM.
|
| |
|
void | configure_lcd (void) |
| | Configure the LCD.
|
| |
|
static void | lcd_flush (void) |
| | Flush any pending data (i.e., a line of text) to the LCD.
|
| |
| void | lcd_ctrl (uint32_t c) |
| | Write a control byte to the LCD.
|
| |
| void | lcd_putc (uint32_t c) |
| | Write a character to the LCD. Buffers.
|
| |
|
|
static uint8_t | lcd_buf [LCD_SIZE] |
| | Buffer for gathering a line to write to the LCD.
|
| |
|
static uint32_t | lcd_ptr |
| | Write position within lcd_buf.
|
| |
|
bool | lcd_active |
| | Whether the LCD is active; if not, nothing should be sent to the LCD.
|
| |
| static const uint8_t | lcd_init [] |
| | LCD initialisation descriptor.
|
| |
I2C peripheral handling for BC&MP.
- Copyright
- © The University of Manchester - 2012-2015
- Author
- Steve Temple, APT Group, School of Computer Science
◆ wait_i2c()
| static void wait_i2c |
( |
LPC_I2C_TypeDef *restrict |
i2c | ) |
|
|
static |
Wait for I2C to be ready.
- Parameters
-
| [in] | i2c | Which I2C port to wait for |
◆ i2c_poll()
| uint32_t i2c_poll |
( |
LPC_I2C_TypeDef *restrict |
i2c, |
|
|
uint32_t |
ctrl |
|
) |
| |
Poll an I2C port.
- Parameters
-
| [in] | i2c | Which I2C port to poll |
| [in] | ctrl | Control byte |
- Returns
- True if ACK received
◆ i2c_send()
| uint32_t i2c_send |
( |
LPC_I2C_TypeDef *restrict |
i2c, |
|
|
uint32_t |
ctrl, |
|
|
uint32_t |
addr, |
|
|
uint32_t |
length, |
|
|
const void * |
buf |
|
) |
| |
Send a buffer over I2C.
- Parameters
-
| [in] | i2c | Which I2C port to send via |
| [in] | ctrl | Control word |
| [in] | addr | Destination address |
| [in] | length | Number of bytes to write |
| [in] | buf | Buffer of data to write |
- Returns
- true if data was written
◆ i2c_receive()
| uint32_t i2c_receive |
( |
LPC_I2C_TypeDef *restrict |
i2c, |
|
|
uint32_t |
ctrl, |
|
|
uint32_t |
addr, |
|
|
uint32_t |
length, |
|
|
void * |
buf |
|
) |
| |
Receive a buffer over I2C.
- Parameters
-
| [in] | i2c | Which I2C port to receive via |
| [in] | ctrl | Control word |
| [in] | addr | Source address |
| [in] | length | Number of bytes to receive |
| [in] | buf | Buffer of data to receive into |
- Returns
- true if data was received
◆ read_ts()
| int16_t read_ts |
( |
LPC_I2C_TypeDef *restrict |
i2c, |
|
|
uint32_t |
addr |
|
) |
| |
Read temperature sensor.
- Parameters
-
| [in] | i2c | Which I2C port to use |
| [in] | addr | What address to read. (Controls which sensor to read) |
- Returns
- The temperature sensor value
◆ read_ee()
| uint32_t read_ee |
( |
uint32_t |
addr, |
|
|
uint32_t |
count, |
|
|
void * |
buf |
|
) |
| |
Read from EEPROM.
- Parameters
-
| [in] | addr | Address to read from |
| [in] | count | Number of bytes to read |
| [in] | buf | Buffer to read into |
- Returns
- True if the read succeeded
◆ write_ee()
| uint32_t write_ee |
( |
uint32_t |
addr, |
|
|
uint32_t |
count, |
|
|
const void * |
buf |
|
) |
| |
Write to EEPROM.
- Parameters
-
| [in] | addr | Address to write to |
| [in] | count | Number of bytes to write |
| [in] | buf | Buffer to write from |
- Returns
- True if the write succeeded
◆ lcd_ctrl()
| void lcd_ctrl |
( |
uint32_t |
c | ) |
|
Write a control byte to the LCD.
- Parameters
-
| [in] | c | Control byte to write |
◆ lcd_putc()
| void lcd_putc |
( |
uint32_t |
c | ) |
|
Write a character to the LCD. Buffers.
- Parameters
-
| [in] | c | The character to write |
◆ lcd_init
Initial value:= {
0x38,
0x00,
0x39,
0x14,
0x70,
0x6c,
0x56,
0x0c,
0x01
}
LCD initialisation descriptor.