spinnaker_tools (BMP) latest
SpiNNaker BMP firmware
Loading...
Searching...
No Matches
Macros | Functions | Variables
bmp_i2c.c File Reference

I2C peripheral handling for BC&MP. More...

#include "lpc17xx.h"
#include "lpc17xx_clkpwr.h"
#include "bmp.h"

Macros

#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.
 

Functions

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.
 

Variables

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.
 

Detailed Description

I2C peripheral handling for BC&MP.

Author
Steve Temple, APT Group, School of Computer Science

Function Documentation

◆ wait_i2c()

static void wait_i2c ( LPC_I2C_TypeDef *restrict  i2c)
static

Wait for I2C to be ready.

Parameters
[in]i2cWhich 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]i2cWhich I2C port to poll
[in]ctrlControl 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]i2cWhich I2C port to send via
[in]ctrlControl word
[in]addrDestination address
[in]lengthNumber of bytes to write
[in]bufBuffer 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]i2cWhich I2C port to receive via
[in]ctrlControl word
[in]addrSource address
[in]lengthNumber of bytes to receive
[in]bufBuffer 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]i2cWhich I2C port to use
[in]addrWhat 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]addrAddress to read from
[in]countNumber of bytes to read
[in]bufBuffer 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]addrAddress to write to
[in]countNumber of bytes to write
[in]bufBuffer 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]cControl byte to write

◆ lcd_putc()

void lcd_putc ( uint32_t  c)

Write a character to the LCD. Buffers.

Parameters
[in]cThe character to write

Variable Documentation

◆ lcd_init

const uint8_t lcd_init[]
static
Initial value:
= {
0x38,
0x00,
0x39,
0x14,
0x70,
0x6c,
0x56,
0x0c,
0x01
}

LCD initialisation descriptor.