-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi2c0.hpp
37 lines (28 loc) · 990 Bytes
/
i2c0.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _I2C0_H_
#define _I2C0_H_
/* includes */
#include <stdlib.h>
#include <stdint.h>
#include "LPC17xx.h"
/* defines */
#define MODE_100kbps 100000
#define MODE_400kbps 400000
#define MODE_1Mbps 1000000
/* typedefs */
/* functions */
// Initialize the I2C hardware.
// see 'readme'
void i2c0_init(uint32_t i2c_freq, uint8_t int_pri);
// Performs a I2C master send function.
// Returns the number of bytes sent successfully.
// Returns 0xFFFFFFFF if slave did not response on bus.
// This is NOT thread safe.
uint32_t i2c0_send(uint8_t address, uint8_t* buffer, uint32_t length);
// Performs a I2C master receive function.
// Returns the number of bytes received successfully.
// Returns 0xFFFFFFFF if slave did not response on bus.
// This is NOT thread safe.
uint32_t i2c0_recv(uint8_t address, uint8_t* buffer, uint32_t length);
/*** DEBUG ***/uint8_t* i2c_buf(void);
/*** DEBUG ***/uint32_t i2c_pos(void);
#endif /* _I2C0_H_ */