diff options
author | Stephane D'Alu <sdalu@sdalu.com> | 2016-07-11 23:09:07 +0200 |
---|---|---|
committer | Stephane D'Alu <sdalu@sdalu.com> | 2016-07-11 23:09:07 +0200 |
commit | 8eabdabb052c686bb1dae89c81bcb92b7f02f413 (patch) | |
tree | 56f9ee7f13b14b616a61666f8c73a67386fec279 /os/hal | |
parent | 5923ee5d506d91431d8a6d4ab26e3054fc380963 (diff) | |
download | ChibiOS-Contrib-8eabdabb052c686bb1dae89c81bcb92b7f02f413.tar.gz ChibiOS-Contrib-8eabdabb052c686bb1dae89c81bcb92b7f02f413.tar.bz2 ChibiOS-Contrib-8eabdabb052c686bb1dae89c81bcb92b7f02f413.zip |
moved i2c to LLD
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/ports/NRF5/LLD/hal_i2c_lld.c (renamed from os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c) | 48 | ||||
-rw-r--r-- | os/hal/ports/NRF5/LLD/hal_i2c_lld.h (renamed from os/hal/ports/NRF5/NRF51822/hal_i2c_lld.h) | 4 | ||||
-rw-r--r-- | os/hal/ports/NRF5/NRF51822/platform.mk | 4 | ||||
-rw-r--r-- | os/hal/ports/NRF5/NRF52832/platform.mk | 4 |
4 files changed, 40 insertions, 20 deletions
diff --git a/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c b/os/hal/ports/NRF5/LLD/hal_i2c_lld.c index 3092b73..6412844 100644 --- a/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c +++ b/os/hal/ports/NRF5/LLD/hal_i2c_lld.c @@ -15,8 +15,8 @@ */
/**
- * @file NRF51822/i2c_lld.c
- * @brief NRF51822 I2C subsystem low level driver source.
+ * @file NRF5/LLD/hal_i2c_lld.c
+ * @brief NRF5 I2C subsystem low level driver source.
*
* @addtogroup I2C
* @{
@@ -33,10 +33,10 @@ /*===========================================================================*/
/* These macros are needed to see if the slave is stuck and we as master send dummy clock cycles to end its wait */
-#define I2C_HIGH(p) do { NRF_GPIO->OUTSET = (1UL << (p)); } while(0) /*!< Pulls I2C line high */
-#define I2C_LOW(p) do { NRF_GPIO->OUTCLR = (1UL << (p)); } while(0) /*!< Pulls I2C line low */
-#define I2C_INPUT(p) do { NRF_GPIO->DIRCLR = (1UL << (p)); } while(0) /*!< Configures I2C pin as input */
-#define I2C_OUTPUT(p) do { NRF_GPIO->DIRSET = (1UL << (p)); } while(0) /*!< Configures I2C pin as output */
+#define I2C_HIGH(p) do { IOPORT1->OUTSET = (1UL << (p)); } while(0) /*!< Pulls I2C line high */
+#define I2C_LOW(p) do { IOPORT1->OUTCLR = (1UL << (p)); } while(0) /*!< Pulls I2C line low */
+#define I2C_INPUT(p) do { IOPORT1->DIRCLR = (1UL << (p)); } while(0) /*!< Configures I2C pin as input */
+#define I2C_OUTPUT(p) do { IOPORT1->DIRSET = (1UL << (p)); } while(0) /*!< Configures I2C pin as output */
#define I2C_PIN_CNF \
((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
@@ -102,14 +102,14 @@ static void i2c_clear_bus(I2CDriver *i2cp) const I2CConfig *cfg = i2cp->config;
int i;
- NRF_GPIO->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF;
- NRF_GPIO->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF;
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF;
I2C_HIGH(cfg->sda_pad);
I2C_HIGH(cfg->scl_pad);
- NRF_GPIO->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR;
- NRF_GPIO->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR;
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR;
nrf_delay_us(4);
@@ -165,7 +165,10 @@ static void serve_interrupt(I2CDriver *i2cp) { if(i2c->EVENTS_TXDSENT) {
i2c->EVENTS_TXDSENT = 0;
-
+#if CORTEX_MODEL >= 4
+ (void)i2c->EVENTS_TXDSENT;
+#endif
+
if(--i2cp->txbytes) {
i2c->TXD = *i2cp->txptr++;
@@ -182,6 +185,10 @@ static void serve_interrupt(I2CDriver *i2cp) { if(i2c->EVENTS_RXDREADY) {
i2c->EVENTS_RXDREADY = 0;
+#if CORTEX_MODEL >= 4
+ (void)i2c->EVENTS_RXDREADY;
+#endif
+
*i2cp->rxptr++ = i2c->RXD;
if(--i2cp->rxbytes) {
@@ -194,7 +201,9 @@ static void serve_interrupt(I2CDriver *i2cp) { uint32_t err = i2c->ERRORSRC;
i2c->EVENTS_ERROR = 0;
-
+#if CORTEX_MODEL >= 4
+ (void)i2c->EVENTS_ERROR;
+#endif
if (err & TWI_ERRORSRC_OVERRUN_Msk)
i2cp->errors |= I2C_OVERRUN;
if (err & (TWI_ERRORSRC_ANACK_Msk | TWI_ERRORSRC_DNACK_Msk))
@@ -206,6 +215,9 @@ static void serve_interrupt(I2CDriver *i2cp) { stop_count++;
i2c->EVENTS_STOPPED = 0;
+#if CORTEX_MODEL >= 4
+ (void)i2c->EVENTS_STOPPED;
+#endif
_i2c_wakeup_isr(i2cp);
}
}
@@ -278,11 +290,15 @@ void i2c_lld_start(I2CDriver *i2cp) { i2c_clear_bus(i2cp);
- NRF_GPIO->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF;
- NRF_GPIO->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF;
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF;
i2c->EVENTS_RXDREADY = 0;
i2c->EVENTS_TXDSENT = 0;
+#if CORTEX_MODEL >= 4
+ (void)i2c->EVENTS_RXDREADY;
+ (void)i2c->EVENTS_TXDSENT;
+#endif
i2c->PSELSCL = cfg->scl_pad;
i2c->PSELSDA = cfg->sda_pad;
@@ -330,8 +346,8 @@ void i2c_lld_stop(I2CDriver *i2cp) { nvicDisableVector(I2C_IRQ_NUM);
- NRF_GPIO->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR;
- NRF_GPIO->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR;
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR;
}
}
diff --git a/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.h b/os/hal/ports/NRF5/LLD/hal_i2c_lld.h index f631368..578d69b 100644 --- a/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.h +++ b/os/hal/ports/NRF5/LLD/hal_i2c_lld.h @@ -15,8 +15,8 @@ */
/**
- * @file NRF51822/i2c_lld.h
- * @brief NRF51822 I2C subsystem low level driver header.
+ * @file NRF5/LLD/hal_i2c_lld.h
+ * @brief NRF5 I2C subsystem low level driver header.
*
* @addtogroup I2C
* @{
diff --git a/os/hal/ports/NRF5/NRF51822/platform.mk b/os/hal/ports/NRF5/NRF51822/platform.mk index 587aebd..7305acf 100644 --- a/os/hal/ports/NRF5/NRF51822/platform.mk +++ b/os/hal/ports/NRF5/NRF51822/platform.mk @@ -20,7 +20,7 @@ PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_ext_lld.c endif ifneq ($(findstring HAL_USE_I2C TRUE,$(HALCONF)),) -PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c +PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_i2c_lld.c endif ifneq ($(findstring HAL_USE_ADC TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_adc_lld.c @@ -49,7 +49,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_spi_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_ext_lld.c \ - ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c \ + ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_i2c_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_adc_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \ diff --git a/os/hal/ports/NRF5/NRF52832/platform.mk b/os/hal/ports/NRF5/NRF52832/platform.mk index 38bc015..248027b 100644 --- a/os/hal/ports/NRF5/NRF52832/platform.mk +++ b/os/hal/ports/NRF5/NRF52832/platform.mk @@ -15,6 +15,9 @@ endif ifneq ($(findstring HAL_USE_SPI TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_spi_lld.c endif +ifneq ($(findstring HAL_USE_I2C TRUE,$(HALCONF)),) +PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_i2c_lld.c +endif ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c endif @@ -33,6 +36,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_pal_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_spi_lld.c \ + ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_i2c_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_st_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \ |