More updates for PIC32 MX1/2 device configuration bits

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4857 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-06-20 22:29:32 +00:00
parent a3fbedb46c
commit 8a98f7c42b
4 changed files with 225 additions and 157 deletions

View File

@ -714,6 +714,14 @@
# error "Unsupported BOARD_UPLL_IDIV"
#endif
#ifndef CONFIG_PIC32MX_FUPLLEN
# if defined(CHIP_PIC32MX3) || defined(CHIP_PIC32MX4)
# define CONFIG_PIC32MX_FUPLLEN 0 /* Bypass and disable */
# else
# define CONFIG_PIC32MX_FUPLLEN 1 /* Bypass and disable */
# endif
#endif
#undef CONFIG_PIC32MX_PLLODIV
#if BOARD_PLL_ODIV == 1
# define CONFIG_PIC32MX_PLLODIV DEVCFG2_FPLLODIV_DIV1
@ -805,6 +813,10 @@
# define CONFIG_PIC32MX_FCKSM DEVCFG1_FCKSM_NONE
#endif
#ifndef CONFIG_PIC32MX_OSCOUT
# define CONFIG_PIC32MX_OSCOUT 0
#endif
#undef CONFIG_PIC32MX_WDPS
#if BOARD_WD_PRESCALER == 1
# define CONFIG_PIC32MX_WDPS DEVCFG1_WDTPS_1
@ -866,12 +878,20 @@
#endif
#ifndef CONFIG_PIC32MX_ICESEL /* In-Circuit Emulator/Debugger Communication Channel Select */
# define CONFIG_PIC32MX_ICESEL 1 /* default */
# if defined(CHIP_PIC32MX1) || defined(CHIP_PIC32MX2)
# define CONFIG_PIC32MX_ICESEL 3 /* Default PGEC1/PGED1 */
# else
# define CONFIG_PIC32MX_ICESEL 1 /* Default PGEC1/PGED1 */
# endif
#endif
#ifndef CONFIG_PIC32MX_PROGFLASHWP /* Program FLASH write protect */
# if defined(CHIP_PIC32MX1) || defined(CHIP_PIC32MX2)
# define CONFIG_PIC32MX_PROGFLASHWP 0x3ff /* Disabled */
# else
# define CONFIG_PIC32MX_PROGFLASHWP 0xff /* Disabled */
# endif
#endif
#ifndef CONFIG_PIC32MX_BOOTFLASHWP
# define CONFIG_PIC32MX_BOOTFLASHWP 1 /* Disabled */

View File

