From be0a832f65a8b85b24773d4aa11695017feff47a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 1 Sep 2014 12:07:59 -0600 Subject: [PATCH] Updates to the CC3200-Launchpad configuration for better compatibility --- .../cc3200-launchpad/include/cc3200_utils.h | 4 - configs/cc3200-launchpad/src/cc3200_serial.c | 19 ++--- configs/cc3200-launchpad/src/cc3200_utils.c | 79 +++++++------------ 3 files changed, 37 insertions(+), 65 deletions(-) diff --git a/configs/cc3200-launchpad/include/cc3200_utils.h b/configs/cc3200-launchpad/include/cc3200_utils.h index 18b8ac51c5..d4dc093ef9 100644 --- a/configs/cc3200-launchpad/include/cc3200_utils.h +++ b/configs/cc3200-launchpad/include/cc3200_utils.h @@ -39,8 +39,6 @@ * Pre-processor Definitions ************************************************************************************/ -#define HWREG(x) (*((volatile unsigned long *)(x))) - #define CONSOLE_BAUD_RATE 115200 #define PAD_CONFIG_BASE 0x4402E0A0 @@ -137,8 +135,6 @@ static const unsigned long g_cc3200_pinmap[64] = * Public Functions ************************************************************************************/ -void cc3200_putc(char c); -char cc3200_getc(void); void cc3200_print(char* str); void cc3200_pin_config_set(uint32_t pin, uint32_t pin_strength, uint32_t pin_type); void cc3200_pin_mode_set(uint32_t pin, uint32_t pin_mode); diff --git a/configs/cc3200-launchpad/src/cc3200_serial.c b/configs/cc3200-launchpad/src/cc3200_serial.c index 6a1359ba1f..34e4eaef3f 100644 --- a/configs/cc3200-launchpad/src/cc3200_serial.c +++ b/configs/cc3200-launchpad/src/cc3200_serial.c @@ -47,6 +47,7 @@ #include "chip/cc3200_memorymap.h" #include "tiva_start.h" +#include "up_arch.h" #include "up_internal.h" #include "cc3200_launchpad.h" @@ -71,24 +72,24 @@ static void cc3200_uart0_init(void) { - HWREG(0x44025080) |= 0x01; + putreg32(getreg32(0x44025080) | 0x01, 0x44025080); cc3200_pin_type_uart(PIN_55, PIN_MODE_3); cc3200_pin_type_uart(PIN_57, PIN_MODE_3); - while(HWREG(0x4000C018) & 0x08) + while(getreg32(0x4000C018) & 0x08) { } - HWREG(0x4000C02C) &= ~(0x00000010); - HWREG(0x4000C030) &= ~(0x01 | 0x100 | 0x200); - HWREG(0x4000C030) &= ~(0x20); + putreg32(getreg32(0x4000C02C) & ~(0x00000010), 0x4000C02C); + putreg32(getreg32(0x4000C030) & ~(0x01 | 0x100 | 0x200), 0x4000C030); + putreg32(getreg32(0x4000C030) & ~(0x20), 0x4000C030); - HWREG(0x4000C024) = ((((80000000 * 8) / 115200) + 1) / 2) / 64; - HWREG(0x4000C028) = ((((80000000 * 8) / 115200) + 1) / 2) % 64; + putreg32(((((80000000 * 8) / 115200) + 1) / 2) / 64, 0x4000C024); + putreg32(((((80000000 * 8) / 115200) + 1) / 2) % 64, 0x4000C028); - HWREG(0x4000C02C) = (0x60 | 0x82 | 0x10); - HWREG(0x4000C030) |= (0x01 | 0x100 | 0x200); + putreg32((0x60 | 0x82 | 0x10), 0x4000C02C); + putreg32(getreg32(0x4000C030) | (0x01 | 0x100 | 0x200), 0x4000C030); } /************************************************************************************ diff --git a/configs/cc3200-launchpad/src/cc3200_utils.c b/configs/cc3200-launchpad/src/cc3200_utils.c index 8534483e90..e83030d97b 100644 --- a/configs/cc3200-launchpad/src/cc3200_utils.c +++ b/configs/cc3200-launchpad/src/cc3200_utils.c @@ -39,40 +39,15 @@ #include #include +#include "nuttx/arch.h" +#include "up_arch.h" + #include "cc3200_launchpad.h" /************************************************************************************ * Public Functions ************************************************************************************/ -/************************************************************************************ - * Name: cc3200_putc - ************************************************************************************/ - -void cc3200_putc(char c) -{ - while(HWREG(0x4000C000 + 0x00000018) & 0x00000020) - ; - - HWREG(0x4000C000) = c; -} - -/************************************************************************************ - * Name: cc3200_getc - ************************************************************************************/ - -char cc3200_getc(void) -{ - if (!(HWREG(0x4000C000 + 0x00000018) & 0x00000010)) - { - return HWREG(0x4000C000); - } - else - { - return -1; - } -} - /************************************************************************************ * Name: cc3200_print ************************************************************************************/ @@ -81,7 +56,7 @@ void cc3200_print(char* str) { while (str && *str != '\0') { - cc3200_putc(*str++); + up_putc(*str++); } } @@ -98,15 +73,15 @@ void cc3200_pin_config_set(uint32_t pin, uint32_t pin_strength, uint32_t pin_typ switch (pin_type) { case PIN_TYPE_ANALOG: - HWREG(0x4402E144) |= ((0x80 << pad) & (0x1E << 8)); + putreg32(getreg32(0x4402E144) | ((0x80 << pad) & (0x1E << 8)), 0x4402E144); pad = ((pad << 2) + PAD_CONFIG_BASE); - HWREG(pad) |= 0xC00; + putreg32(getreg32(pad) | 0xC00, pad); break; default: - HWREG(0x4402E144) &= ~((0x80 << pad) & (0x1E << 8)); + putreg32(getreg32(0x4402E144) & ~((0x80 << pad) & (0x1E << 8)), 0x4402E144); pad = ((pad << 2) + PAD_CONFIG_BASE); - HWREG(pad) = ((HWREG(pad) & ~(PAD_STRENGTH_MASK | PAD_TYPE_MASK)) | (pin_strength | pin_type )); + putreg32(((getreg32(pad) & ~(PAD_STRENGTH_MASK | PAD_TYPE_MASK)) | (pin_strength | pin_type )), pad); break; } } @@ -121,7 +96,7 @@ void cc3200_pin_mode_set(uint32_t pin, uint32_t pin_mode) pad = g_cc3200_pinmap[pin & 0x3F]; pad = ((pad << 2) + PAD_CONFIG_BASE); - HWREG(pad) = (((HWREG(pad) & ~PAD_MODE_MASK) | pin_mode) & ~(3<<10)); + putreg32( (((getreg32(pad) & ~PAD_MODE_MASK) | pin_mode) & ~(3<<10)), pad); } /************************************************************************************ @@ -142,40 +117,40 @@ void cc3200_init(void) { uint8_t x=16; - HWREG(0x4402F064) |= 0x800000; - HWREG(0x4402F800 + 0x00000418) |= (1<<4); - HWREG(0x4402E16C) |= 0x3C; - HWREG(0x44025000 + 0x00000048) |= 0x00000001; + putreg32(getreg32(0x4402F064) | 0x800000,0x4402F064); + putreg32(getreg32(0x4402F800 + 0x00000418) | (1<<4), 0x4402F800 + 0x00000418); + putreg32(getreg32(0x4402E16C) | 0x3C, 0x4402E16C); + putreg32(getreg32(0x44025000 + 0x00000048) | 0x00000001, 0x44025000 + 0x00000048); while(--x) ; - HWREG(0x44025000 + 0x00000048) &= ~0x00000001; - HWREG(0x4402F804) = 0x0; - HWREG(0x4402F804) = 0x1; + putreg32(getreg32(0x44025000 + 0x00000048) & ~0x00000001, 0x44025000 + 0x00000048); + putreg32(0x0, 0x4402F804); + putreg32(0x1, 0x4402F804); - if (((HWREG(0x4402F0C8) & 0xFF) == 0x2)) + if (((getreg32(0x4402F0C8) & 0xFF) == 0x2)) { - HWREG(0x4402E110) = ((HWREG(0x4402E110) & ~0xC0F) | 0x2); - HWREG(0x4402E114) = ((HWREG(0x4402E110) & ~0xC0F) | 0x2); + putreg32((getreg32(0x4402E110) & ~0xC0F) | 0x2, 0x4402E110); + putreg32((getreg32(0x4402E114) & ~0xC0F) | 0x2, 0x4402E114); } - HWREG(0x4402E184) |= 0x2; + putreg32(getreg32(0x4402E184) | 0x2, 0x4402E184); - if ((HWREG(0x4402E0A4) & 0xF) == 0x1) + if ((getreg32(0x4402E0A4) & 0xF) == 0x1) { - HWREG(0x4402E0A4) = ((HWREG(0x4402E0A4) & ~0xF)); + putreg32(getreg32(0x4402E0A4) & ~0xF, 0x4402E0A4); } - if ((HWREG(0x4402E0A8) & 0xF) == 0x1) + if ((getreg32(0x4402E0A8) & 0xF) == 0x1) { - HWREG(0x4402E0A8) = ((HWREG(0x4402E0A8) & ~0xF)); + putreg32(getreg32(0x4402E0A8) & ~0xF, 0x4402E0A8); } - if (((HWREG(0x4402DC78) >> 22) & 0xF) == 0xE) + if (((getreg32(0x4402DC78) >> 22) & 0xF) == 0xE) { - HWREG(0x4402F0B0) = ((HWREG(0x4402F0B0) & ~(0x00FC0000))|(0x32 << 18)); + putreg32((getreg32(0x4402F0B0) & ~(0x00FC0000)) | (0x32 << 18), 0x4402F0B0); } else { - HWREG(0x4402F0B0) = ((HWREG(0x4402F0B0) & ~(0x00FC0000))|(0x29 << 18)); + putreg32((getreg32(0x4402F0B0) & ~(0x00FC0000)) | (0x29 << 18), 0x4402F0B0); } }