|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "debug/printf.h" |
|
|
#include "debug/printf.h" |
|
|
|
|
|
|
|
|
|
|
|
#define PINCONFIG (IOMUXC_PAD_ODE | IOMUXC_PAD_SRE | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_SPEED(0) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3)) |
|
|
|
|
|
|
|
|
void TwoWire::begin(void) |
|
|
void TwoWire::begin(void) |
|
|
{ |
|
|
{ |
|
|
// use 24 MHz clock |
|
|
// use 24 MHz clock |
|
|
|
|
|
|
|
|
setClock(100000); |
|
|
setClock(100000); |
|
|
|
|
|
|
|
|
// Setup SDA register |
|
|
// Setup SDA register |
|
|
*(portControlRegister(hardware.sda_pins[sda_pin_index_].pin)) |= IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3); |
|
|
|
|
|
|
|
|
*(portControlRegister(hardware.sda_pins[sda_pin_index_].pin)) = PINCONFIG; |
|
|
*(portConfigRegister(hardware.sda_pins[sda_pin_index_].pin)) = hardware.sda_pins[sda_pin_index_].mux_val; |
|
|
*(portConfigRegister(hardware.sda_pins[sda_pin_index_].pin)) = hardware.sda_pins[sda_pin_index_].mux_val; |
|
|
if (hardware.sda_pins[sda_pin_index_].select_input_register) { |
|
|
if (hardware.sda_pins[sda_pin_index_].select_input_register) { |
|
|
*(hardware.sda_pins[sda_pin_index_].select_input_register) = hardware.sda_pins[sda_pin_index_].select_val; |
|
|
*(hardware.sda_pins[sda_pin_index_].select_input_register) = hardware.sda_pins[sda_pin_index_].select_val; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// setup SCL register |
|
|
// setup SCL register |
|
|
*(portControlRegister(hardware.scl_pins[scl_pin_index_].pin)) |= IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3); |
|
|
|
|
|
|
|
|
*(portControlRegister(hardware.scl_pins[scl_pin_index_].pin)) = PINCONFIG; |
|
|
*(portConfigRegister(hardware.scl_pins[scl_pin_index_].pin)) = hardware.scl_pins[scl_pin_index_].mux_val; |
|
|
*(portConfigRegister(hardware.scl_pins[scl_pin_index_].pin)) = hardware.scl_pins[scl_pin_index_].mux_val; |
|
|
if (hardware.scl_pins[scl_pin_index_].select_input_register) { |
|
|
if (hardware.scl_pins[scl_pin_index_].select_input_register) { |
|
|
*(hardware.scl_pins[scl_pin_index_].select_input_register) = hardware.scl_pins[scl_pin_index_].select_val; |
|
|
*(hardware.scl_pins[scl_pin_index_].select_input_register) = hardware.scl_pins[scl_pin_index_].select_val; |