summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-05-05 14:38:29 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-05-05 14:38:29 -0600
commit03a7ce0f604530c31f9716533103b4a2288c857b (patch)
tree1f5d4dbbcb9b0ed5f9512e6014335850323af010 /nuttx
parent5bc7fcd3ffc062169be8562afc4d2feaa6425cb0 (diff)
downloadnuttx-03a7ce0f604530c31f9716533103b4a2288c857b.tar.gz
nuttx-03a7ce0f604530c31f9716533103b4a2288c857b.tar.bz2
nuttx-03a7ce0f604530c31f9716533103b4a2288c857b.zip
SAM4S Xplained Pro: Clean-up of LED usage and also some integration of new timer features. From Bob Doiron
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog5
-rw-r--r--nuttx/configs/sam4s-xplained-pro/Kconfig4
-rw-r--r--nuttx/configs/sam4s-xplained-pro/include/board.h3
-rw-r--r--nuttx/configs/sam4s-xplained-pro/nsh/defconfig60
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c15
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_boot.c7
-rwxr-xr-xnuttx/configs/sam4s-xplained-pro/src/sam_tc.c31
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c15
-rw-r--r--nuttx/sched/Kconfig6
9 files changed, 61 insertions, 85 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 8c57bbff0..68cbd07a4 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -7285,3 +7285,8 @@
adding CONFIG_NSH_ALTCONDEV: CONFIG_NSH_ALTCONDEV enables or disables
the feature then, if enabled, CONFIG_NSH_CONDEV provides the alternative
console device name (2014-5-5).
+ * arch/arm/src/sam34/sam_rtt.c/.h: RTT driver from Bob Doiron. Also
+ added high resolution RTC emulation using the RTT for the sub-second
+ counter (2014-5-5).
+ * configs/sam4s-xplained-pro: Clean-up of LED usage and also some
+ integration of new timer features. From Bob Doiron (2014-5-5). \ No newline at end of file
diff --git a/nuttx/configs/sam4s-xplained-pro/Kconfig b/nuttx/configs/sam4s-xplained-pro/Kconfig
index cce0f48a8..b3f327cf9 100644
--- a/nuttx/configs/sam4s-xplained-pro/Kconfig
+++ b/nuttx/configs/sam4s-xplained-pro/Kconfig
@@ -12,12 +12,12 @@ config SAM4S_XPLAINED_PRO_CDCACM_DEVMINOR
config SAM4S_XPLAINED_PRO_SCHED_TIMER_DEVPATH
string "Scheduler Timer Device Path"
- default "/dev/tc0"
+ default "/dev/rtt0"
depends on TIMER && SYSTEMTICK_EXTCLK
config SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH
string "CPU Load Timer Device Path"
- default "/dev/tc1"
+ default "/dev/tc0"
depends on TIMER && SCHED_CPULOAD && SCHED_CPULOAD_EXTCLK
diff --git a/nuttx/configs/sam4s-xplained-pro/include/board.h b/nuttx/configs/sam4s-xplained-pro/include/board.h
index a28238e8d..deb332b81 100644
--- a/nuttx/configs/sam4s-xplained-pro/include/board.h
+++ b/nuttx/configs/sam4s-xplained-pro/include/board.h
@@ -229,6 +229,9 @@
#define LED_PANIC 3 /* The system has crashed Flash @ 250ms */
#define LED_IDLE 4 /* MCU is is sleep mode Not used */
+#define LED_D301_OFF true /* GPIO high for OFF */
+#define LED_D301_ON false /* GPIO low for ON */
+
/* Thus if D301 is statically on, NuttX has successfully booted and is,
* apparently, running normmally.
*/
diff --git a/nuttx/configs/sam4s-xplained-pro/nsh/defconfig b/nuttx/configs/sam4s-xplained-pro/nsh/defconfig
index d54fe7ad5..04a25c5a7 100644
--- a/nuttx/configs/sam4s-xplained-pro/nsh/defconfig
+++ b/nuttx/configs/sam4s-xplained-pro/nsh/defconfig
@@ -12,10 +12,6 @@ CONFIG_HOST_LINUX=y
# CONFIG_HOST_OSX is not set
# CONFIG_HOST_WINDOWS is not set
# CONFIG_HOST_OTHER is not set
-# CONFIG_WINDOWS_NATIVE is not set
-# CONFIG_WINDOWS_CYGWIN is not set
-# CONFIG_WINDOWS_MSYS is not set
-# CONFIG_WINDOWS_OTHER is not set
#
# Build Configuration
@@ -44,36 +40,9 @@ CONFIG_RAW_BINARY=y
#
# Debug Options
#
-CONFIG_DEBUG=y
+# CONFIG_DEBUG is not set
CONFIG_ARCH_HAVE_STACKCHECK=y
# CONFIG_ARCH_HAVE_HEAPCHECK is not set
-# CONFIG_DEBUG_VERBOSE is not set
-
-#
-# Subsystem Debug Options
-#
-# CONFIG_DEBUG_MM is not set
-# CONFIG_DEBUG_SCHED is not set
-# CONFIG_DEBUG_USB is not set
-# CONFIG_DEBUG_FS is not set
-# CONFIG_DEBUG_LIB is not set
-# CONFIG_DEBUG_BINFMT is not set
-# CONFIG_DEBUG_GRAPHICS is not set
-# CONFIG_DEBUG_IRQ is not set
-CONFIG_DEBUG_STACK=y
-
-#
-# Driver Debug Options
-#
-# CONFIG_DEBUG_LEDS is not set
-# CONFIG_DEBUG_ANALOG is not set
-# CONFIG_DEBUG_SDIO is not set
-# CONFIG_DEBUG_GPIO is not set
-# CONFIG_DEBUG_DMA is not set
-# CONFIG_DEBUG_RTC is not set
-# CONFIG_DEBUG_WATCHDOG is not set
-# CONFIG_DEBUG_TIMER is not set
-# CONFIG_DEBUG_AUDIO is not set
CONFIG_DEBUG_SYMBOLS=y
CONFIG_ARCH_HAVE_CUSTOMOPT=y
# CONFIG_DEBUG_NOOPT is not set
@@ -134,21 +103,14 @@ CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_ARCH_HAVE_MPU=y
CONFIG_ARMV7M_MPU=y
CONFIG_ARMV7M_MPU_NREGIONS=8
-CONFIG_DEBUG_HARDFAULT=y
#
# ARMV7M Configuration Options
#
-# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set
-# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set
# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set
-# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set
-# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set
-# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW is not set
-# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set
# CONFIG_ARMV7M_OABI_TOOLCHAIN is not set
CONFIG_ARCH_HAVE_EXTNAND=y
CONFIG_ARCH_HAVE_EXTNOR=y
@@ -217,7 +179,7 @@ CONFIG_SAM34_HSMCI=y
CONFIG_SAM34_PDCA=y
# CONFIG_SAM34_PWM is not set
CONFIG_SAM34_RTC=y
-# CONFIG_SAM34_RTT is not set
+CONFIG_SAM34_RTT=y
CONFIG_SAM34_SMC=y
# CONFIG_SAM34_SPI0 is not set
# CONFIG_SAM34_SSC is not set
@@ -264,13 +226,11 @@ CONFIG_SAM34_GPIOC_IRQ=y
#
# AT91SAM3/4 USB Full Speed Device Controller driver (DCD) options
#
-# CONFIG_SAM34_UDP_REGDEBUG is not set
CONFIG_SAM34_TC=y
#
# AT91SAM3/4 Timer/Counter options
#
-# CONFIG_SAM34_TC_REGDEBUG is not set
#
# AT91SAM3/4 Watchdog Configuration
@@ -359,8 +319,8 @@ CONFIG_NSH_MMCSDSLOTNO=0
# Board-Specific Options
#
CONFIG_SAM4S_XPLAINED_PRO_CDCACM_DEVMINOR=0
-CONFIG_SAM4S_XPLAINED_PRO_SCHED_TIMER_DEVPATH="/dev/tc0"
-CONFIG_SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH="/dev/tc1"
+CONFIG_SAM4S_XPLAINED_PRO_SCHED_TIMER_DEVPATH="/dev/rtt0"
+CONFIG_SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH="/dev/tc0"
#
# RTOS Features
@@ -410,7 +370,7 @@ CONFIG_NPTHREAD_KEYS=4
#
CONFIG_SCHED_CPULOAD=y
CONFIG_SCHED_CPULOAD_EXTCLK=y
-CONFIG_SCHED_CPULOAD_TICKSPERSEC=333
+CONFIG_SCHED_CPULOAD_TICKSPERSEC=222
CONFIG_SCHED_CPULOAD_TIMECONSTANT=2
# CONFIG_SCHED_INSTRUMENTATION is not set
@@ -473,7 +433,9 @@ CONFIG_DEV_ZERO=y
# CONFIG_SPI is not set
# CONFIG_I2S is not set
CONFIG_RTC=y
-CONFIG_RTC_DATETIME=y
+# CONFIG_RTC_DATETIME is not set
+CONFIG_RTC_HIRES=y
+CONFIG_RTC_FREQUENCY=32768
CONFIG_RTC_ALARM=y
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_DEVPATH="/dev/watchdog0"
@@ -533,7 +495,6 @@ CONFIG_ARCH_HAVE_USART1=y
CONFIG_USART1_ISUART=y
CONFIG_MCU_SERIAL=y
CONFIG_STANDARD_SERIAL=y
-# CONFIG_SERIAL_TIOCSERGSTRUCT is not set
# CONFIG_UART0_SERIAL_CONSOLE is not set
CONFIG_UART1_SERIAL_CONSOLE=y
# CONFIG_USART1_SERIAL_CONSOLE is not set
@@ -938,7 +899,6 @@ CONFIG_NSH_CONSOLE=y
#
# USB Trace Support
#
-# CONFIG_NSH_USBDEV_TRACE is not set
# CONFIG_NSH_ALTCONDEV is not set
CONFIG_NSH_ARCHINIT=y
@@ -1028,10 +988,6 @@ CONFIG_SYSTEM_SYSINFO_STACKSIZE=1024
#
# Stack Monitor
#
-CONFIG_SYSTEM_STACKMONITOR=y
-CONFIG_SYSTEM_STACKMONITOR_STACKSIZE=1024
-CONFIG_SYSTEM_STACKMONITOR_PRIORITY=110
-CONFIG_SYSTEM_STACKMONITOR_INTERVAL=1
#
# USB CDC/ACM Device Commands
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c b/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c
index 4921a5301..24a490e19 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c
@@ -73,9 +73,6 @@
* LED_IDLE MCU is is sleep mode Not used
*/
-#define LED_OFF true /* GPIO high for OFF */
-#define LED_ON false /* GPIO low for ON */
-
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
*/
@@ -120,19 +117,19 @@ void board_led_on(int led)
switch (led)
{
case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED - off while initializing */
- sam_gpiowrite(GPIO_D301, LED_OFF);
+ sam_gpiowrite(GPIO_D301, LED_D301_OFF);
break;
case 1: /* LED_STACKCREATED - turn on when ready */
- sam_gpiowrite(GPIO_D301, LED_ON);
+ sam_gpiowrite(GPIO_D301, LED_D301_ON);
break;
case 2: /* LED_INIRQ, LED_SIGNAL - turn off inside irqs/signal processing */
- sam_gpiowrite(GPIO_D301, LED_OFF);
+ sam_gpiowrite(GPIO_D301, LED_D301_OFF);
return;
case 3: /* LED_PANIC - flash */
- sam_gpiowrite(GPIO_D301, LED_ON);
+ sam_gpiowrite(GPIO_D301, LED_D301_ON);
break;
default:
@@ -153,11 +150,11 @@ void board_led_off(int led)
break;
case 2: /* LED_INIRQ, LED_SIGNAL - return to on after irq/signal processing */
- sam_gpiowrite(GPIO_D301, LED_ON);
+ sam_gpiowrite(GPIO_D301, LED_D301_ON);
return;
case 3: /* LED_PANIC - flashes */
- sam_gpiowrite(GPIO_D301, LED_OFF);
+ sam_gpiowrite(GPIO_D301, LED_D301_OFF);
break;
}
}
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_boot.c b/nuttx/configs/sam4s-xplained-pro/src/sam_boot.c
index cda18efb1..5c60c76d5 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_boot.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_boot.c
@@ -42,6 +42,7 @@
#include <debug.h>
#include <nuttx/watchdog.h>
+#include <arch/board/board.h>
#include "sam4s-xplained-pro.h"
/************************************************************************************
@@ -97,6 +98,12 @@ void board_initialize(void)
DEBUGASSERT(up_wdginitialize() >= 0);
#endif
+#ifndef CONFIG_ARCH_LEDS
+ /* Initialize user led */
+
+ sam_ledinit();
+#endif
+
#ifdef CONFIG_TIMER
/* Registers the timers and starts any async processes (which may include the scheduler) */
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_tc.c b/nuttx/configs/sam4s-xplained-pro/src/sam_tc.c
index c2ba12e4e..4012bb80d 100755
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_tc.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_tc.c
@@ -57,6 +57,7 @@
#include "sam_lowputc.h"
#include "sam_tc.h"
+#include "sam_rtt.h"
#ifdef CONFIG_TIMER
@@ -64,22 +65,35 @@
* Definitions
****************************************************************************/
/* Configuration ************************************************************/
-/* Watchdog hardware should be enabled */
-#if !defined(CONFIG_SAM34_TC0)
-# warning "CONFIG_SAM34_TC0 must be defined"
+#if !(defined(CONFIG_SAM34_TC0) || defined(CONFIG_SAM34_TC1) || defined(CONFIG_SAM34_TC2) \
+ || defined(CONFIG_SAM34_TC3) || defined(CONFIG_SAM34_TC4) || defined(CONFIG_SAM34_RTT) )
+# warning "CONFIG_SAM34_TCx or CONFIG_SAM34_RTT must be defined"
#endif
/* Select the path to the registered watchdog timer device */
#ifndef CONFIG_TIMER0_DEVPATH
# define CONFIG_TIMER0_DEVPATH "/dev/tc0"
+#endif
+#ifndef CONFIG_TIMER1_DEVPATH
# define CONFIG_TIMER1_DEVPATH "/dev/tc1"
+#endif
+#ifndef CONFIG_TIMER2_DEVPATH
# define CONFIG_TIMER2_DEVPATH "/dev/tc2"
+#endif
+#ifndef CONFIG_TIMER3_DEVPATH
# define CONFIG_TIMER3_DEVPATH "/dev/tc3"
+#endif
+#ifndef CONFIG_TIMER4_DEVPATH
# define CONFIG_TIMER4_DEVPATH "/dev/tc4"
+#endif
+#ifndef CONFIG_TIMER5_DEVPATH
# define CONFIG_TIMER5_DEVPATH "/dev/tc5"
#endif
+#ifndef CONFIG_RTT_DEVPATH
+# define CONFIG_RTT_DEVPATH "/dev/rtt0"
+#endif
/* Timer Definitions ********************************************************/
@@ -183,6 +197,11 @@ int sam_timerinitialize(void)
sam_tcinitialize(CONFIG_TIMER5_DEVPATH, SAM_IRQ_TC5);
#endif
+#if defined(CONFIG_SAM34_RTT)
+ tcvdbg("Initializing %s...\n", CONFIG_RTT_DEVPATH);
+ sam_rttinitialize(CONFIG_RTT_DEVPATH);
+#endif
+
#if defined(CONFIG_SYSTEMTICK_EXTCLK) && !defined(CONFIG_SUPPRESS_INTERRUPTS) && \
!defined(CONFIG_SUPPRESS_TIMER_INTS)
/* System Timer Initialization */
@@ -209,7 +228,7 @@ int sam_timerinitialize(void)
/* install user callback */
{
- struct timer_capture_s tccb;
+ struct timer_sethandler_s tccb;
tccb.newhandler = systemtick;
tccb.oldhandler = NULL;
@@ -260,7 +279,7 @@ int sam_timerinitialize(void)
/* Install user callback */
{
- struct timer_capture_s tccb;
+ struct timer_sethandler_s tccb;
tccb.newhandler = calc_cpuload;
tccb.oldhandler = NULL;
@@ -281,13 +300,13 @@ int sam_timerinitialize(void)
tcdbg("ioctl(TCIOC_START) failed: %d\n", errno);
goto errout_with_dev;
}
+#endif
goto success;
errout_with_dev:
close(fd);
errout:
return ERROR;
-#endif
success:
return OK;
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c b/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c
index ead93669f..76bbf090f 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c
@@ -105,18 +105,10 @@ void sam_ledinit(void)
void sam_setled(int led, bool ledon)
{
- uint32_t ledcfg;
-
if (led == BOARD_D301)
{
- ledcfg = GPIO_D301;
- }
- else
- {
- return;
+ sam_gpiowrite(GPIO_D301, ledon ? LED_D301_ON : LED_D301_OFF);
}
-
- sam_gpiowrite(ledcfg, !ledon); /* 0 = on, 1 = off */
}
/****************************************************************************
@@ -125,10 +117,7 @@ void sam_setled(int led, bool ledon)
void sam_setleds(uint8_t ledset)
{
- bool ledon;
-
- ledon = ((ledset & BOARD_D301_BIT) != 0);
- sam_gpiowrite(GPIO_D301, !ledon); /* 0 = on, 1 = off */
+ sam_gpiowrite(GPIO_D301, (ledset & BOARD_D301_BIT) ? LED_D301_ON : LED_D301_OFF);
}
#endif /* !CONFIG_ARCH_LEDS */
diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig
index 35d027db2..8c73a7faf 100644
--- a/nuttx/sched/Kconfig
+++ b/nuttx/sched/Kconfig
@@ -67,10 +67,10 @@ config SYSTEMTICK_EXTCLK
depends on ARCH_HAVE_EXTCLK
---help---
Use external clock for system tick. When enabled, the platform-specific
- logic must start it's own timer interrupt to make periodic calls to the
+ logic must start its own timer interrupt to make periodic calls to the
sched_process_timer() or the functions called within. The purpose is
- to move the scheduling off the processor to enter low power states that
- would disable that clock. Platform-specific logic must also provide
+ to move the scheduling off the processor clock to allow entering low
+ power states that would disable that clock.
config SYSTEM_TIME64
bool "64-bit system clock"