Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
da2fd0d2a8 |
@@ -7,6 +7,7 @@
|
||||
## Dependencies
|
||||
|
||||
1. [zh_avr_free_rtos](http://git.zh.com.ru/avr_libraries/zh_avr_free_rtos)
|
||||
2. [zh_avr_common](http://git.zh.com.ru/avr_libraries/zh_avr_common)
|
||||
|
||||
## Using
|
||||
|
||||
@@ -16,6 +17,7 @@ In an existing project, run the following command to install the component:
|
||||
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
|
||||
git clone http://git.zh.com.ru/avr_libraries/zh_avr_common
|
||||
```
|
||||
|
||||
In the application, add the component:
|
||||
|
@@ -5,30 +5,14 @@
|
||||
#include "avr/io.h"
|
||||
#include "avr/interrupt.h"
|
||||
#include "stdbool.h"
|
||||
#include "avr_err.h"
|
||||
#include "avr_bit_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AVR_FAIL = -1,
|
||||
AVR_OK,
|
||||
AVR_ERR_NO_MEM,
|
||||
AVR_ERR_INVALID_ARG,
|
||||
AVR_ERR_INVALID_STATE,
|
||||
AVR_ERR_INVALID_SIZE,
|
||||
AVR_ERR_NOT_FOUND,
|
||||
AVR_ERR_NOT_SUPPORTED,
|
||||
AVR_ERR_TIMEOUT,
|
||||
AVR_ERR_INVALID_RESPONSE,
|
||||
AVR_ERR_INVALID_CRC,
|
||||
AVR_ERR_INVALID_VERSION,
|
||||
AVR_ERR_NOT_FINISHED,
|
||||
AVR_ERR_NOT_ALLOWED
|
||||
} avr_err_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize I2C bus.
|
||||
*
|
||||
|
@@ -1 +1 @@
|
||||
1.0.0
|
||||
1.1.0
|
14
zh_avr_i2c.c
14
zh_avr_i2c.c
@@ -1,15 +1,9 @@
|
||||
#include "zh_avr_i2c.h"
|
||||
|
||||
#define ZH_ERROR_CHECK(cond, err, ...) \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
return err; \
|
||||
}
|
||||
|
||||
#define I2C_OK 0x01
|
||||
#define I2C_NACK 0x02
|
||||
#define I2C_COLLISION 0x04
|
||||
#define I2C_BUS_FAIL 0x08
|
||||
#define I2C_OK AVR_BIT0
|
||||
#define I2C_NACK AVR_BIT1
|
||||
#define I2C_COLLISION AVR_BIT2
|
||||
#define I2C_BUS_FAIL AVR_BIT3
|
||||
|
||||
#define I2C_START ((1 << TWINT) | (1 << TWEN) | (1 << TWIE))
|
||||
#define I2C_MASTER_READ 1
|
||||
|
Reference in New Issue
Block a user