@ -193,10 +193,10 @@
# define DEVCFG1_WDTPS_262144 (18 << DEVCFG1_WDTPS_SHIFT) /* 1:262144 */
# define DEVCFG1_WDTPS_524288 (19 << DEVCFG1_WDTPS_SHIFT) /* 1:524288 */
# define DEVCFG1_WDTPS_1048576 (20 << DEVCFG1_WDTPS_SHIFT) /* 1:1048576 */
#define DEVCFG1_WINDIS (1 << 22) /* Bit 22: Windowed watchdog timer enable */
#define DEVCFG1_FWDTEN (1 << 23) /* Bit 23: WDT enable */
#if defined(CHIP_PIC32MX1) || defined(CHIP_PIC32MX2)
# define DEVCFG1_WINDIS (1 << 22) /* Bit 22: Windowed watchdog timer enable */
# define DEVCFG1_FWDTWINSZ_SHIFT (24) /* Bits 24-25: Watchdog Timer Window Size bits */
# define DEVCFG1_FWDTWINSZ_MASK (3 << DEVCFG1_FWDTWINSZ_SHIFT)
# define DEVCFG1_FWDTWINSZ_25 (0 << DEVCFG1_FWDTWINSZ_SHIFT) /* 25% */
@ -205,11 +205,35 @@
# define DEVCFG1_FWDTWINSZ_75 (3 << DEVCFG1_FWDTWINSZ_SHIFT) /* 75% */
# define DEVCFG1_UNUSED 0xfc200858 /* Bits 3-4, 6, 11, 21, 26-31 */
#else
# define DEVCFG1_UNUSED 0xff200858 /* Bits 3-4, 6, 11, 21, 24-31 */
# define DEVCFG1_UNUSED 0xff600858 /* Bits 3-4, 6, 11, 21-22, 24-31 */
#endif
/* Device configuration word 0 */
#if defined(CHIP_PIC32MX1) || defined(CHIP_PIC32MX2)
# define PWP_CODE(a) REVISIT (((~((a) >> 12)) - 1) & 0x3ff)
# define DEVCFG0_DEBUG_SHIFT (0) /* Bits 0-1: Background debugger enable */
# define DEVCFG0_DEBUG_MASK (3 << DEVCFG0_DEBUG_SHIFT)
# define DEVCFG0_DEBUG_ENABLED (1 << DEVCFG0_DEBUG_SHIFT)
# define DEVCFG0_DEBUG_DISABLED (3 << DEVCFG0_DEBUG_SHIFT)
# define DEVCFG0_JTAGEN (1 << 2) /* Bit 2: JTAG enable */
# define DEVCFG0_ICESEL_SHIFT (3) /* Bits 3-4: Background debugger enable */
# define DEVCFG0_ICESEL_MASK (3 << DEVCFG0_ICESEL_SHIFT)
# define DEVCFG0_ICESEL_CHAN4 (0 << DEVCFG0_ICESEL_SHIFT) /* PGEC4/PGED4 pair is used */
# define DEVCFG0_ICESEL_CHAN3 (1 << DEVCFG0_ICESEL_SHIFT) /* PGEC3/PGED3 pair is used */
# define DEVCFG0_ICESEL_CHAN2 (2 << DEVCFG0_ICESEL_SHIFT) /* PGEC2/PGED2 pair is used */
# define DEVCFG0_ICESEL_CHAN1 (3 << DEVCFG0_ICESEL_SHIFT) /* PGEC1/PGED1 pair is used */
# define DEVCFG0_PWP_SHIFT (10) /* Bits 10-15: Program flash write-protect */
# define DEVCFG0_PWP_MASK (0x3ff << DEVCFG0_PWP_SHIFT)
# define DEVCFG0_PWP_DISABLE (0x3ff << DEVCFG0_PWP_SHIFT)
# define DEVCFG0_PWP(code) ((code) << DEVCFG0_PWP_SHIFT) /* See PWP_CODE above */
# define DEVCFG0_BWP (1 << 24) /* Bit 24: Boot flash write-protect */
# define DEVCFG0_CP (1 << 28) /* Bit 28: Code-protect */
# define DEVCFG0_SIGN (1 << 31) /* Bit 31: Signature */
# define DEVCFG0_UNUSED 0x6eff03e0 /* Bits 5-9, 16-23, 25-27, 29-30 */
#else
# define PWP_CODE(a) (((~((a) >> 12)) - 1) & 0xff)
# define DEVCFG0_DEBUG_SHIFT (0) /* Bits 0-1: Background debugger enable */
@ -224,7 +248,9 @@
# define DEVCFG0_BWP (1 << 24) /* Bit 24: Boot flash write-protect */
# define DEVCFG0_CP (1 << 28) /* Bit 28: Code-protect */
# define DEVCFG0_SIGN (1 << 31) /* Bit 31: Signature */
# define DEVCFG0_UNUSED 0x6ef00ff0 /* Bits 4-11, 20-23, 25-27, 29-30 */
#endif
/****************************************************************************
* Public Types

View File

@ -614,21 +614,41 @@ devconfig3:
devconfig2:
.long CONFIG_PIC32MX_PLLIDIV | CONFIG_PIC32MX_PLLMULT | \
CONFIG_PIC32MX_UPLLIDIV | CONFIG_PIC32MX_PLLODIV | \
DEVCFG2_UNUSED
CONFIG_PIC32MX_FUPLLEN << 15 | DEVCFG2_UNUSED
devconfig1:
#if defined(CHIP_PIC32MX1) || defined(CHIP_PIC32MX2)
.long CONFIG_PIC32MX_FNOSC | CONFIG_PIC32MX_FSOSCEN | \
CONFIG_PIC32MX_IESO | CONFIG_PIC32MX_POSCMOD | \
CONFIG_PIC32MX_OSCOUT << 10 | \
CONFIG_PIC32MX_PBDIV | CONFIG_PIC32MX_FCKSM | \
DEVCFG1_WINDIS | CONFIG_PIC32MX_WDENABLE | \
DEVCFG1_FWDTWINSZ_75 | DEVCFG1_UNUSED
#else
.long CONFIG_PIC32MX_FNOSC | CONFIG_PIC32MX_FSOSCEN | \
CONFIG_PIC32MX_IESO | CONFIG_PIC32MX_POSCMOD | \
CONFIG_PIC32MX_OSCOUT << 10 | \
CONFIG_PIC32MX_PBDIV | CONFIG_PIC32MX_FCKSM | \
CONFIG_PIC32MX_WDENABLE | DEVCFG1_UNUSED
#endif
devconfig0:
#if defined(CHIP_PIC32MX1) || defined(CHIP_PIC32MX2)
.long CONFIG_PIC32MX_DEBUGGER << DEVCFG0_DEBUG_SHIFT | \
DEVCFG0_JTAGEN | \
CONFIG_PIC32MX_ICESEL << DEVCFG0_ICESEL_SHIFT | \
CONFIG_PIC32MX_PROGFLASHWP << DEVCFG0_PWP_SHIFT | \
CONFIG_PIC32MX_BOOTFLASHWP << 24 | \
CONFIG_PIC32MX_CODEWP << 28 | \
DEVCFG0_UNUSED
#else
.long CONFIG_PIC32MX_DEBUGGER << DEVCFG0_DEBUG_SHIFT | \
CONFIG_PIC32MX_ICESEL << 3 | \
CONFIG_PIC32MX_PROGFLASHWP << DEVCFG0_PWP_SHIFT | \
CONFIG_PIC32MX_BOOTFLASHWP << 24 | \
CONFIG_PIC32MX_CODEWP << 28 | \
DEVCFG0_UNUSED
#endif
.size devconfig, .-devconfig
/****************************************************************************

View File

@ -167,13 +167,14 @@ CONFIG_PIC32MX_IOPORTC=y
#
# DEVCFG0:
# CONFIG_PIC32MX_DEBUGGER - Background Debugger Enable. Default 3 (disabled). The
# value 2 enables.
# value 1 enables.
# CONFIG_PIC32MX_ICESEL - In-Circuit Emulator/Debugger Communication Channel Select
# Default 1 (PG2)
# Default 3 (PG1)
# CONFIG_PIC32MX_PROGFLASHWP - Program FLASH write protect. Default 0xff (disabled)
# CONFIG_PIC32MX_BOOTFLASHWP - Default 1 (disabled)
# CONFIG_PIC32MX_CODEWP - Default 1 (disabled)
# DEVCFG1: (All settings determined by selections in board.h)
# DEVCFG1: All settings determined by selections in board.h. Except
# CONFIG_PIC32MX_OSCOUT - May be used to disable oscillator output (enabled by default)
# DEVCFG2: (All settings determined by selections in board.h)
# DEVCFG3:
# CONFIG_PIC32MX_USBIDO - USB USBID Selection. Default 1 if USB enabled
@ -183,8 +184,9 @@ CONFIG_PIC32MX_IOPORTC=y
# CONFIG_PIC32MX_WDENABLE - Enabled watchdog on power up. Default 0 (watchdog
# can be enabled later by software).
#
CONFIG_PIC32MX_DEBUGGER=2
CONFIG_PIC32MX_ICESEL=1
CONFIG_PIC32MX_DEBUGGER=1
CONFIG_PIC32MX_ICESEL=2
CONFIG_PIC32MX_OSCOUT=1
#
# PIC32MX specific serial device driver settings