You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.4 KiB

3 months ago
#ifndef OWI_H
#define OWI_H
#include "r_cg_macrodriver.h"
#include "r_cg_serial.h"
#include "r_cg_port.h"
#include <stdint.h>
/* =========================================================
* OWI GPIO: P70 (P7.0) + HW Open-Drain (POM7.0)
* ========================================================= */
#define OWI_PORT_P P7 /* port data (read/write latch) */
#define OWI_PORT_PM PM7 /* port mode (1=input, 0=output) */
#define OWI_PORT_PU PU7 /* pull-up enable */
#define OWI_PORT_POM POM7 /* open-drain enable */
/* P70 = bit0 */
#define OWI_PIN_MASK (1u << 0)
/* =========================================================
* Timing ( )
* ========================================================= */
2 months ago
#define OWI_BIT_PERIOD_US 1200u
3 months ago
#define TBIT OWI_BIT_PERIOD_US
2 months ago
#define TLOW_0 ((TBIT * 3u) / 4u) /* 75us (double calc) */
#define TLOW_1 ((TBIT * 1u) / 4u) /* 25us */
3 months ago
#define TSTOP_LOW (TBIT * 2) /* 200us */
#define TIDLE (TBIT * 3) /* 300us */
#define TSTART_HOLD 50u
2 months ago
#define SECURE_HIGH (2u * TBIT)
3 months ago
#define SECURE_TOGGLE_COUNT 3u
2 months ago
#define SECURE_TOGGLE_LOW (TBIT / 4u)
#define SECURE_TOGGLE_HIGH (TBIT / 5u)
3 months ago
2 months ago
#define OWI_STRONG_HIGH_US 5u /* 10~80us 범위에서 튜닝 */
3 months ago
/* =========================================================
* External dependencies
* ========================================================= */
#ifndef RAM_BYTES
#define RAM_BYTES 3
#endif
/* =========================================================
* API
* ========================================================= */
void GPIO_Clear(void);
void GPIO_Input(void);
int GPIO_Read(void);
void OWI_Init(uint32_t bit_time_us);
void OWI_Start(void);
void OWI_Stop(void);
void OWI_SecureStop(void);
void OWI_WriteBit(int bit);
void OWI_WriteByte(uint8_t data);
uint8_t OWI_ReadBit(void);
uint8_t OWI_ReadByte(void);
void OWI_T_ReadBytesAndPrint(int length);
void OWI_ReadBytesAndPrint(int length, uint8_t id);
void OWI_T_CommandMode(const uint8_t *tx_data, uint8_t tx_len, uint8_t id);
void OWI_CommandMode (const uint8_t *tx_data, uint8_t tx_len, uint8_t id);
void OWI_A_CommandMode(const uint8_t *tx_data, uint8_t tx_len, uint8_t id);
void OWI_disable(void);
2 months ago
/* strong high kick (push assist) */
void GPIO_ForceHighKick(void);
3 months ago
#endif /* OWI_H */