Skip to content

Commit

Permalink
fix issue when compiling on Arduino Due (really old) modems, these wi…
Browse files Browse the repository at this point in the history
…ll never support I2C;
  • Loading branch information
gatekeep committed Jun 18, 2023
1 parent c83a409 commit 23ef0a2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion DWT_delay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include "DWT_delay.h"

#if (!defined(__SAM3X8E__) && !defined(__MK20DX256__) && !defined(__MK64FX512__) && !defined(__MK66FX1M0__)) && !defined(ARDUINO_SAM_DUE)

RCC_ClocksTypeDef RCC_Clocks;
uint32_t HCLK_Freq;

Expand Down Expand Up @@ -89,4 +91,5 @@ void DWT_Delay_us(volatile uint32_t microseconds)
while ((DWT->CYCCNT - clk_cycle_start) < microseconds);
}

/* Use DWT_Delay_Init (); and DWT_Delay_us (microseconds) in the main */
/* Use DWT_Delay_Init (); and DWT_Delay_us (microseconds) in the main */
#endif
4 changes: 4 additions & 0 deletions DWT_delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
#ifndef __DWT_DELAY_H__
#define __DWT_DELAY_H__

#if (!defined(__SAM3X8E__) && !defined(__MK20DX256__) && !defined(__MK64FX512__) && !defined(__MK66FX1M0__)) && !defined(ARDUINO_SAM_DUE)

#include "stm32f4xx_rcc.h"

uint32_t DWT_Delay_Init(void);
void DWT_Delay_us(volatile uint32_t microseconds);

#endif

#endif
6 changes: 5 additions & 1 deletion sw_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "sw_i2c.h"
#include "DWT_delay.h"

#if (!defined(__SAM3X8E__) && !defined(__MK20DX256__) && !defined(__MK64FX512__) && !defined(__MK66FX1M0__)) && !defined(ARDUINO_SAM_DUE)

void scl(bool on)
{
GPIO_WriteBit(PORT_SCL, PIN_SCL, on ? Bit_SET : Bit_RESET);
Expand Down Expand Up @@ -158,4 +160,6 @@ bool sw_i2c_write(uint8_t address, uint8_t *data, uint8_t size) {
}
gen_stop();
return false;
}
}

#endif
4 changes: 4 additions & 0 deletions sw_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#if !defined(__SW_I2C_H__)
#define __SW_I2C_H__

#if (!defined(__SAM3X8E__) && !defined(__MK20DX256__) && !defined(__MK64FX512__) && !defined(__MK66FX1M0__)) && !defined(ARDUINO_SAM_DUE)

#include "Globals.h"

// Pin Defs
Expand All @@ -48,4 +50,6 @@
void sw_i2c_init();
bool sw_i2c_write(uint8_t address, uint8_t *data, uint8_t size);

#endif

#endif

0 comments on commit 23ef0a2

Please sign in to comment.