The SAM4S Xplained Pro now uses the extended timer/counter features. From Bob Doiron.
This commit is contained in:
parent
c528079853
commit
52583de4cf
@ -10,4 +10,9 @@ config SAM4S_XPLAINED_PRO_CDCACM_DEVMINOR
|
||||
default 0
|
||||
depends on SAM34_UDP && USBDEV && CDCACM
|
||||
|
||||
config SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH
|
||||
string "CPU Load Timer Device Path"
|
||||
default "/dev/tc0"
|
||||
depends on TIMER && SCHED_CPULOAD && SCHED_CPULOAD_EXTCLK
|
||||
|
||||
endif
|
||||
|
@ -342,6 +342,7 @@ CONFIG_NSH_MMCSDSLOTNO=0
|
||||
# Board-Specific Options
|
||||
#
|
||||
CONFIG_SAM4S_XPLAINED_PRO_CDCACM_DEVMINOR=0
|
||||
CONFIG_SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH="/dev/tc0"
|
||||
|
||||
#
|
||||
# RTOS Features
|
||||
@ -389,7 +390,8 @@ CONFIG_NPTHREAD_KEYS=4
|
||||
# Performance Monitoring
|
||||
#
|
||||
CONFIG_SCHED_CPULOAD=y
|
||||
# CONFIG_SCHED_CPULOAD_EXTCLK is not set
|
||||
CONFIG_SCHED_CPULOAD_EXTCLK=y
|
||||
CONFIG_SCHED_CPULOAD_TICKSPERSEC=333
|
||||
CONFIG_SCHED_CPULOAD_TIMECONSTANT=2
|
||||
# CONFIG_SCHED_INSTRUMENTATION is not set
|
||||
|
||||
@ -513,8 +515,8 @@ CONFIG_USART1_ISUART=y
|
||||
CONFIG_MCU_SERIAL=y
|
||||
CONFIG_STANDARD_SERIAL=y
|
||||
# CONFIG_SERIAL_TIOCSERGSTRUCT is not set
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
# CONFIG_UART1_SERIAL_CONSOLE is not set
|
||||
# CONFIG_UART0_SERIAL_CONSOLE is not set
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
# CONFIG_USART1_SERIAL_CONSOLE is not set
|
||||
# CONFIG_NO_SERIAL_CONSOLE is not set
|
||||
|
||||
@ -784,6 +786,8 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
|
||||
# CONFIG_EXAMPLES_ROMFS is not set
|
||||
# CONFIG_EXAMPLES_SENDMAIL is not set
|
||||
CONFIG_EXAMPLES_SERIALBLASTER=y
|
||||
CONFIG_EXAMPLES_SERIALBLASTER_STACKSIZE=2048
|
||||
CONFIG_EXAMPLES_SERIALBLASTER_PRIORITY=50
|
||||
CONFIG_EXAMPLES_SERIALRX=y
|
||||
CONFIG_EXAMPLES_SERIALRX_STACKSIZE=2048
|
||||
CONFIG_EXAMPLES_SERIALRX_PRIORITY=50
|
||||
@ -1007,8 +1011,8 @@ CONFIG_SYSTEM_SYSINFO_STACKSIZE=1024
|
||||
#
|
||||
CONFIG_SYSTEM_STACKMONITOR=y
|
||||
CONFIG_SYSTEM_STACKMONITOR_STACKSIZE=1024
|
||||
CONFIG_SYSTEM_STACKMONITOR_PRIORITY=50
|
||||
CONFIG_SYSTEM_STACKMONITOR_INTERVAL=2
|
||||
CONFIG_SYSTEM_STACKMONITOR_PRIORITY=110
|
||||
CONFIG_SYSTEM_STACKMONITOR_INTERVAL=1
|
||||
|
||||
#
|
||||
# USB CDC/ACM Device Commands
|
||||
|
@ -57,6 +57,10 @@
|
||||
#include "sam_lowputc.h"
|
||||
#include "sam_tc.h"
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
# include <os_internal.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
/****************************************************************************
|
||||
@ -82,8 +86,6 @@
|
||||
|
||||
/* Timer Definitions ********************************************************/
|
||||
|
||||
#define TINTERVAL (3042)
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
/* Non-standard debug that may be enabled just for testing the watchdog
|
||||
* timer
|
||||
@ -114,6 +116,12 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static bool calc_cpuload(FAR uint32_t *next_interval_us)
|
||||
{
|
||||
sched_process_cpuload();
|
||||
return TRUE; /* Reload, no change to interval */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -165,24 +173,41 @@ int sam_timerinitialize(void)
|
||||
|
||||
/* Open the timer device */
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
tcvdbg("Opening.\n");
|
||||
fd = open(CONFIG_TIMER0_DEVPATH, O_RDONLY);
|
||||
|
||||
fd = open(CONFIG_SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
tcdbg("open %s failed: %d\n", CONFIG_TIMER0_DEVPATH, errno);
|
||||
tcdbg("open %s failed: %d\n", CONFIG_SAM4S_XPLAINED_PRO_CPULOAD_TIMER_DEVPATH, errno);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Set the timeout */
|
||||
|
||||
tcvdbg("Timeout = %d.\n", TINTERVAL);
|
||||
ret = ioctl(fd, TCIOC_SETTIMEOUT, (unsigned long)TINTERVAL);
|
||||
ret = ioctl(fd, TCIOC_SETTIMEOUT, (unsigned long)1000000 / CONFIG_SCHED_CPULOAD_TICKSPERSEC);
|
||||
if (ret < 0)
|
||||
{
|
||||
tcdbg("ioctl(TCIOC_SETTIMEOUT) failed: %d\n", errno);
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
/* Install user callback */
|
||||
|
||||
{
|
||||
struct timer_capture_s tccb;
|
||||
tccb.newhandler = calc_cpuload;
|
||||
tccb.oldhandler = NULL;
|
||||
|
||||
ret = ioctl(fd, TCIOC_SETHANDLER, (unsigned long)&tccb);
|
||||
if (ret < 0)
|
||||
{
|
||||
tcdbg("ioctl(TCIOC_SETHANDLER) failed: %d\n", errno);
|
||||
goto errout_with_dev;
|
||||
}
|
||||
}
|
||||
|
||||
/* Start the timer */
|
||||
|
||||
tcvdbg("Starting.\n");
|
||||
@ -192,13 +217,17 @@ int sam_timerinitialize(void)
|
||||
tcdbg("ioctl(TCIOC_START) failed: %d\n", errno);
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
goto success;
|
||||
errout_with_dev:
|
||||
close(fd);
|
||||
errout:
|
||||
return ERROR;
|
||||
#endif
|
||||
|
||||
success:
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONFIG_TIMER */
|
||||
|
Loading…
Reference in New Issue
Block a user