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.
75 lines
2.3 KiB
75 lines
2.3 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 (기존 네 값 유지)
|
||
|
|
* ========================================================= */
|
||
|
|
#define OWI_BIT_PERIOD_US 100u
|
||
|
|
#define TBIT OWI_BIT_PERIOD_US
|
||
|
|
#define TLOW_0 (TBIT * 0.75) /* 75us (double calc) */
|
||
|
|
#define TLOW_1 (TBIT * 0.25) /* 25us */
|
||
|
|
#define TSTOP_LOW (TBIT * 2) /* 200us */
|
||
|
|
#define TIDLE (TBIT * 3) /* 300us */
|
||
|
|
#define TSTART_HOLD 50u
|
||
|
|
#define SECURE_HIGH 250u
|
||
|
|
#define SECURE_TOGGLE_COUNT 3u
|
||
|
|
#define SECURE_TOGGLE_LOW 40u
|
||
|
|
#define SECURE_TOGGLE_HIGH 60u
|
||
|
|
|
||
|
|
/* =========================================================
|
||
|
|
* External dependencies
|
||
|
|
* ========================================================= */
|
||
|
|
#ifndef RAM_BYTES
|
||
|
|
#define RAM_BYTES 3
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* =========================================================
|
||
|
|
* API
|
||
|
|
* ========================================================= */
|
||
|
|
void OWI_EnablePower(void); /* no-op */
|
||
|
|
void OWI_DisablePower(void); /* no-op */
|
||
|
|
|
||
|
|
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);
|
||
|
|
void OWI_Diagnostic(uint8_t id);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#endif /* OWI_H */
|