-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcf8574.h
31 lines (23 loc) · 825 Bytes
/
pcf8574.h
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
/*
* pcf8574.h
*
* Created on: Aug 26, 2024
* Author: Alixahedi
*/
#ifndef PCF8574_H
#define PCF8574_H
#include "stm32h7xx_hal.h"
#define PCF8574_ADDRESS_BASE 0x40
typedef struct {
I2C_HandleTypeDef *hi2c;
uint8_t address;
uint8_t portState;
} PCF8574_HandleTypeDef;
// توابع کتابخانه
void PCF8574_Init(PCF8574_HandleTypeDef *pcf8574, I2C_HandleTypeDef *hi2c, uint8_t a0, uint8_t a1, uint8_t a2);
void PCF8574_WritePin(PCF8574_HandleTypeDef *pcf8574, uint8_t pin, GPIO_PinState state);
GPIO_PinState PCF8574_ReadPin(PCF8574_HandleTypeDef *pcf8574, uint8_t pin);
void PCF8574_TogglePin(PCF8574_HandleTypeDef *pcf8574, uint8_t pin);
uint8_t PCF8574_ReadPort(PCF8574_HandleTypeDef *pcf8574);
void PCF8574_WritePort(PCF8574_HandleTypeDef *pcf8574, uint8_t value);
#endif // PCF8574_H