chenged to 2 motor velocity-closed-loop; before testing
This commit is contained in:
@@ -4,33 +4,47 @@
|
||||
|
||||
#define DELAY 1
|
||||
#define SDA_PIN_SHIFT 9 // if pa.8 shift8 , if pa.9 shift 9
|
||||
|
||||
uint32_t SCL_PIN, SDA_PIN;
|
||||
uint32_t SDA_IOMUX;
|
||||
GPIO_Regs *PORT;
|
||||
void Set_Ang_Sensor(int Mot) {
|
||||
if (Mot == 0) {
|
||||
PORT = SOFT_I2C_PORT;
|
||||
SDA_IOMUX = SOFT_I2C_SDA_IOMUX;
|
||||
SCL_PIN = SOFT_I2C_CLK_PIN;
|
||||
SDA_PIN = SOFT_I2C_SDA_PIN;
|
||||
} else if (Mot == 1) {
|
||||
}
|
||||
}
|
||||
|
||||
void I2C_ENABLE_OUTPUT_SDA(void) {
|
||||
DL_GPIO_initDigitalOutput(SOFT_I2C_SDA_IOMUX);
|
||||
DL_GPIO_enableOutput(SOFT_I2C_PORT, SOFT_I2C_SDA_PIN);
|
||||
DL_GPIO_initDigitalOutput(SDA_IOMUX);
|
||||
DL_GPIO_enableOutput(PORT, SDA_PIN);
|
||||
}
|
||||
void I2C_ENABLE_INPUT_SDA(void) {
|
||||
DL_GPIO_disableOutput(SOFT_I2C_PORT, SOFT_I2C_SDA_PIN);
|
||||
DL_GPIO_disableOutput(PORT, SDA_PIN);
|
||||
DL_GPIO_initDigitalInputFeatures(
|
||||
SOFT_I2C_SDA_IOMUX, DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
|
||||
SDA_IOMUX, DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
|
||||
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
|
||||
}
|
||||
|
||||
void I2C_W_SCL(uint8_t BitValue) {
|
||||
if (BitValue) {
|
||||
DL_GPIO_setPins(SOFT_I2C_PORT, SOFT_I2C_CLK_PIN);
|
||||
DL_GPIO_setPins(PORT, SCL_PIN);
|
||||
|
||||
} else {
|
||||
DL_GPIO_clearPins(SOFT_I2C_PORT, SOFT_I2C_CLK_PIN);
|
||||
DL_GPIO_clearPins(PORT, SCL_PIN);
|
||||
}
|
||||
delay_us(DELAY);
|
||||
}
|
||||
|
||||
void I2C_W_SDA(uint8_t BitValue) {
|
||||
if (BitValue) {
|
||||
DL_GPIO_setPins(SOFT_I2C_PORT, SOFT_I2C_SDA_PIN);
|
||||
DL_GPIO_setPins(PORT, SDA_PIN);
|
||||
|
||||
} else {
|
||||
DL_GPIO_clearPins(SOFT_I2C_PORT, SOFT_I2C_SDA_PIN);
|
||||
DL_GPIO_clearPins(PORT, SDA_PIN);
|
||||
}
|
||||
delay_us(DELAY);
|
||||
}
|
||||
@@ -38,7 +52,7 @@ void I2C_W_SDA(uint8_t BitValue) {
|
||||
// 读取时钟线数据
|
||||
uint8_t I2C_R_SDA(void) {
|
||||
uint32_t BitValue;
|
||||
BitValue = DL_GPIO_readPins(SOFT_I2C_PORT, SOFT_I2C_SDA_PIN);
|
||||
BitValue = DL_GPIO_readPins(PORT, SDA_PIN);
|
||||
|
||||
return (uint8_t)(BitValue >> 9);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user