Compare commits
17 Commits
v1.0.0
...
56a61b6163
Author | SHA1 | Date | |
---|---|---|---|
56a61b6163 | |||
fd7969779d | |||
e5303e4090 | |||
700848f9b2 | |||
74408d8f32 | |||
a0873bbe36 | |||
0b6e04a1c0 | |||
aae08f710a | |||
3e31aa3683 | |||
1284e245cc | |||
4547f6f510 | |||
851605cae3 | |||
9976c50da0 | |||
57c19ada39 | |||
b75fc68c80 | |||
5ef69ec6c7 | |||
13d46a62ef |
Binary file not shown.
Binary file not shown.
32
README.md
32
README.md
@@ -1,34 +1,7 @@
|
|||||||
# FreeRTOS based AVR library for I2C bus
|
# zh_avr_i2c
|
||||||
|
|
||||||
## Features
|
AVR library for I2C bus.
|
||||||
|
|
||||||
1. Simple read and write data.
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
1. [zh_avr_free_rtos](http://git.zh.com.ru/avr_libraries/zh_avr_free_rtos)
|
|
||||||
|
|
||||||
## Using
|
|
||||||
|
|
||||||
In an existing project, run the following command to install the component:
|
|
||||||
|
|
||||||
```text
|
|
||||||
cd ../your_project/lib
|
|
||||||
git clone http://git.zh.com.ru/avr_libraries/zh_avr_free_rtos
|
|
||||||
git clone http://git.zh.com.ru/avr_libraries/zh_avr_i2c
|
|
||||||
```
|
|
||||||
|
|
||||||
In the application, add the component:
|
|
||||||
|
|
||||||
```c
|
|
||||||
#include "zh_avr_i2c.h"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
Master read and write data:
|
|
||||||
|
|
||||||
```c
|
|
||||||
#include "avr/io.h"
|
#include "avr/io.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "zh_avr_i2c.h"
|
#include "zh_avr_i2c.h"
|
||||||
@@ -92,4 +65,3 @@ int main(void)
|
|||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
@@ -39,37 +39,15 @@ extern "C"
|
|||||||
avr_err_t zh_avr_i2c_master_init(const bool pullup);
|
avr_err_t zh_avr_i2c_master_init(const bool pullup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Probe I2C address.
|
* @brief Probe I2C address, if address is correct and ACK is received, this function will return AVR_OK.
|
||||||
*
|
*
|
||||||
* @param[in] addr Address I2C device.
|
* @param[in] addr Address I2C device address that you want to probe.
|
||||||
* @param[in] xTicksToWait Wait timeout in FreeRTOS ticks.
|
* @param[in] xTicksToWait Wait timeout in FreeRTOS ticks.
|
||||||
*
|
*
|
||||||
* @return AVR_OK if success or an error code otherwise.
|
* @return AVR_OK if success or an error code otherwise.
|
||||||
*/
|
*/
|
||||||
avr_err_t zh_avr_i2c_master_probe(const uint8_t addr, TickType_t xTicksToWait);
|
avr_err_t zh_avr_i2c_master_probe(const uint8_t addr, TickType_t xTicksToWait);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Send data to I2C address.
|
|
||||||
*
|
|
||||||
* @param[in] addr Address I2C device.
|
|
||||||
* @param[in] data Pointer to data for send.
|
|
||||||
* @param[in] size Data size.
|
|
||||||
* @param[in] xTicksToWait Wait timeout in FreeRTOS ticks.
|
|
||||||
*
|
|
||||||
* @return AVR_OK if success or an error code otherwise.
|
|
||||||
*/
|
|
||||||
avr_err_t zh_avr_i2c_master_transmit(const uint8_t addr, uint8_t *data, uint8_t size, TickType_t xTicksToWait);
|
avr_err_t zh_avr_i2c_master_transmit(const uint8_t addr, uint8_t *data, uint8_t size, TickType_t xTicksToWait);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read data from I2C address.
|
|
||||||
*
|
|
||||||
* @param[in] addr Address I2C device.
|
|
||||||
* @param[out] data Pointer to buffer for read.
|
|
||||||
* @param[in] size Data size.
|
|
||||||
* @param[in] xTicksToWait Wait timeout in FreeRTOS ticks.
|
|
||||||
*
|
|
||||||
* @return AVR_OK if success or an error code otherwise.
|
|
||||||
*/
|
|
||||||
avr_err_t zh_avr_i2c_master_receive(const uint8_t addr, uint8_t *data, uint8_t size, TickType_t xTicksToWait);
|
avr_err_t zh_avr_i2c_master_receive(const uint8_t addr, uint8_t *data, uint8_t size, TickType_t xTicksToWait);
|
||||||
|
|
||||||
avr_err_t zh_avr_i2c_master_transmit_register(const uint8_t addr, uint16_t *reg, uint8_t *data, uint8_t size, TickType_t xTicksToWait); // To Do
|
avr_err_t zh_avr_i2c_master_transmit_register(const uint8_t addr, uint16_t *reg, uint8_t *data, uint8_t size, TickType_t xTicksToWait); // To Do
|
||||||
|
BIN
Доступ к портам I_O AVR на языке C (GCC, WinAVR).pdf
Normal file
BIN
Доступ к портам I_O AVR на языке C (GCC, WinAVR).pdf
Normal file
Binary file not shown.
BIN
Интерфейсная шина IIC (I2C) _.pdf
Normal file
BIN
Интерфейсная шина IIC (I2C) _.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user