mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Implemented setClock for the Due as well
This allows users to change the I2C clock frequency
This commit is contained in:
parent
f9cdc5ea00
commit
9d20959b6a
@ -96,7 +96,7 @@ TwoWire::TwoWire(Twi *_twi, void(*_beginCb)(void)) :
|
||||
twi(_twi), rxBufferIndex(0), rxBufferLength(0), txAddress(0),
|
||||
txBufferLength(0), srvBufferIndex(0), srvBufferLength(0), status(
|
||||
UNINITIALIZED), onBeginCallback(_beginCb) {
|
||||
// Empty
|
||||
setClock(100000); // Set clock frequency to 100000 Hz
|
||||
}
|
||||
|
||||
void TwoWire::begin(void) {
|
||||
@ -106,7 +106,7 @@ void TwoWire::begin(void) {
|
||||
// Disable PDC channel
|
||||
twi->TWI_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;
|
||||
|
||||
TWI_ConfigureMaster(twi, TWI_CLOCK, VARIANT_MCK);
|
||||
TWI_ConfigureMaster(twi, twiClock, VARIANT_MCK);
|
||||
status = MASTER_IDLE;
|
||||
}
|
||||
|
||||
@ -127,6 +127,10 @@ void TwoWire::begin(int address) {
|
||||
begin((uint8_t) address);
|
||||
}
|
||||
|
||||
void TwoWire::setClock(uint32_t frequency) {
|
||||
twiClock = frequency;
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) {
|
||||
if (quantity > BUFFER_LENGTH)
|
||||
quantity = BUFFER_LENGTH;
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
void begin();
|
||||
void begin(uint8_t);
|
||||
void begin(int);
|
||||
void setClock(uint32_t);
|
||||
void beginTransmission(uint8_t);
|
||||
void beginTransmission(int);
|
||||
uint8_t endTransmission(void);
|
||||
@ -99,7 +100,7 @@ private:
|
||||
TwoWireStatus status;
|
||||
|
||||
// TWI clock frequency
|
||||
static const uint32_t TWI_CLOCK = 100000;
|
||||
uint32_t twiClock;
|
||||
|
||||
// Timeouts (
|
||||
static const uint32_t RECV_TIMEOUT = 100000;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
setClock KEYWORD2
|
||||
beginTransmission KEYWORD2
|
||||
endTransmission KEYWORD2
|
||||
requestFrom KEYWORD2
|
||||
|
Loading…
Reference in New Issue
Block a user