diff --git a/ChangeLog b/ChangeLog index 055d540aeafde0c8c9216b0883fea13828185dc2..ee37fbdd33beda12e20fa8e5425e6d81a9394096 100755 --- a/ChangeLog +++ b/ChangeLog @@ -17445,7 +17445,7 @@ * The lcdrw example has been removed because it violates the portable OS interface (2017-10-14). * All configurations that use NXIMAGE or NXHELLO must select - NX_MULTIUSER. All configuratinos that use examples/nxterm must enable + NX_MULTIUSER. All configurations that use examples/nxterm must enable CONFIG_LIB_BOARDCTL (2017-10-14). * configs/stm32f103-minimum: Add support for LM75 in the stm32f103-minimum board. From Alan Carvalho de Assis (2017-10-14). diff --git a/Documentation/NXGraphicsSubsystem.html b/Documentation/NXGraphicsSubsystem.html index 3a58de35fc3337ede6e38300dd09cc80bfd69930..efb8cbf1fe4a1c9690e968a47fdcec4f2ed645e5 100644 --- a/Documentation/NXGraphicsSubsystem.html +++ b/Documentation/NXGraphicsSubsystem.html @@ -12,7 +12,7 @@

NX Graphics Subsystem

-

Last Updated: October 17, 2017

+

Last Updated: January 21, 2018

@@ -542,7 +542,7 @@ void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8

Description: - Convert 8-bit RGB triplet to 8-bit YUV triplet. + Convert 8-bit YUV triplet to 8-bit RGB triplet.

2.2.3 nxgl_rectcopy()

diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html index c23950484cd83895c4f1a664914846070a2625fd..6095357a5cea6da41103aa1b234a90a8decc09ed 100644 --- a/Documentation/NuttShell.html +++ b/Documentation/NuttShell.html @@ -8,7 +8,7 @@

NuttShell (NSH)

-

Last Updated: January 10, 2018

+

Last Updated: January 12, 2018

@@ -251,259 +251,265 @@
- 2.28 Send a signal to a task (kill) + 2.28 Show Interrupt Status (irqinfo)
- 2.29 Setup/teardown the Loop Device (losetup) + 2.29 Send a signal to a task (kill)
- 2.30 List to a File or Directory (ln) + 2.30 Setup/teardown the Loop Device (losetup)
- 2.31 List Directory Contents (ls) + 2.31 List to a File or Directory (ln)
- 2.32 Show information about installed OS modules (lsmod) + 2.32 List Directory Contents (ls)
- 2.33 Calculate MD5 (md5) + 2.33 Show information about installed OS modules (lsmod)
- 2.34 Access Memory (mb, mh, and mw) + 2.34 Calculate MD5 (md5)
- 2.35 Show Current Tasks and Threads (ps) + 2.35 Access Memory (mb, mh, and mw)
- 2.36 Create a Directory (mkdir) + 2.36 Show Current Tasks and Threads (ps)
- 2.37 Create a FAT File System (mkfatfs) + 2.37 Create a Directory (mkdir)
- 2.38 Create a FIFO (mkfifo) + 2.38 Create a FAT File System (mkfatfs)
- 2.39 Create a RAMDISK (mkrd) + 2.39 Create a FIFO (mkfifo)
- 2.40 Mount a File System (mount) + 2.40 Create a RAMDISK (mkrd)
- 2.41 Rename a File (mv) + 2.41 Mount a File System (mount)
- 2.42 Mount an NFS File System (nfsmount) + 2.42 Rename a File (mv)
- 2.43 Lookup a network address (nslookup) + 2.43 Mount an NFS File System (nfsmount)
- 2.44 Change a User's Password (passwd) + 2.44 Lookup a network address (nslookup)
- 2.45 Shut the system down (poweroff) + 2.45 Change a User's Password (passwd)
- 2.46 Send File Via TFTP (put) + 2.46 Shut the system down (poweroff)
- 2.47 Show Current Working Directory (pwd) + 2.47 Send File Via TFTP (put)
- 2.48 Show target of a link (readlink) + 2.48 Show Current Working Directory (pwd)
- 2.49 Reset and reboot the system (reboot) + 2.49 Show target of a link (readlink)
- 2.50 Remove a File (rm) + 2.50 Reset and reboot the system (reboot)
- 2.51 Remove a Directory (rmdir) + 2.51 Remove a File (rm)
- 2.52 Remove on OS Module (rmmod) + 2.52 Remove a Directory (rmdir)
- 2.53 Show routing table (route) + 2.53 Remove on OS Module (rmmod)
- 2.54 Set an Environment Variable (set) + 2.54 Show routing table (route)
- 2.55 Execute an NSH Script (sh) + 2.55 Set an Environment Variable (set)
- 2.56 Shut the system down (shutdown) + 2.56 Execute an NSH Script (sh)
- 2.57 Wait for Seconds (sleep) + 2.57 Shut the system down (shutdown)
- 2.58 Start the Telnet Daemon (telnetd) + 2.58 Wait for Seconds (sleep)
- 2.59 Time execution of another command (time) + 2.59 Start the Telnet Daemon (telnetd)
- 2.60 Set the Size of a File (truncate) + 2.60 Time execution of another command (time)
- 2.61 Unmount a File System (umount) + 2.61 Set the Size of a File (truncate)
- 2.62 Print system information (uname) + 2.62 Unmount a File System (umount)
- 2.63 Unset an Environment Variable (unset) + 2.63 Print system information (uname)
- 2.64 URL Decode (urldecode) + 2.64 Unset an Environment Variable (unset)
- 2.65 URL Encode (urlencode) + 2.65 URL Decode (urldecode)
- 2.66 Add a New User (useradd) + 2.66 URL Encode (urlencode)
- 2.67 Delete a user (userdel) + 2.67 Add a New User (useradd)
- 2.68 Wait for Microseconds (usleep) + 2.68 Delete a user (userdel)
- 2.69 Get File Via HTTP (wget) + 2.69 Wait for Microseconds (usleep)
- 2.70 Hexadecimal Dump of Memory (xd) + 2.70 Get File Via HTTP (wget) + + + +
+ + 2.71 Hexadecimal Dump of Memory (xd) @@ -1941,7 +1947,34 @@ mydriver 20404659 20404625 0 20404580 552 204047a8 0 + +
-

2.28 Send a signal to a task (kill)

+

2.28 Show Interrupt Status (irqinfo)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Show the current count of interrupts taken on all attached interrupts. +

+

+ Example:. +

+ + + + +
+

2.29 Send a signal to a task (kill)

@@ -1983,7 +2016,7 @@ nsh>
-

2.29 Setup/teardown the Loop Device (losetup)

+

2.30 Setup/teardown the Loop Device (losetup)

@@ -2036,7 +2069,7 @@ losetup d <dev-path>
-

2.30 Link to a File or Directory (ln)

+

2.31 Link to a File or Directory (ln)

@@ -2061,7 +2094,7 @@ ln [-s] <target> <link>
-

2.31 List Directory Contents (ls)

+

2.32 List Directory Contents (ls)

@@ -2099,7 +2132,7 @@ ls [-lRs] <dir-path>
-

2.32 Show information about installed OS modules (lsmod)

+

2.33 Show information about installed OS modules (lsmod)

@@ -2132,7 +2165,7 @@ mydriver 20404659 20404625 0 20404580 552 204047a8 0
-

2.33 Calculate MD5 (md5)

+

2.34 Calculate MD5 (md5)

@@ -2149,7 +2182,7 @@ md5 [-f] <string or filepath>
-

2.34 Access Memory (mb, mh, and mw)

+

2.35 Access Memory (mb, mh, and mw)

@@ -2202,7 +2235,7 @@ nsh>
-

2.35 Show Current Tasks and Threads (ps)

+

2.36 Show Current Tasks and Threads (ps)

@@ -2236,7 +2269,7 @@ nsh> mount -t procfs /proc
-

2.36 Create a Directory (mkdir)

+

2.37 Create a Directory (mkdir)

@@ -2271,7 +2304,7 @@ nsh>
-

2.37 Create a FAT File System (mkfatfs)

+

2.38 Create a FAT File System (mkfatfs)

@@ -2296,7 +2329,7 @@ mkfatfs [-F <fatsize>] <block-driver>
-

2.38 Create a FIFO (mkfifo)

+

2.39 Create a FIFO (mkfifo)

@@ -2334,7 +2367,7 @@ nsh>
-

2.39 Create a RAMDISK (mkrd)

+

2.40 Create a RAMDISK (mkrd)

@@ -2385,7 +2418,7 @@ nsh>
-

2.40 Mount a File System (mount)

+

2.41 Mount a File System (mount)

@@ -2464,7 +2497,7 @@ nsh> mount
-

2.41 Rename a File (mv)

+

2.42 Rename a File (mv)

@@ -2482,7 +2515,7 @@ mv <old-path> <new-path>
-

2.42 Mount an NFS file system (nfsmount)

+

2.43 Mount an NFS file system (nfsmount)

@@ -2501,7 +2534,7 @@ nfsmount <server-address> <mount-point> <remote-path>
-

2.43 Lookup a network address (nslookup)

+

2.44 Lookup a network address (nslookup)

@@ -2518,7 +2551,7 @@ nslookup <host-name>
-

2.44 Change a User's Password (passwd)

+

2.45 Change a User's Password (passwd)

@@ -2535,7 +2568,7 @@ passwd <username> <password>
-

2.45 Shut the system down (poweroff)

+

2.46 Shut the system down (poweroff)

@@ -2557,7 +2590,7 @@ poweroff
-

2.46 Send File Via TFTP (put)

+

2.47 Send File Via TFTP (put)

@@ -2592,7 +2625,7 @@ put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
-

2.47 Show Current Working Directory (pwd)

+

2.48 Show Current Working Directory (pwd)

@@ -2622,7 +2655,7 @@ nsh>
-

2.48 Show target of a link (readlink)

+

2.49 Show target of a link (readlink)

@@ -2639,7 +2672,7 @@ readlink <link>
-

2.49 Reboot the system (reboot)

+

2.50 Reboot the system (reboot)

@@ -2660,7 +2693,7 @@ reboot
-

2.50 Remove a File (rm)

+

2.51 Remove a File (rm)

@@ -2694,7 +2727,7 @@ nsh>
-

2.51 Remove a Directory (rmdir)

+

2.52 Remove a Directory (rmdir)

@@ -2729,7 +2762,7 @@ nsh>
-

2.52 Remove on OS Module (rmmod)

+

2.53 Remove on OS Module (rmmod)

@@ -2757,7 +2790,7 @@ nsh>
-

2.53 Show routing table (route)

+

2.54 Show routing table (route)

@@ -2777,7 +2810,7 @@ route ipv4|ipv6
-

2.54 Set an Environment Variable (set)

+

2.55 Set an Environment Variable (set)

@@ -2846,7 +2879,7 @@ nsh>
-

2.55 Execute an NSH Script (sh)

+

2.56 Execute an NSH Script (sh)

@@ -2864,7 +2897,7 @@ sh <script-path>
-

2.56 Shut the system down (shutdown)

+

2.57 Shut the system down (shutdown)

@@ -2885,7 +2918,7 @@ shutdown [--reboot]
-

2.57 Wait for Seconds (sleep)

+

2.58 Wait for Seconds (sleep)

@@ -2902,7 +2935,7 @@ sleep <sec>
-

2.58 Time Start the Telnet Daemon (telnetd)

+

2.59 Time Start the Telnet Daemon (telnetd)

@@ -2928,7 +2961,7 @@ telnetd
-

2.59 Time execution of another command (time)

+

2.60 Time execution of another command (time)

@@ -2986,7 +3019,7 @@ nsh>
-

2.60 Set the Size of a File (truncate)

+

2.61 Set the Size of a File (truncate)

@@ -3014,7 +3047,7 @@ truncate -s <length> <file-path>
-

2.61 Unmount a File System (umount)

+

2.62 Unmount a File System (umount)

@@ -3044,7 +3077,7 @@ nsh>
-

2.62 Print system information (uname)

+

2.63 Print system information (uname)

@@ -3111,7 +3144,7 @@ uname [-a | -imnoprsv]
-

2.63 Unset an Environment Variable (unset)

+

2.64 Unset an Environment Variable (unset)

@@ -3137,7 +3170,7 @@ nsh>
-

2.64 URL Decode (urldecode)

+

2.65 URL Decode (urldecode)

@@ -3154,7 +3187,7 @@ urldecode [-f] <string or filepath>
-

2.65 URL Encode (urlencode)

+

2.66 URL Encode (urlencode)

@@ -3171,7 +3204,7 @@ urlencode [-f] <string or filepath>
-

2.66 Add a New User (useradd)

+

2.67 Add a New User (useradd)

@@ -3188,7 +3221,7 @@ useradd <username> <password>
-

2.67 Delete a user (userdel)

+

2.68 Delete a user (userdel)

@@ -3205,7 +3238,7 @@ userdel <username>
-

2.68 Wait for Microseconds (usleep)

+

2.69 Wait for Microseconds (usleep)

@@ -3222,7 +3255,7 @@ usleep <usec>
-

2.69 Get File Via HTTP (wget)

+

2.70 Get File Via HTTP (wget)

@@ -3249,7 +3282,7 @@ wget [-o <local-path>] <url>
-

2.70 Hexadecimal Dump of Memory (xd)

+

2.71 Hexadecimal Dump of Memory (xd)

@@ -3506,6 +3539,11 @@ nsh> CONFIG_MODULE CONFIG_NSH_DISABLE_MODCMDS + + irqinfo + !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS && CONFIG_SCHED_IRQMONITOR +
+ kill !CONFIG_DISABLE_SIGNALS @@ -5486,10 +5524,10 @@ xxd -i romfs_img >nsh_romfsimg.h
  • CONFIG_NSH_ROMFSMOUNTPT
  • CONFIG_NSH_ROMFSSECTSIZE
  • CONFIG_NSH_STRERROR
  • +
  • CONFIG_NSH_TELNET
  • 4.2 APIs Exported by Architecture-Specific Logic to NuttX

    @@ -2605,7 +2632,7 @@ pointer to a watchdog structure.

    Returned Value:

    @@ -2662,7 +2689,7 @@ wd_start() on a given watchdog ID has any effect.

    Returned Value:

    @@ -3852,7 +3879,7 @@ void sched_timer_expiration(void);

    NOTE: The other interfaces described in this document are internal OS interface. boardctl() is an application interface to the OS. - There is not point, in fact, of using boardctl() within the OS; + There is no point, in fact, of using boardctl() within the OS; the board interfaces prototyped in include/nuttx/board.h may be called directly from within the OS.

    diff --git a/README.txt b/README.txt index adfead108410b4af248e67e7279135c3dfcb0157..032554efcac265a6b17df6c4f978706894f9686f 100644 --- a/README.txt +++ b/README.txt @@ -76,10 +76,10 @@ ENVIRONMENTS is that it is closer to a native Windows environment and uses only a minimal of add-on POSIX-land tools. - - NuttX can also be installed and built on a native Windows system, but - with some potential tool-related issues (see the discussion "Native - Windows Build" under "Building NuttX" below). GNUWin32 is used to - provide compatible native windows tools. + NuttX can also be installed and built on a native Windows system, but with + some potential tool-related issues (see the discussion "Native Windows + Build" under "Building NuttX" below). GNUWin32 is used to provide + compatible native windows tools. Installing Cygwin ----------------- @@ -635,7 +635,7 @@ Instantiating "Canned" Configurations refreshing the configuration as described below. NOTE: NuttX uses only compressed defconfig files. For the NuttX - defconfig files, this refrshing step is *NOT* optional; it is also + defconfig files, this refreshing step is *NOT* optional; it is also necessary to uncompress and regenerate the full making file. This is discussed further below. @@ -1040,6 +1040,14 @@ NuttX Configuration Tool under DOS that can be used: http://uvc.de/posts/linux-kernel-configuration-tool-mconf-under-windows.html + The configuration steps most recent versions of NuttX require the + kconfig-tweak tool that is not not available in the the above. However, + there has been an update to this Kconfig Windows tools that does include + kconfig-tweak: http://reclonelabs.com/more-kconfig-awesomeness-for-windows/ + + Source code is available here: https://github.com/reclone/kconfig-frontends-win32 + and https://github.com/reclone/kconfig-frontends-win32/releases + It is also possible to use the version of kconfig-frontends built under Cygwin outside of the Cygwin "sandbox" in a native Windows environment: @@ -1260,7 +1268,7 @@ Build Targets and Options Perform the distclean operation only in the user application directory. The apps/.config file is preserved so that this is not a "full" distclean - but more of a configuration "reset." + but more of a configuration "reset" for the application directory. export @@ -1318,7 +1326,6 @@ Native Windows Build The windows native build logic initiated if CONFIG_WINDOWS_NATIVE=y is defined in the NuttX configuration file: - This build: - Uses all Windows style paths @@ -1415,6 +1422,22 @@ Installing GNUWin32 CYGWIN BUILD PROBLEMS ^^^^^^^^^^^^^^^^^^^^^ +Performance +----------- + + Build performance under Cygwin is really not so bad, certainly not as good + as a Linux build. However, often you will find that the performance is + not just bad but terrible. If you are seeing awful performance.. like two + or three compilations per second.. the culprit is usually your Windows + Anti-Virus protection interfering with the build tool program execution. + + I use Cygwin quite often and I use Windows Defender. In order to get good + build performance, I routinely keep the Windows Defender "Virus & Threat + Protections Settings" screen up: I disable "Real-Time Protection" just + before entering 'make' then turn "Real-Time Protection" back on when the + build completes. With this additional nuisance step, I find that build + performance under Cygwin is completely acceptable. + Strange Path Problems --------------------- @@ -1468,6 +1491,7 @@ Window Native Toolchain Issues if you are using a native Windows toolchain. That bring us to #3: General Pre-built Toolchain Issues +---------------------------------- To continue with the list of "Window Native Toolchain Issues" we can add the following. These, however, are really just issues that you will have @@ -1521,6 +1545,7 @@ General Pre-built Toolchain Issues binutils and possibly different ABIs. Building Original Linux Boards in Cygwin +---------------------------------------- Some default board configurations are set to build under Linux and others to build under Windows with Cygwin. Various default toolchains may also @@ -1539,6 +1564,7 @@ Building Original Linux Boards in Cygwin ("Run As" option, right button) you find errors like "Permission denied". Recovering from Bad Configurations +---------------------------------- Many people make the mistake of configuring NuttX with the "canned" configuration and then just typing 'make' with disastrous consequences; diff --git a/ReleaseNotes b/ReleaseNotes index d3302c654ece99e39973764ebd62d9a0a5c59cbd..aaa960e996106203aaf0a8246ab1285d7d802c65 100644 --- a/ReleaseNotes +++ b/ReleaseNotes @@ -16669,7 +16669,7 @@ detailed bugfix information): * Examples/Tests: apps/examples: - All configurations that use NXIMAGE or NXHELLO must select - NX_MULTIUSER. All configuratinos that use examples/nxterm must + NX_MULTIUSER. All configurations that use examples/nxterm must enable CONFIG_LIB_BOARDCTL. - All configurations that use NXLINES must select NX_MULTIUSER. All configurations that use the NX server need to have larger POSIX diff --git a/TODO b/TODO index 3d92fd7ee2cc84745d03d4b523cd06576d4728fd..7801c545aaa30d5ef4ed2b83fee7c9cdd3be65c4 100644 --- a/TODO +++ b/TODO @@ -1,15 +1,15 @@ -NuttX TODO List (Last updated January 3, 2018) +NuttX TODO List (Last updated January 23, 2018) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with standards, things that could be improved, and ideas for enhancements. This -TODO list does not include issues associated with individual boar ports. See +TODO list does not include issues associated with individual board ports. See also the individual README.txt files in the configs/ sub-directories for issues related to each board port. nuttx/: - (12) Task/Scheduler (sched/) + (14) Task/Scheduler (sched/) (1) SMP (1) Memory Management (mm/) (0) Power Management (drivers/pm) @@ -19,7 +19,7 @@ nuttx/: (8) Kernel/Protected Build (3) C++ Support (6) Binary loaders (binfmt/) - (17) Network (net/, drivers/net) + (16) Network (net/, drivers/net) (4) USB (drivers/usbdev, drivers/usbhost) (0) Other drivers (drivers/) (12) Libraries (libc/, libm/) @@ -47,7 +47,7 @@ o Task/Scheduler (sched/) Status: Closed. No, this behavior will not be implemented. Priority: Medium, required for good emulation of process/pthread model. The current behavior allows for the main thread of a task to - exit() and any child pthreads will perist. That does raise + exit() and any child pthreads will persist. That does raise some issues: The main thread is treated much like just-another- pthread but must follow the semantics of a task or a process. That results in some inconsistencies (for example, with robust @@ -124,7 +124,7 @@ o Task/Scheduler (sched/) The fix for all of these issues it to have the callbacks run on the caller's thread as is currently done with signal handlers. Signals are delivered differently in - PROTECTED and KERNEL modes: The deliver is involes a + PROTECTED and KERNEL modes: The delivery involves a signal handling trampoline function in the user address space and two signal handlers: One to call the signal handler trampoline in user mode (SYS_signal_handler) and @@ -170,9 +170,14 @@ o Task/Scheduler (sched/) to make this change: Just move the pterrno field from struct tcb_s to struct task_group_s. However, I am still not sure if this should be done or not. - Status: Closed. The existing solution is better (although its - incompatibilities could show up in porting some code). - Priority: Low + NOTE: glibc behaves this way unless __thread is defined then, + in that case, it behaves like NuttX (using TLS to save the + thread local errno). + Status: Closed. The existing solution is better and compatible with + thread-aware GLIBC (although its incompatibilities could show + up in porting some code). I will retain this issue for + referencei only. + Priority: N/A Title: SCALABILITY Description: Task control information is retained in simple lists. This @@ -198,7 +203,7 @@ o Task/Scheduler (sched/) Description: The internal NuttX logic uses the same interfaces as does the application. That sometime produces a problem because there is "overloaded" functionality in those user interfaces - that are not desireable. + that are not desirable. For example, having cancellation points hidden inside of the OS can cause non-cancellation point interfaces to behave @@ -255,11 +260,14 @@ o Task/Scheduler (sched/) message queue used in the OS. I am keeping this issue open because (1) there are some known remaining calls that that will modify the errno (such as dup(), dup2(), - sched_getparam(), sched_reprioritize(). sched_setaffinity(), - task_activate(), mq_open(), mq_close(), and others) and (2) - there may still be calls that create cancellation points. - Need to check things like open(), close(), read(), write(), - and possibly others. + task_activate(), kthread_create(), exec(), mq_open(), + mq_close(), and others) and (2) there may still be calls that + create cancellation points. Need to check things like open(), + close(), read(), write(), and possibly others. + 2018-01-30: This change has been completed for the case of + scheduler functions used within the OS: sched_getparam(), + sched_setparam(), sched_getscheduler(), sched_setschedule(), + and sched_setaffinity(), Status: Open Priority: Low. Things are working OK the way they are. But the design @@ -327,6 +335,59 @@ o Task/Scheduler (sched/) Status: Open Priority: Low, only needed for more complete debug. + Title: PRIORITY INHERITANCE WITH SPORADIC SCHEDULER + Description: The sporadic scheduler manages CPU utilization by a task by + alternating between a high and a low priority. In either + state, it may have its priority boosted. However, under + some circumstances, it is impossible in the current design to + switch to the correct priority if a semaphore held by the + sporadic thread is participating in priority inheritance: + + There is an issue when switching from the high to the low + priority state. If the priority was NOT boosted above the + higher priority, it still may still need to boosted with + respect to the lower priority. If the highest priority + thread waiting on a semaphore held by the sporadic thread is + higher in priority than the low priority but less than the + higher priority, then new thread priority should be set to + that middle priority, not to the lower priority. + + In order to do this we would need to know the highest + priority from among all tasks waiting for the all semaphores + held by the sporadic task. That information could be + retained by the priority inheritance logic for use by the + sporadic scheduler. The boost priority could be retained in + a new field of the TCB (say, pend_priority). That + pend_priority could then be used when switching from the + higher to the lower priority. + Status: Open + Priority: Low. Does anyone actually use the sporadic scheduler? + + Title: SIMPLIFY SPORADIC SCHEDULER DESIGN + Description: I have been planning to re-implement sporadic scheduling for + some time. I believe that the current implementation is + unnecessarily complex. There is no clear statement for the + requirements of sporadic scheduling that I could find, so I + based the design on some behaviors of another OS that I saw + published (QNX as I recall). + + But I think that the bottom line requirement for sporadic + scheduling is that is it should make a best attempt to + control a fixed percentage of CPU bandwidth for a task in + during an interval only by modifying it is priority between + a low and a high priority. The current design involves + several timers: A "budget" timer plus a variable number of + "replenishment" timers and a lot of nonsense to duplicate QNX + behavior that I think I not necessary. + + It think that the sporadic scheduler could be re-implemented + with only the single "budget" timer. Instead of starting a + new "replenishment" timer when the task is resumed, that + single timer could just be extended. + Status: Open + Priority: Low. This is an enhancement. And does anyone actually use + the sporadic scheduler? + o SMP ^^^ @@ -572,7 +633,7 @@ o pthreads (sched/pthreads) group structure. I am, however, hesitant to make this change: In the FLAT build model, there is nothing that prevents people from accessing the inter-thread controls from threads in - differnt task groups. Making this change, while correct, + different task groups. Making this change, while correct, might introduce subtle bugs in code by people who are not using NuttX correctly. Status: Open @@ -745,7 +806,7 @@ o Kernel/Protected Build Title: USER MODE TASKS CAN MODIFY PRIVILEGED TASKS Description: Certain interfaces, such as sched_setparam(), sched_setscheduler(), etc. can be used by user mode tasks to - modify the behavior of priviledged kernel threads. + modify the behavior of privileged kernel threads. For a truly secure system. Privileges need to be checked in every interface that permits one thread to modify the properties of another thread. @@ -1022,23 +1083,19 @@ o Network (net/, drivers/net) Title: POLL/SELECT ON TCP/UDP SOCKETS NEEDS READ-AHEAD Description: poll()/select() only works for availability of buffered TCP/UDP read data (when read-ahead is enabled). The way writing is - handled in the network layer, all sockets must wait when send and - cannot be notified when they can send without waiting. + handled in the network layer, either (1) If CONFIG_UDP/TCP_WRITE_BUFFERS=y + then we never have to wait to send; otherwise, we always have + to wait to send. So it is impossible to notify the caller + when it can send without waiting. + + An exception "never having to wait" is the case where we are + out of memory for use in write buffering. In that case, the + blocking send()/sendto() would have to wait for the memory + to become available. Status: Open, probably will not be fixed. Priority: Medium... this does effect porting of applications that expect different behavior from poll()/select() - Title: SOCKETS DO NOT ALWAYS SUPPORT O_NONBLOCK - Description: sockets do not support all modes for O_NONBLOCK. Sockets - support nonblocking operations only (1) for TCP/IP non- - blocking read operations when read-ahead buffering is - enabled, (2) TCP/IP accept() operations when TCP/IP - connection backlog is enabled, (2) UDP/IP read() operations - when UDP read-ahead is enabled, and (3) non-blocking - operations on Unix domain sockets. - Status: Open - Priority: Low. - Title: INTERFACES TO LEAVE/JOIN IGMP MULTICAST GROUP Description: The interfaces used to leave/join IGMP multicast groups is non-standard. RFC3678 (IGMPv3) suggests ioctl() commands to do this (SIOCSIPMSFILTER) but @@ -1071,8 +1128,8 @@ o Network (net/, drivers/net) however. Others support the address filtering interfaces but have never been verifed: - C5471, LM3S, ez80, DM0x90 NIC, PIC: Do not support address - filtering. + C5471, LM3S, ez80, DM0x90 NIC, PIC, LPC54: Do not support + address filtering. Kinetis, LPC17xx, LPC43xx: Untested address filter support Status: Open @@ -1282,7 +1339,7 @@ o Network (net/, drivers/net) however, because its priority is low and so it is blocked from execution. - In the mean time, the remote host sends a - packet which is presumeably caught in the read-ahead buffer. + packet which is presumably caught in the read-ahead buffer. - Then the remote host closes the socket. Nothing happens on the target side because net_start_monitor() has not yet been called. @@ -1838,7 +1895,7 @@ o File system / Generic drivers (fs/, drivers/) (using pctl() instead sysctl()). My objective was to be able to control the number of available file descriptors on a task- by-task basis. The complexity due to the partitioning of - desciptor space in a range for file descriptors and a range + descriptor space in a range for file descriptors and a range for socket descriptors made this feature nearly impossible to implement. Status: Open @@ -1920,8 +1977,8 @@ o File system / Generic drivers (fs/, drivers/) 4) When comparing the checksum in the long file name entry with the checksum of the short file name, the checksum fails and the entire directory sequence is - ignored by readder() logic. This the file does not - appear in the 'ls'. + ignored by readdir() logic. This is why the file does + not appear in the 'ls'. o Graphics Subsystem (graphics/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2014,7 +2071,7 @@ o Graphics Subsystem (graphics/) Title: LOW-RES FRAMEBUFFER RENDERERING Description: There are obvious issues in the low-res, < 8 BPP, implemenation of - the framebuffer rendereing logic of graphics/nxglib/fb. I see two + the framebuffer rendering logic of graphics/nxglib/fb. I see two obvious problems in reviewing nxglib_copyrectangle(): 1. The masking logic might work 1 BPP, but is insufficient for other @@ -2026,7 +2083,7 @@ o Graphics Subsystem (graphics/) derives from nxglib_copyrectangle() and all of those issues have been resolved in that file. - Other frambuffer rendering functions probably have similary issues. + Other frambuffer rendering functions probably have similar issues. Status: Open Priority: Low. It is not surprising that there would be bugs in this logic: I have never encountered a hardware framebuffer with sub-byte pixel @@ -2279,11 +2336,11 @@ o Modbus (apps/modbus) Title: MODBUS NOT USABLE WITH USB SERIAL Description: Modbus can be used with USB serial, however, if the USB - serial connectiont is lost, Modbus will hang in an infinite + serial connection is lost, Modbus will hang in an infinite loop. This is a problem in the handling of select() and read() - and could probabaly resolved by studying the Modbus error + and could probably resolved by studying the Modbus error handling. A more USB-friendly solution would be to: (1) Re-connect and diff --git a/arch/Kconfig b/arch/Kconfig index 1efa5d52c2a4bd2ebeb961dcd9466204f56665e4..f1bd17077a6f6b6440bb6a9b5411550257b3f326 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -202,10 +202,23 @@ config ARCH_HAVE_RESET bool default n +config ARCH_HAVE_FETCHADD + bool + default n + config ARCH_HAVE_RTC_SUBSECONDS bool default n +config ARCH_GLOBAL_IRQDISABLE + bool + default n + ---help--- + Indicates that disabling interrupts on one CPU will either (1) disable + all interrupts globally on all CPUs, or (2) will disable interprocessor + interrupts as well so that no context switches can occur on the CPU + that disabled "local" interrupts. + config ARCH_USE_MMU bool "Enable MMU" default n diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 63ca64635c4beb812ee091ff5b1490fdc14886c2..337f9910c21a30c13544acc0542cbd15fc138688 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -16,6 +16,7 @@ config ARCH_CHIP_A1X select ARCH_HAVE_FPU select ARCH_HAVE_IRQPRIO select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_FETCHADD select ARCH_HAVE_SDRAM select BOOT_RUNFROMSDRAM select ARCH_HAVE_ADDRENV @@ -51,6 +52,7 @@ config ARCH_CHIP_EFM32 select ARCH_HAVE_CMNVECTOR select ARCH_HAVE_SPI_BITORDER select ARMV7M_CMNVECTOR + select ARCH_HAVE_FETCHADD ---help--- Energy Micro EFM32 microcontrollers (ARM Cortex-M). @@ -69,6 +71,7 @@ config ARCH_CHIP_IMX6 select ARCH_HAVE_FPU select ARCH_HAVE_TRUSTZONE select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_FETCHADD select ARCH_HAVE_SDRAM select BOOT_RUNFROMSDRAM select ARCH_HAVE_ADDRENV @@ -82,6 +85,7 @@ config ARCH_CHIP_KINETIS select ARCH_HAVE_MPU select ARM_HAVE_MPU_UNIFIED select ARCH_HAVE_FPU + select ARCH_HAVE_FETCHADD select ARCH_HAVE_RAMFUNCS select ARCH_HAVE_CMNVECTOR select ARCH_HAVE_I2CRESET @@ -103,6 +107,7 @@ config ARCH_CHIP_LC823450 select ARCH_HAVE_HEAPCHECK select ARCH_HAVE_MULTICPU select ARCH_HAVE_I2CRESET + select ARCH_GLOBAL_IRQDISABLE ---help--- ON Semiconductor LC823450 architectures (ARM dual Cortex-M3) @@ -114,15 +119,6 @@ config ARCH_CHIP_LM ---help--- TI/Luminary Stellaris LMS3 and LM4F architectures (ARM Cortex-M3/4) -config ARCH_CHIP_TIVA - bool "TI Tiva" - select ARCH_HAVE_CMNVECTOR - select ARCH_HAVE_MPU - select ARM_HAVE_MPU_UNIFIED - select ARCH_HAVE_FPU - ---help--- - TI Tiva TM4C architectures (ARM Cortex-M4) - config ARCH_CHIP_LPC11XX bool "NXP LPC11xx" select ARCH_CORTEXM0 @@ -136,6 +132,7 @@ config ARCH_CHIP_LPC17XX select ARCH_HAVE_CMNVECTOR select ARCH_HAVE_MPU select ARM_HAVE_MPU_UNIFIED + select ARCH_HAVE_FETCHADD ---help--- NXP LPC17xx architectures (ARM Cortex-M3) @@ -168,6 +165,7 @@ config ARCH_CHIP_LPC43XX select ARCH_HAVE_MPU select ARM_HAVE_MPU_UNIFIED select ARCH_HAVE_FPU + select ARCH_HAVE_FETCHADD ---help--- NPX LPC43XX architectures (ARM Cortex-M4). @@ -179,6 +177,7 @@ config ARCH_CHIP_LPC54XX select ARCH_HAVE_MPU select ARM_HAVE_MPU_UNIFIED select ARCH_HAVE_FPU + select ARCH_HAVE_FETCHADD ---help--- NPX LPC54XX architectures (ARM Cortex-M4). @@ -203,6 +202,7 @@ config ARCH_CHIP_SAMA5 select ARCH_HAVE_FPU select ARCH_HAVE_IRQPRIO select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_FETCHADD select ARCH_HAVE_I2CRESET select ARCH_HAVE_TICKLESS select ARCH_HAVE_ADDRENV @@ -229,6 +229,7 @@ config ARCH_CHIP_SAM34 select ARCH_HAVE_CMNVECTOR select ARCH_HAVE_MPU select ARM_HAVE_MPU_UNIFIED + select ARCH_HAVE_FETCHADD select ARCH_HAVE_RAMFUNCS select ARMV7M_HAVE_STACKCHECK ---help--- @@ -239,6 +240,7 @@ config ARCH_CHIP_SAMV7 select ARCH_HAVE_CMNVECTOR select ARCH_CORTEXM7 select ARCH_HAVE_MPU + select ARCH_HAVE_FETCHADD select ARCH_HAVE_RAMFUNCS select ARCH_HAVE_TICKLESS select ARCH_HAVE_I2CRESET @@ -253,6 +255,7 @@ config ARCH_CHIP_STM32 bool "STMicro STM32 F1/F2/F3/F4" select ARCH_HAVE_CMNVECTOR select ARCH_HAVE_MPU + select ARCH_HAVE_FETCHADD select ARCH_HAVE_I2CRESET select ARCH_HAVE_HEAPCHECK select ARCH_HAVE_PROGMEM @@ -276,6 +279,7 @@ config ARCH_CHIP_STM32F7 select ARCH_HAVE_CMNVECTOR select ARCH_CORTEXM7 select ARCH_HAVE_MPU + select ARCH_HAVE_FETCHADD select ARCH_HAVE_I2CRESET select ARCH_HAVE_HEAPCHECK select ARCH_HAVE_SPI_BITORDER @@ -312,17 +316,29 @@ config ARCH_CHIP_TMS570 bool "TI TMS570" select ENDIAN_BIG select ARCH_HAVE_LOWVECTORS + select ARCH_HAVE_FETCHADD select ARCH_HAVE_RAMFUNCS select ARMV7R_MEMINIT select ARMV7R_HAVE_DECODEFIQ ---help--- TI TMS570 family +config ARCH_CHIP_TIVA + bool "TI Tiva" + select ARCH_HAVE_CMNVECTOR + select ARCH_HAVE_MPU + select ARM_HAVE_MPU_UNIFIED + select ARCH_HAVE_FPU + select ARCH_HAVE_FETCHADD + ---help--- + TI Tiva TM4C architectures (ARM Cortex-M4) + config ARCH_CHIP_XMC4 bool "Infineon XMC4xxx" select ARCH_HAVE_CMNVECTOR select ARCH_CORTEXM4 select ARCH_HAVE_MPU + select ARCH_HAVE_FETCHADD select ARCH_HAVE_RAMFUNCS select ARCH_HAVE_I2CRESET select ARM_HAVE_MPU_UNIFIED diff --git a/arch/arm/include/samdl/samd21_irq.h b/arch/arm/include/samdl/samd21_irq.h index e0b26bf962a8b0c4bc1e06a420b166e048e6139d..8c44ed256d8fc74eefa576034bccabcb1f050ed9 100644 --- a/arch/arm/include/samdl/samd21_irq.h +++ b/arch/arm/include/samdl/samd21_irq.h @@ -86,9 +86,9 @@ #define SAM_IRQ_NINTS (28) /* Total number of interrupts */ #define SAM_IRQ_NIRQS (SAM_IRQ_INTERRUPT+28) /* The number of real interrupts */ -/* GPIO interrupts. Up to 16 pins may be configured to support interrupts */ +/* EIC interrupts. Up to 16 pins may be configured to support interrupts */ -#ifdef CONFIG_SAMDL_GPIOIRQ +#ifdef CONFIG_SAMDL_EIC # define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */ # define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */ # define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */ diff --git a/arch/arm/include/spinlock.h b/arch/arm/include/spinlock.h index 16079cc81a333f6fed72d3e7b80662859eb0390f..4a129faccabd5d395d76b06329c220f7704b824b 100644 --- a/arch/arm/include/spinlock.h +++ b/arch/arm/include/spinlock.h @@ -130,7 +130,7 @@ typedef uint8_t spinlock_t; * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/arm/src/a1x/Make.defs b/arch/arm/src/a1x/Make.defs index 7ffb41537e9ea2cdac4c22f0fd332bff095c2302..2697e5363d4539446f3440e95b8fbbef13605707 100644 --- a/arch/arm/src/a1x/Make.defs +++ b/arch/arm/src/a1x/Make.defs @@ -55,7 +55,7 @@ endif CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S arm_vfork.S -CMN_ASRCS += arm_testset.S +CMN_ASRCS += arm_testset.S arm_fetchadd.S CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S diff --git a/arch/arm/src/a1x/a1x_boot.c b/arch/arm/src/a1x/a1x_boot.c index 1dc27fd636520bc0cc3214c363b84cd3b64907c9..95bfc97aa1a7a245c1eef573eb29df107355fd5f 100644 --- a/arch/arm/src/a1x/a1x_boot.c +++ b/arch/arm/src/a1x/a1x_boot.c @@ -124,7 +124,7 @@ static const struct section_mapping_s section_mapping[] = /**************************************************************************** * Name: a1x_setupmappings * - * Description + * Description: * Map all of the initial memory regions defined in section_mapping[] * ****************************************************************************/ diff --git a/arch/arm/src/a1x/a1x_serial.c b/arch/arm/src/a1x/a1x_serial.c index 307dac2d5e0f7d9d1b18fe773488376bc968bbaa..0a91003a28a2d50d26e7d325916231238fdb1d03 100644 --- a/arch/arm/src/a1x/a1x_serial.c +++ b/arch/arm/src/a1x/a1x_serial.c @@ -710,7 +710,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) /************************************************************************************ * Name: a1x_uart0config, uart1config, uart2config, ..., uart7config * - * Descrption: + * Description: * Configure the UART * ************************************************************************************/ @@ -886,7 +886,7 @@ static inline void a1x_uart7config(void) /************************************************************************************ * Name: a1x_uartdl * - * Descrption: + * Description: * Select a divider to produce the BAUD from the UART PCLK. * * BAUD = PCLK / (16 * DL), or diff --git a/arch/arm/src/arm/pg_macros.h b/arch/arm/src/arm/pg_macros.h index 47616b426ae20f77dfe1dc346c85a8f6acc7afed..94263c7eb533f84421c8ee728284971a1ab30608 100644 --- a/arch/arm/src/arm/pg_macros.h +++ b/arch/arm/src/arm/pg_macros.h @@ -377,7 +377,7 @@ * ldr r3, =MMUFLAGS <-- L2 MMU flags * pg_l2map r0, r1, r2, r3, r4 * - * Inputs: + * Input Parameters: * l2 - Physical or virtual start address in the L2 page table, depending * upon the context. (modified) * ppage - The physical address of the start of the region to span. Must @@ -448,7 +448,7 @@ * ldr r4, =MMU_L1_PGTABFLAGS <-- L1 MMU flags * pg_l1span r0, r1, r2, r3, r4, r4 * - * Inputs (unmodified unless noted): + * Input Parameters (unmodified unless noted): * l1 - Physical or virtual address in the L1 table to begin writing (modified) * l2 - Physical start address in the L2 page table (modified) * npages - Number of pages to required to span that memory region (modified) @@ -462,7 +462,7 @@ * ppage - After the first page, this will be the full number of pages. * tmp - scratch * - * Return: + * Returned Value: * Nothing of interest. * * Assumptions: diff --git a/arch/arm/src/arm/up_blocktask.c b/arch/arm/src/arm/up_blocktask.c index 716966714561b7eae8a8e399edaa6f471d440f3a..97d1838d8a2f186790b8e3c920432aaf99287ba9 100644 --- a/arch/arm/src/arm/up_blocktask.c +++ b/arch/arm/src/arm/up_blocktask.c @@ -62,7 +62,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/arm/src/arm/up_dataabort.c b/arch/arm/src/arm/up_dataabort.c index 318c59232c46ab0464c2a6c3be1ec2885247cdf7..2a348b401e2911e232a8cd057791e44e488cb54c 100644 --- a/arch/arm/src/arm/up_dataabort.c +++ b/arch/arm/src/arm/up_dataabort.c @@ -59,7 +59,7 @@ /**************************************************************************** * Name: up_dataabort * - * Input parameters: + * Input Parameters: * regs - The standard, ARM register save array. * * If CONFIG_PAGING is selected in the NuttX configuration file, then these diff --git a/arch/arm/src/arm/up_prefetchabort.c b/arch/arm/src/arm/up_prefetchabort.c index ab97efd5737264712b8b8e4b20e68e35d7ad9f00..7fc02b11df320753e88c719c871d11b948d186d9 100644 --- a/arch/arm/src/arm/up_prefetchabort.c +++ b/arch/arm/src/arm/up_prefetchabort.c @@ -69,7 +69,7 @@ /**************************************************************************** * Name: up_prefetchabort * - * Description; + * Description: * This is the prefetch abort exception handler. The ARM prefetch abort * exception occurs when a memory fault is detected during an an * instruction fetch. diff --git a/arch/arm/src/arm/up_reprioritizertr.c b/arch/arm/src/arm/up_reprioritizertr.c index 95679e31dd7276d9b11c1c24d8a8dfa25e7c1e1c..10175b0df511ffccea33472afcf1512658ce4d99 100644 --- a/arch/arm/src/arm/up_reprioritizertr.c +++ b/arch/arm/src/arm/up_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/arm/src/arm/up_unblocktask.c b/arch/arm/src/arm/up_unblocktask.c index 12cb984d831bb31fc86a9d26052d0ae87972b139..e94c81de0c5cedd835d8c5ccf37f6c01988b0107 100644 --- a/arch/arm/src/arm/up_unblocktask.c +++ b/arch/arm/src/arm/up_unblocktask.c @@ -61,7 +61,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/arm/src/arm/vfork.S b/arch/arm/src/arm/vfork.S index 161315466fe81dd18b3bea6b31dd026500ec1244..661546daabe5a3ab79435d4b556fb2ed0e0a5825 100644 --- a/arch/arm/src/arm/vfork.S +++ b/arch/arm/src/arm/vfork.S @@ -86,10 +86,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and returns * the process ID of the child process to the parent process. Otherwise, -1 is * returned to the parent, no child process is created, and errno is set to diff --git a/arch/arm/src/armv6-m/up_blocktask.c b/arch/arm/src/armv6-m/up_blocktask.c index 2a95163cca220e9fedaf323a7f0ebc88d02771d2..c01894715a41cbee523c6c2e6f86b0e913fcd9e2 100644 --- a/arch/arm/src/armv6-m/up_blocktask.c +++ b/arch/arm/src/armv6-m/up_blocktask.c @@ -61,7 +61,7 @@ * be stopped. Save its context and move it to the inactive list specified * by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally the task at * the head of the list). It most be stopped, its context saved and * moved into one of the waiting task lists. It it was the task at the diff --git a/arch/arm/src/armv6-m/up_fullcontextrestore.S b/arch/arm/src/armv6-m/up_fullcontextrestore.S index 048c468749d44feff5c0c0eb6deaf4a23f38fbea..4ec6a32a7ed743d7c59b40bc3a2765c6ad40ffdc 100644 --- a/arch/arm/src/armv6-m/up_fullcontextrestore.S +++ b/arch/arm/src/armv6-m/up_fullcontextrestore.S @@ -70,7 +70,7 @@ * * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; * - * Return: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/armv6-m/up_reprioritizertr.c b/arch/arm/src/armv6-m/up_reprioritizertr.c index 41f0c8700d33b9b6859c372b6a134087d4ed89e7..0f99b917407ec6efc46c6caa0d1cebc2f3ee95dc 100644 --- a/arch/arm/src/armv6-m/up_reprioritizertr.c +++ b/arch/arm/src/armv6-m/up_reprioritizertr.c @@ -67,7 +67,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/arm/src/armv6-m/up_saveusercontext.S b/arch/arm/src/armv6-m/up_saveusercontext.S index bfc9a70ea884a35f1a6cfb71df9a72e53f60bd16..55e6461b2b40ab27589d4f3badd0b6bf3c457a6f 100644 --- a/arch/arm/src/armv6-m/up_saveusercontext.S +++ b/arch/arm/src/armv6-m/up_saveusercontext.S @@ -70,7 +70,7 @@ * * int up_saveusercontext(uint32_t *saveregs); * - * Return: + * Returned Value: * 0: Normal return * 1: Context switch return * diff --git a/arch/arm/src/armv6-m/up_signal_dispatch.c b/arch/arm/src/armv6-m/up_signal_dispatch.c index fa3cea62224a18debaf5079b8cc5b89c285a155f..45446a2b5e47a3d2dfc4e747fd515cc71c2f5a11 100644 --- a/arch/arm/src/armv6-m/up_signal_dispatch.c +++ b/arch/arm/src/armv6-m/up_signal_dispatch.c @@ -78,12 +78,12 @@ * user-space, signal handler trampoline function. It is called from * up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * sighand - The address user-space signal handling function * signo, info, and ucontext - Standard arguments to be passed to the * signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via an architecture specific system call made by up_signal_handler(). * However, this will look like a normal return by the caller of diff --git a/arch/arm/src/armv6-m/up_signal_handler.S b/arch/arm/src/armv6-m/up_signal_handler.S index f294db9fc805872e268044ddd079a4791fd9e32d..9ad7ec81330d055ffa60067b8a92fa0e508fdf66 100644 --- a/arch/arm/src/armv6-m/up_signal_handler.S +++ b/arch/arm/src/armv6-m/up_signal_handler.S @@ -65,13 +65,13 @@ * This function is the user-space, signal handler trampoline function. It * is called from up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * R0 = sighand * The address user-space signal handling function * R1-R3 = signo, info, and ucontext * Standard arguments to be passed to the signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via the SYS_signal_handler_return (see svcall.h) * diff --git a/arch/arm/src/armv6-m/up_switchcontext.S b/arch/arm/src/armv6-m/up_switchcontext.S index c24f501fc2e6958d588a6e54cc7ad33d5e759a61..dc5aca9169bf56a123c1cc46f96552453390b38f 100644 --- a/arch/arm/src/armv6-m/up_switchcontext.S +++ b/arch/arm/src/armv6-m/up_switchcontext.S @@ -71,7 +71,7 @@ * * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); * - * Return: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/armv6-m/up_unblocktask.c b/arch/arm/src/armv6-m/up_unblocktask.c index 62ec07d90a31c2688a5283d50d78c2e1de8672d1..1fbae1295093789f78430c893a46a018aad288cc 100644 --- a/arch/arm/src/armv6-m/up_unblocktask.c +++ b/arch/arm/src/armv6-m/up_unblocktask.c @@ -60,7 +60,7 @@ * execute. Move the TCB to the ready-to-run list, restore its context, * and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is in one of the * waiting tasks lists. It must be moved to the ready-to-run list and, * if it is the highest priority ready to run taks, executed. diff --git a/arch/arm/src/armv6-m/vfork.S b/arch/arm/src/armv6-m/vfork.S index 20c003d3ea9fbb7b8d7dd22789810c28b31d5192..c64e96e22cff780737965efa18142bb6e0cb32e4 100644 --- a/arch/arm/src/armv6-m/vfork.S +++ b/arch/arm/src/armv6-m/vfork.S @@ -87,10 +87,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and returns * the process ID of the child process to the parent process. Otherwise, -1 is * returned to the parent, no child process is created, and errno is set to diff --git a/arch/arm/src/armv7-a/arm_blocktask.c b/arch/arm/src/armv7-a/arm_blocktask.c index 3f02e46b362b80cc8e1e00311b4c57d6acac62bb..8fdbef00a36fa573155dddcfc1b4a24b71491389 100644 --- a/arch/arm/src/armv7-a/arm_blocktask.c +++ b/arch/arm/src/armv7-a/arm_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/up_blocktask.c * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -62,7 +62,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the @@ -76,8 +76,21 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb; bool switch_needed; +#ifdef CONFIG_SMP + int cpu; + + /* Get the TCB of the currently executing task on this CPU (avoid using + * this_task() because the TCBs may be in an inappropriate state right + * now). + */ + + cpu = this_cpu(); + rtcb = current_task(cpu); +#else + rtcb = this_task(); +#endif /* Verify that the context switch can be performed */ @@ -128,7 +141,11 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif /* Reset scheduler parameters */ @@ -152,7 +169,11 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/arm/src/armv7-a/arm_cpuhead.S b/arch/arm/src/armv7-a/arm_cpuhead.S index 02735e36d50c39df1d5ff8a558fcf138d66df0fa..3ed001656d387490bcaacb66c744e68573c1cd94 100644 --- a/arch/arm/src/armv7-a/arm_cpuhead.S +++ b/arch/arm/src/armv7-a/arm_cpuhead.S @@ -93,7 +93,7 @@ * * These functions are provided by the common ARMv7-A logic. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/arch/arm/src/armv7-a/arm_cpuidlestack.c b/arch/arm/src/armv7-a/arm_cpuidlestack.c index dd264d25c148c4e3f42adef1fc36860a5b953909..1648de2fdb89ba1a694d69e28eec8a0e7e96d500 100644 --- a/arch/arm/src/armv7-a/arm_cpuidlestack.c +++ b/arch/arm/src/armv7-a/arm_cpuidlestack.c @@ -112,7 +112,7 @@ static FAR const uint32_t *g_cpu_stackalloc[CONFIG_SMP_NCPUS] = * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - cpu: CPU index that indicates which CPU the IDLE task is * being created for. * - tcb: The TCB of new CPU IDLE task diff --git a/arch/arm/src/armv7-a/arm_dataabort.c b/arch/arm/src/armv7-a/arm_dataabort.c index 50c95a20188001fd7013b49f8822ce9ec930d9bc..17073a925e0c27a5c4c356fa20c44ac7de7004c2 100644 --- a/arch/arm/src/armv7-a/arm_dataabort.c +++ b/arch/arm/src/armv7-a/arm_dataabort.c @@ -59,7 +59,7 @@ /**************************************************************************** * Name: arm_dataabort * - * Input parameters: + * Input Parameters: * regs - The standard, ARM register save array. * * If CONFIG_PAGING is selected in the NuttX configuration file, then these diff --git a/arch/arm/src/armv7-a/arm_fetchadd.S b/arch/arm/src/armv7-a/arm_fetchadd.S new file mode 100644 index 0000000000000000000000000000000000000000..84b0b7d482359f802c8d7fe1c4779b7d1b33030f --- /dev/null +++ b/arch/arm/src/armv7-a/arm_fetchadd.S @@ -0,0 +1,255 @@ +/**************************************************************************** + * arch/arm/src/armv7-a/arm_fetchadd.S + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + + .file "arm_fetchadd.S" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + + .text + +/**************************************************************************** + * Name: up_fetchadd32 + * + * Description: + * Perform an atomic fetch add operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be incremented. + * value - The 32-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd32 + .type up_fetchadd32, %function + +up_fetchadd32: + +1: + ldrex r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd32, . - up_fetchadd32 + +/**************************************************************************** + * Name: up_fetchsub32 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be decremented. + * value - The 32-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub32 + .type up_fetchsub32, %function + +up_fetchsub32: + +1: + ldrex r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub32, . - up_fetchsub32 + +/**************************************************************************** + * Name: up_fetchadd16 + * + * Description: + * Perform an atomic fetch add operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be incremented. + * value - The 16-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd16 + .type up_fetchadd16, %function + +up_fetchadd16: + +1: + ldrexh r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd16, . - up_fetchadd16 + +/**************************************************************************** + * Name: up_fetchsub16 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be decremented. + * value - The 16-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub16 + .type up_fetchsub16, %function + +up_fetchsub16: + +1: + ldrexh r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + /* Attempt to save the decremented value */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub16, . - up_fetchsub16 + +/**************************************************************************** + * Name: up_fetchadd8 + * + * Description: + * Perform an atomic fetch add operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be incremented. + * value - The 8-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd8 + .type up_fetchadd8, %function + +up_fetchadd8: + +1: + ldrexb r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd8, . - up_fetchadd8 + +/**************************************************************************** + * Name: up_fetchsub8 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be decremented. + * value - The 8-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub8 + .type up_fetchsub8, %function + +up_fetchsub8: + +1: + ldrexb r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub8, . - up_fetchsub8 + .end diff --git a/arch/arm/src/armv7-a/arm_fullcontextrestore.S b/arch/arm/src/armv7-a/arm_fullcontextrestore.S index 64f74c8a98f9f4ab0b8754f46a20b5a3a6e1e94c..f65adbfadb3ff26d3aa56606a264431dab526f4f 100644 --- a/arch/arm/src/armv7-a/arm_fullcontextrestore.S +++ b/arch/arm/src/armv7-a/arm_fullcontextrestore.S @@ -62,7 +62,7 @@ * * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/armv7-a/arm_gicv2.c b/arch/arm/src/armv7-a/arm_gicv2.c index 0232685dc828fa01fde4bddc51a3cd5b7f189655..8c6eee1509ac0372ea477b3f22ec320bc3cfe518 100644 --- a/arch/arm/src/armv7-a/arm_gicv2.c +++ b/arch/arm/src/armv7-a/arm_gicv2.c @@ -372,7 +372,7 @@ void arm_gic_initialize(void) * the irq number of the interrupt and then to call arm_doirq to dispatch * the interrupt. * - * Input parameters: + * Input Parameters: * regs - A pointer to the register save area on the stack. * ****************************************************************************/ @@ -532,7 +532,7 @@ int up_prioritize_irq(int irq, int priority) * Since this API is not supported on all architectures, it should be * avoided in common implementations where possible. * - * Input Paramters: + * Input Parameters: * irq - The interrupt request to modify. * edge - False: Active HIGH level sensitive, True: Rising edge sensitive * diff --git a/arch/arm/src/armv7-a/arm_prefetchabort.c b/arch/arm/src/armv7-a/arm_prefetchabort.c index 0bb8cd37932f68ed9c101f5ad575b3a7f7f16f38..a10f703287c2b7ef0bdedfaae7db56a29b0d8d1e 100644 --- a/arch/arm/src/armv7-a/arm_prefetchabort.c +++ b/arch/arm/src/armv7-a/arm_prefetchabort.c @@ -57,7 +57,7 @@ /**************************************************************************** * Name: arm_prefetchabort * - * Description; + * Description: * This is the prefetch abort exception handler. The ARM prefetch abort * exception occurs when a memory fault is detected during an an * instruction fetch. diff --git a/arch/arm/src/armv7-a/arm_releasepending.c b/arch/arm/src/armv7-a/arm_releasepending.c index 7afc6989a75829f647ee14ba35e2a6b3ef991415..b4a811f7d2ff4dc34e03f265f1889d8256820368 100644 --- a/arch/arm/src/armv7-a/arm_releasepending.c +++ b/arch/arm/src/armv7-a/arm_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/arm_releasepending.c * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -56,16 +56,28 @@ * Name: up_release_pending * * Description: - * Release and ready-to-run tasks that have - * collected in the pending task list. This can call a - * context switch if a new task is placed at the head of - * the ready to run list. + * Release and ready-to-run tasks that have collected in the pending task + * list. This can call a context switch if a new task is placed at the + * head of the ready to run list. * ****************************************************************************/ void up_release_pending(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb; +#ifdef CONFIG_SMP + int cpu; + + /* Get the TCB of the currently executing task on this CPU (avoid using + * this_task() because the TCBs may be in an inappropriate state right + * now). + */ + + cpu = this_cpu(); + rtcb = current_task(cpu); +#else + rtcb = this_task(); +#endif sinfo("From TCB=%p\n", rtcb); @@ -96,7 +108,11 @@ void up_release_pending(void) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif /* Update scheduler parameters */ @@ -121,7 +137,11 @@ void up_release_pending(void) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/arm/src/armv7-a/arm_reprioritizertr.c b/arch/arm/src/armv7-a/arm_reprioritizertr.c index 4381178e05b311e620c620b6d9465e10cec5a333..359392e990b6324a946d194ac4db97ef8f2dd500 100644 --- a/arch/arm/src/armv7-a/arm_reprioritizertr.c +++ b/arch/arm/src/armv7-a/arm_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * @@ -92,8 +92,21 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) } else { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb; bool switch_needed; +#ifdef CONFIG_SMP + int cpu; + + /* Get the TCB of the currently executing task on this CPU (avoid + * using this_task() because the TCBs may be in an inappropriate + * state right now). + */ + + cpu = this_cpu(); + rtcb = current_task(cpu); +#else + rtcb = this_task(); +#endif sinfo("TCB=%p PRI=%d\n", tcb, priority); @@ -150,7 +163,11 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif /* Update scheduler parameters */ @@ -174,7 +191,11 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/arm/src/armv7-a/arm_schedulesigaction.c b/arch/arm/src/armv7-a/arm_schedulesigaction.c index 9f1a46f67542b2a245d73006af5bec0462302d7a..2bb30374a399f85d2a7d59e191436b3b114789b8 100644 --- a/arch/arm/src/armv7-a/arm_schedulesigaction.c +++ b/arch/arm/src/armv7-a/arm_schedulesigaction.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/arm_schedulesigaction.c * - * Copyright (C) 2013, 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -116,7 +116,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is - * signalling itself for some reason. + * signaling itself for some reason. */ if (!CURRENT_REGS) @@ -133,7 +133,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * * Hmmm... there looks like a latent bug here: The following logic * would fail in the strange case where we are in an interrupt - * handler, the thread is signalling itself, but a context switch + * handler, the thread is signaling itself, but a context switch * to another task has occurred so that CURRENT_REGS does not * refer to the thread of this_task()! */ @@ -166,7 +166,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Otherwise, we are (1) signaling a task is not running from an * interrupt handler or (2) we are not in an interrupt handler and the - * running task is signalling some other non-running task. + * running task is signaling some other non-running task. */ else @@ -222,7 +222,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) cpu = tcb->cpu; /* CASE 1: We are not in an interrupt handler and a task is - * signalling itself for some reason. + * signaling itself for some reason. */ if (cpu == me && !CURRENT_REGS) @@ -238,51 +238,36 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * CPU. In the former case, we will have to PAUSE the other CPU * first. But in either case, we will have to modify the return * state as well as the state in the TCB. - * - * Hmmm... there looks like a latent bug here: The following logic - * would fail in the strange case where we are in an interrupt - * handler, the thread is signalling itself, but a context switch - * to another task has occurred so that CURRENT_REGS does not - * refer to the thread of this_task()! */ else { - /* If we signalling a task running on the other CPU, we have + /* If we signaling a task running on the other CPU, we have * to PAUSE the other CPU. */ if (cpu != me) { + /* Pause the CPU */ + up_cpu_pause(cpu); - } - /* Save the return lr and cpsr and one scratch register - * These will be restored by the signal trampoline after - * the signals have been delivered. - */ + /* Wait while the pause request is pending */ - tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; - tcb->xcp.saved_cpsr = CURRENT_REGS[REG_CPSR]; + while (up_cpu_pausereq(cpu)) + { + } - /* Increment the IRQ lock count so that when the task is restarted, - * it will hold the IRQ spinlock. - */ + /* Now tcb on the other CPU can be accessed safely */ - DEBUGASSERT(tcb->irqcount < INT16_MAX); - tcb->irqcount++; + /* Copy tcb->xcp.regs to tcp.xcp.saved. These will be restored + * by the signal trampoline after the signal has been delivered. + */ - /* Handle a possible race condition where the TCB was suspended - * just before we paused the other CPU. The critical section - * established above will prevent new threads from running on - * that CPU, but it will not guarantee that the running thread - * did not suspend itself (allowing any threads "assigned" to - * the CPU to run). - */ + tcb->xcp.sigdeliver = sigdeliver; + tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; + tcb->xcp.saved_cpsr = tcb->xcp.regs[REG_CPSR]; - if (tcb->task_state != TSTATE_TASK_RUNNING) - { /* Then set up to vector to the trampoline with interrupts * disabled */ @@ -292,22 +277,25 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) } else { - /* Then set up to vector to the trampoline with interrupts - * disabled + /* tcb is running on the same CPU */ + + /* Save the return PC, CPSR and either the BASEPRI or PRIMASK + * registers (and perhaps also the LR). These will be + * restored by the signal trampoline after the signal has been + * delivered. */ - CURRENT_REGS[REG_PC] = (uint32_t)up_sigdeliver; - CURRENT_REGS[REG_CPSR] = (PSR_MODE_SVC | PSR_I_BIT | PSR_F_BIT); + tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; + tcb->xcp.saved_cpsr = CURRENT_REGS[REG_CPSR]; - /* In an SMP configuration, the interrupt disable logic also - * involves spinlocks that are configured per the TCB irqcount - * field. This is logically equivalent to enter_critical_section(). - * The matching call to leave_critical_section() will be - * performed in up_sigdeliver(). + /* Then set up vector to the trampoline with interrupts + * disabled. The kernel-space trampoline must run in + * privileged thread mode. */ - spin_setbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, - &g_cpu_irqlock); + CURRENT_REGS[REG_PC] = (uint32_t)up_sigdeliver; + CURRENT_REGS[REG_CPSR] = (PSR_MODE_SVC | PSR_I_BIT | PSR_F_BIT); /* And make sure that the saved context in the TCB is the same * as the interrupt return context. @@ -316,6 +304,23 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) up_savestate(tcb->xcp.regs); } + /* Increment the IRQ lock count so that when the task is restarted, + * it will hold the IRQ spinlock. + */ + + DEBUGASSERT(tcb->irqcount < INT16_MAX); + tcb->irqcount++; + + /* In an SMP configuration, the interrupt disable logic also + * involves spinlocks that are configured per the TCB irqcount + * field. This is logically equivalent to enter_critical_section(). + * The matching call to leave_critical_section() will be + * performed in up_sigdeliver(). + */ + + spin_setbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, + &g_cpu_irqlock); + /* RESUME the other CPU if it was PAUSED */ if (cpu != me) @@ -327,7 +332,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Otherwise, we are (1) signaling a task is not running from an * interrupt handler or (2) we are not in an interrupt handler and the - * running task is signalling some other non-running task. + * running task is signaling some other non-running task. */ else diff --git a/arch/arm/src/armv7-a/arm_signal_dispatch.c b/arch/arm/src/armv7-a/arm_signal_dispatch.c index 5925923760fe5aea3ba112b801c821a9038f1430..1b461f5cb922b17e8a4ec0b943f279a0f38ecb62 100644 --- a/arch/arm/src/armv7-a/arm_signal_dispatch.c +++ b/arch/arm/src/armv7-a/arm_signal_dispatch.c @@ -67,12 +67,12 @@ * user-space, signal handler trampoline function. It is called from * up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * sighand - The address user-space signal handling function * signo, info, and ucontext - Standard arguments to be passed to the * signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via an architecture specific system call made by up_signal_handler(). * However, this will look like a normal return by the caller of diff --git a/arch/arm/src/armv7-a/arm_testset.S b/arch/arm/src/armv7-a/arm_testset.S index 638736e4d6729815674902098a7e3c867ee42760..feb3ea3df466e323841461456be872bd6ecb569d 100644 --- a/arch/arm/src/armv7-a/arm_testset.S +++ b/arch/arm/src/armv7-a/arm_testset.S @@ -72,7 +72,7 @@ * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object (r0). diff --git a/arch/arm/src/armv7-a/arm_unblocktask.c b/arch/arm/src/armv7-a/arm_unblocktask.c index e3d2fa3fc79ca0597e0c23195b98320f00adf472..906d33796b69cdaeda7bc5284560705a5989f105 100644 --- a/arch/arm/src/armv7-a/arm_unblocktask.c +++ b/arch/arm/src/armv7-a/arm_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/arm_unblocktask.c * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -61,7 +61,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority @@ -71,7 +71,20 @@ void up_unblock_task(struct tcb_s *tcb) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb; +#ifdef CONFIG_SMP + int cpu; + + /* Get the TCB of the currently executing task on this CPU (avoid using + * this_task() because the TCBs may be in an inappropriate state right + * now). + */ + + cpu = this_cpu(); + rtcb = current_task(cpu); +#else + rtcb = this_task(); +#endif /* Verify that the context switch can be performed */ @@ -110,7 +123,11 @@ void up_unblock_task(struct tcb_s *tcb) * of the ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif /* Update scheduler parameters */ @@ -136,7 +153,11 @@ void up_unblock_task(struct tcb_s *tcb) * ready-to-run task list. */ +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/arm/src/armv7-a/arm_vfork.S b/arch/arm/src/armv7-a/arm_vfork.S index b7abc1c0f22a306161c9b7fa3f133510370e5857..2e10c9509903ba9242cbb763e09430d995371852 100644 --- a/arch/arm/src/armv7-a/arm_vfork.S +++ b/arch/arm/src/armv7-a/arm_vfork.S @@ -88,10 +88,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and * returns the process ID of the child process to the parent process. * Otherwise, -1 is returned to the parent, no child process is created, diff --git a/arch/arm/src/armv7-a/crt0.c b/arch/arm/src/armv7-a/crt0.c index a06e3f858e24bdeced0d4793a184f30f1228af88..f13148aa9b85669b19ef003b5ecd032f0144f79f 100644 --- a/arch/arm/src/armv7-a/crt0.c +++ b/arch/arm/src/armv7-a/crt0.c @@ -67,13 +67,13 @@ int main(int argc, char *argv[]); * R4-R10 - static registers must be preserved * R12-R14 - LR and SP must be preserved * - * Inputs: + * Input Parameters: * R0 = sighand * The address user-space signal handling function * R1-R3 = signo, info, and ucontext * Standard arguments to be passed to the signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via the SYS_signal_handler_return (see svcall.h) * diff --git a/arch/arm/src/armv7-a/gic.h b/arch/arm/src/armv7-a/gic.h index 8c882ad6ddc2c8711c978f0885c83fe11b8a9afa..0281abae6786ffd7b12775fa924c6a82c839a542 100644 --- a/arch/arm/src/armv7-a/gic.h +++ b/arch/arm/src/armv7-a/gic.h @@ -634,7 +634,7 @@ static inline unsigned int arm_gic_nlines(void) * If CONFIG_SMP is not selected, the cpuset is ignored and SGI is sent * only to the current CPU. * - * Input Paramters + * Input Parameters: * sgi - The SGI interrupt ID (0-15) * cpuset - The set of CPUs to receive the SGI * @@ -714,7 +714,7 @@ void arm_gic_initialize(void); * Since this API is not supported on all architectures, it should be * avoided in common implementations where possible. * - * Input Paramters: + * Input Parameters: * irq - The interrupt request to modify. * edge - False: Active HIGH level sensitive, True: Rising edge sensitive * @@ -735,7 +735,7 @@ int arm_gic_irq_trigger(int irq, bool edge); * the irq number of the interrupt and then to call arm_doirq to dispatch * the interrupt. * - * Input parameters: + * Input Parameters: * regs - A pointer to the register save area on the stack. * ****************************************************************************/ diff --git a/arch/arm/src/armv7-a/gtm.h b/arch/arm/src/armv7-a/gtm.h index 347085f6737a8b6498d8b693c09e8c8f9cb5ebd0..4fa10f318418db5bd2bd4a51355ad764e30ebf9e 100644 --- a/arch/arm/src/armv7-a/gtm.h +++ b/arch/arm/src/armv7-a/gtm.h @@ -111,17 +111,6 @@ extern "C" #define EXTERN extern #endif -/**************************************************************************** - * Name: - * - * Description: - * - * Input Parameters: - * - * Returned Value: - * - ****************************************************************************/ - /* Clocking: * CLK - This is the main clock of the Cortex-A9 processor. All Cortex-A9 * processors in the Cortex-A9 MPCore processor and the SCU are clocked diff --git a/arch/arm/src/armv7-a/mmu.h b/arch/arm/src/armv7-a/mmu.h index c6338d33378b30395f574085ac6aac80ed98a4f6..ba0870c235234c8b736337948ca14916290978a0 100644 --- a/arch/arm/src/armv7-a/mmu.h +++ b/arch/arm/src/armv7-a/mmu.h @@ -897,7 +897,7 @@ struct section_mapping_s * Description: * Disable the MMU * - * Inputs: + * Input Parameters: * None * ************************************************************************************/ @@ -919,7 +919,7 @@ struct section_mapping_s * instruction that performs the operation. Software does not have to write a * value to the register before issuing the MCR instruction. * - * Inputs: + * Input Parameters: * None * ************************************************************************************/ @@ -934,7 +934,7 @@ struct section_mapping_s * Description: * Invalidate unified TLB entry by MVA all ASID Inner Shareable * - * Inputs: + * Input Parameters: * vaddr - The virtual address to be invalidated * ************************************************************************************/ @@ -952,7 +952,7 @@ struct section_mapping_s * Description: * Write the Domain Access Control Register (DACR) * - * Inputs: + * Input Parameters: * dacr - The new value of the DACR * ************************************************************************************/ @@ -979,7 +979,7 @@ struct section_mapping_s * Table Base Register 0 (TTBR0). Then it clears the TTB control * register (TTBCR), indicating that we are using TTBR0. * - * Inputs: + * Input Parameters: * ttb - The new value of the TTBR0 register * ************************************************************************************/ @@ -1012,7 +1012,7 @@ struct section_mapping_s * ldr r3, =MMUFLAGS <-- L2 MMU flags * pg_l2map r0, r1, r2, r3, r4 * - * Inputs: + * Input Parameters: * l2 - Physical or virtual start address in the L2 page table, depending * upon the context. (modified) * ppage - The physical address of the start of the region to span. Must @@ -1083,7 +1083,7 @@ struct section_mapping_s * ldr r4, =MMU_L1_PGTABFLAGS <-- L1 MMU flags * pg_l1span r0, r1, r2, r3, r4, r4 * - * Inputs (unmodified unless noted): + * Input Parameters (unmodified unless noted): * l1 - Physical or virtual address in the L1 table to begin writing (modified) * l2 - Physical start address in the L2 page table (modified) * npages - Number of pages to required to span that memory region (modified) @@ -1097,7 +1097,7 @@ struct section_mapping_s * ppage - After the first page, this will be the full number of pages. * tmp - scratch * - * Return: + * Returned Value: * Nothing of interest. * * Assumptions: @@ -1159,7 +1159,7 @@ struct section_mapping_s * Description: * Disable the MMU * - * Inputs: + * Input Parameters: * None * ************************************************************************************/ @@ -1188,7 +1188,7 @@ static inline void cp15_disable_mmu(void) * instruction that performs the operation. Software does not have to write a * value to the register before issuing the MCR instruction. * - * Inputs: + * Input Parameters: * None * ************************************************************************************/ @@ -1210,7 +1210,7 @@ static inline void cp15_invalidate_tlbs(void) * Description: * Invalidate unified TLB entry by MVA all ASID Inner Shareable * - * Inputs: + * Input Parameters: * vaddr - The virtual address to be invalidated * ************************************************************************************/ @@ -1235,7 +1235,7 @@ static inline void cp15_invalidate_tlb_bymva(uint32_t vaddr) * Description: * Write the Domain Access Control Register (DACR) * - * Inputs: + * Input Parameters: * dacr - The new value of the DACR * ************************************************************************************/ @@ -1269,7 +1269,7 @@ static inline void cp15_wrdacr(unsigned int dacr) * Table Base Register 0 (TTBR0). Then it clears the TTB control * register (TTBCR), indicating that we are using TTBR0. * - * Inputs: + * Input Parameters: * ttb - The new value of the TTBR0 register * ************************************************************************************/ diff --git a/arch/arm/src/armv7-a/smp.h b/arch/arm/src/armv7-a/smp.h index 7c9d1cc72af68cd3678a4718cd6037a0077ee532..1ae2bbfad8f8552f51ef428167a8b4d7d8a08440 100644 --- a/arch/arm/src/armv7-a/smp.h +++ b/arch/arm/src/armv7-a/smp.h @@ -93,7 +93,7 @@ extern uint32_t g_cpu3_idlestack[SMP_STACK_WORDS]; * * These functions are provided by the common ARMv7-A logic. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -129,7 +129,7 @@ void __cpu3_start(void); * This function must be provided by the each ARMv7-A MCU and implement * MCU-specific initialization logic. * - * Input parameters: + * Input Parameters: * cpu - The CPU index. This is the same value that would be obtained by * calling up_cpu_index(); * diff --git a/arch/arm/src/armv7-m/gnu/up_fetchadd.S b/arch/arm/src/armv7-m/gnu/up_fetchadd.S new file mode 100644 index 0000000000000000000000000000000000000000..143c38e5163234965cceb3971e7ef0d39108a9c1 --- /dev/null +++ b/arch/arm/src/armv7-m/gnu/up_fetchadd.S @@ -0,0 +1,257 @@ +/**************************************************************************** + * arch/arm/src/armv7-m/gnu/up_fetchadd.S + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + + .syntax unified + .thumb + .file "up_fetchadd.S" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + + .text + +/**************************************************************************** + * Name: up_fetchadd32 + * + * Description: + * Perform an atomic fetch add operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be incremented. + * value - The 32-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd32 + .type up_fetchadd32, %function + +up_fetchadd32: + +1: + ldrex r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd32, . - up_fetchadd32 + +/**************************************************************************** + * Name: up_fetchsub32 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be decremented. + * value - The 32-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub32 + .type up_fetchsub32, %function + +up_fetchsub32: + +1: + ldrex r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub32, . - up_fetchsub32 + +/**************************************************************************** + * Name: up_fetchadd16 + * + * Description: + * Perform an atomic fetch add operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be incremented. + * value - The 16-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd16 + .type up_fetchadd16, %function + +up_fetchadd16: + +1: + ldrexh r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd16, . - up_fetchadd16 + +/**************************************************************************** + * Name: up_fetchsub16 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be decremented. + * value - The 16-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub16 + .type up_fetchsub16, %function + +up_fetchsub16: + +1: + ldrexh r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + /* Attempt to save the decremented value */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub16, . - up_fetchsub16 + +/**************************************************************************** + * Name: up_fetchadd8 + * + * Description: + * Perform an atomic fetch add operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be incremented. + * value - The 8-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd8 + .type up_fetchadd8, %function + +up_fetchadd8: + +1: + ldrexb r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd8, . - up_fetchadd8 + +/**************************************************************************** + * Name: up_fetchsub8 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be decremented. + * value - The 8-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub8 + .type up_fetchsub8, %function + +up_fetchsub8: + +1: + ldrexb r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub8, . - up_fetchsub8 + .end diff --git a/arch/arm/src/armv7-m/gnu/up_fullcontextrestore.S b/arch/arm/src/armv7-m/gnu/up_fullcontextrestore.S index a9ccb0d572c0b9208e25fb3365382d0e1b4436fd..7b5171a449218b47c780853efb54058bfac941a2 100644 --- a/arch/arm/src/armv7-m/gnu/up_fullcontextrestore.S +++ b/arch/arm/src/armv7-m/gnu/up_fullcontextrestore.S @@ -71,7 +71,7 @@ * * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; * - * Return: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/armv7-m/gnu/up_saveusercontext.S b/arch/arm/src/armv7-m/gnu/up_saveusercontext.S index 7ebd2e4836a79d94b77c5cbfcd73e86fa444377f..a4d96ef8fa5fa1a3ff6813675b85af155ab877a0 100644 --- a/arch/arm/src/armv7-m/gnu/up_saveusercontext.S +++ b/arch/arm/src/armv7-m/gnu/up_saveusercontext.S @@ -71,7 +71,7 @@ * * int up_saveusercontext(uint32_t *saveregs); * - * Return: + * Returned Value: * 0: Normal return * 1: Context switch return * diff --git a/arch/arm/src/armv7-m/gnu/up_signal_handler.S b/arch/arm/src/armv7-m/gnu/up_signal_handler.S index 2cc31da4d19fe67be41c4caf0ce4a97d16e6b098..daf9448c14e2e3e79b67cbb9918702774c9a5269 100644 --- a/arch/arm/src/armv7-m/gnu/up_signal_handler.S +++ b/arch/arm/src/armv7-m/gnu/up_signal_handler.S @@ -71,13 +71,13 @@ * R4-R10 - static registers must be preserved * R12-R14 - LR and SP must be preserved * - * Inputs: + * Input Parameters: * R0 = sighand * The address user-space signal handling function * R1-R3 = signo, info, and ucontext * Standard arguments to be passed to the signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via the SYS_signal_handler_return (see svcall.h) * diff --git a/arch/arm/src/armv7-m/gnu/up_switchcontext.S b/arch/arm/src/armv7-m/gnu/up_switchcontext.S index c0ddf151627c485681cdbfc39ee167b908a02c51..7c72411d3e5a16d60f65e8ea3a64ff69f1060cb3 100644 --- a/arch/arm/src/armv7-m/gnu/up_switchcontext.S +++ b/arch/arm/src/armv7-m/gnu/up_switchcontext.S @@ -72,7 +72,7 @@ * * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); * - * Return: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/armv7-m/gnu/up_testset.S b/arch/arm/src/armv7-m/gnu/up_testset.S index c1888c56a98fcc5a64381b053c0e8903c585c65e..10929b0780da3c1b60a356eb929e632446f99b6a 100644 --- a/arch/arm/src/armv7-m/gnu/up_testset.S +++ b/arch/arm/src/armv7-m/gnu/up_testset.S @@ -74,7 +74,7 @@ * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/arm/src/armv7-m/gnu/vfork.S b/arch/arm/src/armv7-m/gnu/vfork.S index 784ab83ce7b065113b69dd7a3dd48c780ff2644b..fa3cfc1bea621d6116d863378b479c5b12218400 100644 --- a/arch/arm/src/armv7-m/gnu/vfork.S +++ b/arch/arm/src/armv7-m/gnu/vfork.S @@ -88,10 +88,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and returns * the process ID of the child process to the parent process. Otherwise, -1 is * returned to the parent, no child process is created, and errno is set to diff --git a/arch/arm/src/armv7-m/iar/up_fetchadd.S b/arch/arm/src/armv7-m/iar/up_fetchadd.S new file mode 100644 index 0000000000000000000000000000000000000000..f5db1837f642a69a2e17224b097b7ce2ce4f7fb0 --- /dev/null +++ b/arch/arm/src/armv7-m/iar/up_fetchadd.S @@ -0,0 +1,238 @@ +/**************************************************************************** + * arch/arm/src/armv7-m/iar/up_fetchadd.S + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + + MODULE up_testset + SECTION .text:CODE:NOROOT(2) + +/**************************************************************************** + * Public Symbols + ****************************************************************************/ + + PUBLIC up_fetchadd32 + PUBLIC up_fetchsub32 + PUBLIC up_fetchadd16 + PUBLIC up_fetchsub16 + PUBLIC up_fetchadd8 + PUBLIC up_fetchsub8 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + + THUMB + +/**************************************************************************** + * Name: up_fetchadd32 + * + * Description: + * Perform an atomic fetch add operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be incremented. + * value - The 32-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + +up_fetchadd32: + + ldrex r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne up_fetchadd32 /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + +/**************************************************************************** + * Name: up_fetchsub32 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be decremented. + * value - The 32-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + +up_fetchsub32: + + ldrex r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne up_fetchsub32 /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + +/**************************************************************************** + * Name: up_fetchadd16 + * + * Description: + * Perform an atomic fetch add operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be incremented. + * value - The 16-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + +up_fetchadd16: + + ldrexh r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne up_fetchadd16 /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + +/**************************************************************************** + * Name: up_fetchsub16 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be decremented. + * value - The 16-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + +up_fetchsub16: + + ldrexh r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + /* Attempt to save the decremented value */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne up_fetchsub16 /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + +/**************************************************************************** + * Name: up_fetchadd8 + * + * Description: + * Perform an atomic fetch add operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be incremented. + * value - The 8-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + +up_fetchadd8: + + ldrexb r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne up_fetchadd8 /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + +/**************************************************************************** + * Name: up_fetchsub8 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be decremented. + * value - The 8-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + +up_fetchsub8: + + ldrexb r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne up_fetchsub8 /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + + END diff --git a/arch/arm/src/armv7-m/iar/up_fullcontextrestore.S b/arch/arm/src/armv7-m/iar/up_fullcontextrestore.S index 045c903a32ade7ae13a05f8fd18031233a6186ac..034bbfc8e845f7f1ec32c4765290f3b8c10c78cb 100644 --- a/arch/arm/src/armv7-m/iar/up_fullcontextrestore.S +++ b/arch/arm/src/armv7-m/iar/up_fullcontextrestore.S @@ -72,7 +72,7 @@ * * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; * - * Return: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/armv7-m/iar/up_saveusercontext.S b/arch/arm/src/armv7-m/iar/up_saveusercontext.S index b8f27a7772cbac54ea11701e5337a2c2f3e439e3..07a82c620ae9323a066bc6b93b9a74a6c6213989 100644 --- a/arch/arm/src/armv7-m/iar/up_saveusercontext.S +++ b/arch/arm/src/armv7-m/iar/up_saveusercontext.S @@ -72,7 +72,7 @@ * * int up_saveusercontext(uint32_t *saveregs); * - * Return: + * Returned Value: * 0: Normal return * 1: Context switch return * diff --git a/arch/arm/src/armv7-m/iar/up_switchcontext.S b/arch/arm/src/armv7-m/iar/up_switchcontext.S index 5936503d73fe27c3ce9516f4fa2bd209de95c945..a115a498bf0e8ce6d9dd71b89e32138579119407 100644 --- a/arch/arm/src/armv7-m/iar/up_switchcontext.S +++ b/arch/arm/src/armv7-m/iar/up_switchcontext.S @@ -73,7 +73,7 @@ * * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); * - * Return: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/armv7-m/iar/up_testset.S b/arch/arm/src/armv7-m/iar/up_testset.S index e690aed3de9d7f6ae88d9374e67b6f71d04d32ae..72874dff3367b03ea415c1a09e8f570e58df7918 100644 --- a/arch/arm/src/armv7-m/iar/up_testset.S +++ b/arch/arm/src/armv7-m/iar/up_testset.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/gnu/up_testset.S + * arch/arm/src/armv7-m/iar/up_testset.S * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -59,7 +59,7 @@ * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/arm/src/armv7-m/iar/vfork.S b/arch/arm/src/armv7-m/iar/vfork.S index 6018a28a00a7bda8d1f6177d865f9a234cbd6fd9..e7352aee1ee18b857feb532416d4432de0c64493 100644 --- a/arch/arm/src/armv7-m/iar/vfork.S +++ b/arch/arm/src/armv7-m/iar/vfork.S @@ -89,10 +89,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and returns * the process ID of the child process to the parent process. Otherwise, -1 is * returned to the parent, no child process is created, and errno is set to diff --git a/arch/arm/src/armv7-m/up_blocktask.c b/arch/arm/src/armv7-m/up_blocktask.c index 5e62e0fb9fc3c4d9e021e4087560d84ad1efbed1..68151cb09b38cf6ce4330079c30f93511d43c2b8 100644 --- a/arch/arm/src/armv7-m/up_blocktask.c +++ b/arch/arm/src/armv7-m/up_blocktask.c @@ -61,7 +61,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/arm/src/armv7-m/up_reprioritizertr.c b/arch/arm/src/armv7-m/up_reprioritizertr.c index 5e65a3d33837b16d3928614b6fbd726d2009b34d..22c80ed298ebaeee8833fc179a233a042fb6f095 100644 --- a/arch/arm/src/armv7-m/up_reprioritizertr.c +++ b/arch/arm/src/armv7-m/up_reprioritizertr.c @@ -67,7 +67,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/arm/src/armv7-m/up_schedulesigaction.c b/arch/arm/src/armv7-m/up_schedulesigaction.c index 42aa2932ba64ce13f56a3ef67af8512a83780ba1..698b8a3c2c945c949d9e6f830c51fcc196e9545c 100644 --- a/arch/arm/src/armv7-m/up_schedulesigaction.c +++ b/arch/arm/src/armv7-m/up_schedulesigaction.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_schedulesigaction.c * - * Copyright (C) 2009-2014, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2014, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -118,7 +118,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is - * signalling itself for some reason. + * signaling itself for some reason. */ if (!CURRENT_REGS) @@ -176,9 +176,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) } } - /* Otherwise, we are (1) signalling a task is not running from an + /* Otherwise, we are (1) signaling a task is not running from an * interrupt handler or (2) we are not in an interrupt handler and the - * running task is signalling* some non-running task. + * running task is signaling* some non-running task. */ else @@ -250,7 +250,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) cpu = tcb->cpu; /* CASE 1: We are not in an interrupt handler and a task is - * signalling itself for some reason. + * signaling itself for some reason. */ if (cpu == me && !CURRENT_REGS) @@ -266,60 +266,45 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * CPU. In the former case, we will have to PAUSE the other CPU * first. But in either case, we will have to modify the return * state as well as the state in the TCB. - * - * Hmmm... there looks like a latent bug here: The following logic - * would fail in the strange case where we are in an interrupt - * handler, the thread is signalling itself, but a context switch - * to another task has occurred so that CURRENT_REGS does not - * refer to the thread of this_task()! */ else { - /* If we signalling a task running on the other CPU, we have + /* If we signaling a task running on the other CPU, we have * to PAUSE the other CPU. */ if (cpu != me) { + /* Pause the CPU */ + up_cpu_pause(cpu); - } - /* Save the return PC, CPSR and either the BASEPRI or PRIMASK - * registers (and perhaps also the LR). These will be - * restored by the signal trampoline after the signal has been - * delivered. - */ + /* Wait while the pause request is pending */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; - tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; + while (up_cpu_pausereq(cpu)) + { + } + + /* Now tcb on the other CPU can be accessed safely */ + + /* Copy tcb->xcp.regs to tcp.xcp.saved. These will be restored + * by the signal trampoline after the signal has been delivered. + */ + + tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; #ifdef CONFIG_ARMV7M_USEBASEPRI - tcb->xcp.saved_basepri = CURRENT_REGS[REG_BASEPRI]; + tcb->xcp.saved_basepri = tcb->xcp.regs[REG_BASEPRI]; #else - tcb->xcp.saved_primask = CURRENT_REGS[REG_PRIMASK]; + tcb->xcp.saved_primask = tcb->xcp.regs[REG_PRIMASK]; #endif - tcb->xcp.saved_xpsr = CURRENT_REGS[REG_XPSR]; + tcb->xcp.saved_xpsr = tcb->xcp.regs[REG_XPSR]; #ifdef CONFIG_BUILD_PROTECTED - tcb->xcp.saved_lr = CURRENT_REGS[REG_LR]; + tcb->xcp.saved_lr = tcb->xcp.regs[REG_LR]; #endif - /* Increment the IRQ lock count so that when the task is restarted, - * it will hold the IRQ spinlock. - */ - - DEBUGASSERT(tcb->irqcount < INT16_MAX); - tcb->irqcount++; - /* Handle a possible race condition where the TCB was suspended - * just before we paused the other CPU. The critical section - * established above will prevent new threads from running on - * that CPU, but it will not guarantee that the running thread - * did not suspend itself (allowing any threads "assigned" to - * the CPU to run). - */ - - if (tcb->task_state != TSTATE_TASK_RUNNING) - { - /* Then set up to vector to the trampoline with interrupts + /* Then set up vector to the trampoline with interrupts * disabled. We must already be in privileged thread mode * to be here. */ @@ -337,8 +322,29 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) } else { - /* Then set up to vector to the trampoline with interrupts - * disabled + /* tcb is running on the same CPU */ + + /* Save the return PC, CPSR and either the BASEPRI or PRIMASK + * registers (and perhaps also the LR). These will be + * restored by the signal trampoline after the signal has been + * delivered. + */ + + tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; +#ifdef CONFIG_ARMV7M_USEBASEPRI + tcb->xcp.saved_basepri = CURRENT_REGS[REG_BASEPRI]; +#else + tcb->xcp.saved_primask = CURRENT_REGS[REG_PRIMASK]; +#endif + tcb->xcp.saved_xpsr = CURRENT_REGS[REG_XPSR]; +#ifdef CONFIG_BUILD_PROTECTED + tcb->xcp.saved_lr = CURRENT_REGS[REG_LR]; +#endif + + /* Then set up vector to the trampoline with interrupts + * disabled. The kernel-space trampoline must run in + * privileged thread mode. */ CURRENT_REGS[REG_PC] = (uint32_t)up_sigdeliver; @@ -351,15 +357,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) #ifdef CONFIG_BUILD_PROTECTED CURRENT_REGS[REG_LR] = EXC_RETURN_PRIVTHR; #endif - /* In an SMP configuration, the interrupt disable logic also - * involves spinlocks that are configured per the TCB irqcount - * field. This is logically equivalent to enter_critical_section(). - * The matching call to leave_critical_section() will be - * performed in up_sigdeliver(). - */ - - spin_setbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, - &g_cpu_irqlock); /* And make sure that the saved context in the TCB is the same * as the interrupt return context. @@ -368,6 +365,24 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) up_savestate(tcb->xcp.regs); } + /* Increment the IRQ lock count so that when the task is restarted, + * it will hold the IRQ spinlock. + */ + + DEBUGASSERT(tcb->irqcount < INT16_MAX); + tcb->irqcount++; + + /* In an SMP configuration, the interrupt disable logic also + * involves spinlocks that are configured per the TCB irqcount + * field. This is logically equivalent to enter_critical_section(). + * The matching call to leave_critical_section() will be + * performed in up_sigdeliver(). + */ + + spin_setbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, + &g_cpu_irqlock); + + /* RESUME the other CPU if it was PAUSED */ if (cpu != me) @@ -379,7 +394,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Otherwise, we are (1) signaling a task is not running from an * interrupt handler or (2) we are not in an interrupt handler and the - * running task is signalling some other non-running task. + * running task is signaling some other non-running task. */ else diff --git a/arch/arm/src/armv7-m/up_signal_dispatch.c b/arch/arm/src/armv7-m/up_signal_dispatch.c index 9ec7d151529ca35f84e4dc939165e35f8882d9a5..63f2c56fc8215fc1f4989c3bb0eeaa69ed13f386 100644 --- a/arch/arm/src/armv7-m/up_signal_dispatch.c +++ b/arch/arm/src/armv7-m/up_signal_dispatch.c @@ -60,18 +60,18 @@ * This kernel-mode stub will then be called transfer control to the user * mode signal handler by calling this function. * - * Normally the a user-mode signalling handling stub will also execute + * Normally the a user-mode signaling handling stub will also execute * before the ultimate signal handler is called. See * arch/arm/src/armv[6\7]/up_signal_handler. This function is the * user-space, signal handler trampoline function. It is called from * up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * sighand - The address user-space signal handling function * signo, info, and ucontext - Standard arguments to be passed to the * signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via an architecture specific system call made by up_signal_handler(). * However, this will look like a normal return by the caller of diff --git a/arch/arm/src/armv7-m/up_unblocktask.c b/arch/arm/src/armv7-m/up_unblocktask.c index 3c9ae8df14780afc49037b67f6666882c72dcffc..7ecbbd0e577f5b2defbd8d2a9f4db8d50420a90f 100644 --- a/arch/arm/src/armv7-m/up_unblocktask.c +++ b/arch/arm/src/armv7-m/up_unblocktask.c @@ -60,7 +60,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/arm/src/armv7-r/arm_blocktask.c b/arch/arm/src/armv7-r/arm_blocktask.c index 58cefee3cfe8a4e88fcf9b61b05dddcdc1e0fc1d..c35093df074d85d5b30170d70a91830067208a65 100644 --- a/arch/arm/src/armv7-r/arm_blocktask.c +++ b/arch/arm/src/armv7-r/arm_blocktask.c @@ -62,7 +62,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/arm/src/armv7-r/arm_dataabort.c b/arch/arm/src/armv7-r/arm_dataabort.c index 52f5d124365dbe84f502b6f133721e76e174faa2..f5939f80e5fa68ec80d1fa0d6df91527295ab636 100644 --- a/arch/arm/src/armv7-r/arm_dataabort.c +++ b/arch/arm/src/armv7-r/arm_dataabort.c @@ -54,7 +54,7 @@ /**************************************************************************** * Name: arm_dataabort * - * Input parameters: + * Input Parameters: * regs - The standard, ARM register save array. * dfar - Fault address register. * dfsr - Fault status register. diff --git a/arch/arm/src/armv7-r/arm_fetchadd.S b/arch/arm/src/armv7-r/arm_fetchadd.S new file mode 100644 index 0000000000000000000000000000000000000000..77f661b98489def3fc00b135b174a8114fd7ba68 --- /dev/null +++ b/arch/arm/src/armv7-r/arm_fetchadd.S @@ -0,0 +1,255 @@ +/**************************************************************************** + * arch/arm/src/armv7-r/up_fetchadd.S + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + + .file "arm_fetchadd.S" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + + .text + +/**************************************************************************** + * Name: up_fetchadd32 + * + * Description: + * Perform an atomic fetch add operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be incremented. + * value - The 32-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd32 + .type up_fetchadd32, %function + +up_fetchadd32: + +1: + ldrex r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd32, . - up_fetchadd32 + +/**************************************************************************** + * Name: up_fetchsub32 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 32-bit value to be decremented. + * value - The 32-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub32 + .type up_fetchsub32, %function + +up_fetchsub32: + +1: + ldrex r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strex r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strex failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub32, . - up_fetchsub32 + +/**************************************************************************** + * Name: up_fetchadd16 + * + * Description: + * Perform an atomic fetch add operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be incremented. + * value - The 16-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd16 + .type up_fetchadd16, %function + +up_fetchadd16: + +1: + ldrexh r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd16, . - up_fetchadd16 + +/**************************************************************************** + * Name: up_fetchsub16 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 16-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 16-bit value to be decremented. + * value - The 16-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub16 + .type up_fetchsub16, %function + +up_fetchsub16: + +1: + ldrexh r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + /* Attempt to save the decremented value */ + + strexh r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexh failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub16, . - up_fetchsub16 + +/**************************************************************************** + * Name: up_fetchadd8 + * + * Description: + * Perform an atomic fetch add operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be incremented. + * value - The 8-bit addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchadd8 + .type up_fetchadd8, %function + +up_fetchadd8: + +1: + ldrexb r2, [r0] /* Fetch the value to be incremented */ + add r2, r2, r1 /* Add the addend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the incremented value */ + bx lr /* Successful! */ + .size up_fetchadd8, . - up_fetchadd8 + +/**************************************************************************** + * Name: up_fetchsub8 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 8-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of 8-bit value to be decremented. + * value - The 8-bit subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + + .globl up_fetchsub8 + .type up_fetchsub8, %function + +up_fetchsub8: + +1: + ldrexb r2, [r0] /* Fetch the value to be decremented */ + sub r2, r2, r1 /* Subtract the subtrahend */ + + strexb r3, r2, [r0] /* Attempt to save the result */ + teq r3, #0 /* r2 will be 1 is strexb failed */ + bne 1b /* Failed to lock... try again */ + + mov r0, r2 /* Return the decremented value */ + bx lr /* Successful! */ + .size up_fetchsub8, . - up_fetchsub8 + .end diff --git a/arch/arm/src/armv7-r/arm_fullcontextrestore.S b/arch/arm/src/armv7-r/arm_fullcontextrestore.S index 06daa2218262b5b223219b0f85450e505786911e..9de8e405b75dc918a91d4cca1087e4fcbbc23be5 100644 --- a/arch/arm/src/armv7-r/arm_fullcontextrestore.S +++ b/arch/arm/src/armv7-r/arm_fullcontextrestore.S @@ -75,7 +75,7 @@ * * void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/armv7-r/arm_prefetchabort.c b/arch/arm/src/armv7-r/arm_prefetchabort.c index 74713f5ad3eae3be527be24885bab7aaea3df460..7d5fd7cd86a1899a89abdd5527532931e4648093 100644 --- a/arch/arm/src/armv7-r/arm_prefetchabort.c +++ b/arch/arm/src/armv7-r/arm_prefetchabort.c @@ -54,7 +54,7 @@ /**************************************************************************** * Name: arm_prefetchabort * - * Description; + * Description: * This is the prefetch abort exception handler. The ARM prefetch abort * exception occurs when a memory fault is detected during an an * instruction fetch. diff --git a/arch/arm/src/armv7-r/arm_reprioritizertr.c b/arch/arm/src/armv7-r/arm_reprioritizertr.c index db96424eb2f4d6042c672334f327784d4fcecbee..85b8ee22c0ce42ff51f77ab2d4e765ff25923669 100644 --- a/arch/arm/src/armv7-r/arm_reprioritizertr.c +++ b/arch/arm/src/armv7-r/arm_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/arm/src/armv7-r/arm_signal_dispatch.c b/arch/arm/src/armv7-r/arm_signal_dispatch.c index 5fa1b3a647769ae46991415dd56ee175ac3576a3..c09c1481b6c0b445e30ae5494e9712ee0a8c684f 100644 --- a/arch/arm/src/armv7-r/arm_signal_dispatch.c +++ b/arch/arm/src/armv7-r/arm_signal_dispatch.c @@ -79,12 +79,12 @@ * user-space, signal handler trampoline function. It is called from * up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * sighand - The address user-space signal handling function * signo, info, and ucontext - Standard arguments to be passed to the * signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via an architecture specific system call made by up_signal_handler(). * However, this will look like a normal return by the caller of diff --git a/arch/arm/src/armv7-r/arm_signal_handler.S b/arch/arm/src/armv7-r/arm_signal_handler.S index 43f629a3ba9254f8e84ab949648e2bdb28ae7296..f2812a934fd06ebb8ac263470157d48b855683e3 100644 --- a/arch/arm/src/armv7-r/arm_signal_handler.S +++ b/arch/arm/src/armv7-r/arm_signal_handler.S @@ -76,13 +76,13 @@ * R4-R10 - static registers must be preserved * R12-R14 - LR and SP must be preserved * - * Inputs: + * Input Parameters: * R0 = sighand * The address user-space signal handling function * R1-R3 = signo, info, and ucontext * Standard arguments to be passed to the signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via the SYS_signal_handler_return (see svcall.h) * diff --git a/arch/arm/src/armv7-r/arm_testset.S b/arch/arm/src/armv7-r/arm_testset.S index f82837d5fe8f688779b5620a0ad03fa029631071..703f466b1989a459480f12fca50d2c5355590900 100644 --- a/arch/arm/src/armv7-r/arm_testset.S +++ b/arch/arm/src/armv7-r/arm_testset.S @@ -72,7 +72,7 @@ * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/arm/src/armv7-r/arm_unblocktask.c b/arch/arm/src/armv7-r/arm_unblocktask.c index 0361c1cc816f19903bb5c95e52796c25bca5c547..10188aac106458462165ee566dc9184cd2756f7f 100644 --- a/arch/arm/src/armv7-r/arm_unblocktask.c +++ b/arch/arm/src/armv7-r/arm_unblocktask.c @@ -73,7 +73,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/arm/src/armv7-r/arm_vfork.S b/arch/arm/src/armv7-r/arm_vfork.S index 635a5759c461a41c2688408c8f1d16c66b68c5ab..5b9a49588fe73264c396d61bf88ec76ad2ea491d 100644 --- a/arch/arm/src/armv7-r/arm_vfork.S +++ b/arch/arm/src/armv7-r/arm_vfork.S @@ -88,10 +88,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and * returns the process ID of the child process to the parent process. * Otherwise, -1 is returned to the parent, no child process is created, diff --git a/arch/arm/src/bcm2708/bcm_boot.c b/arch/arm/src/bcm2708/bcm_boot.c index a73dbf5e66787065f614b0f6d54dcd99eaf2fe80..7dbc32cb812179b1bbaaa6803f7a40b5000d3750 100644 --- a/arch/arm/src/bcm2708/bcm_boot.c +++ b/arch/arm/src/bcm2708/bcm_boot.c @@ -104,7 +104,7 @@ static inline void bcm_set_level1entry(uint32_t paddr, uint32_t vaddr, /**************************************************************************** * Name: bcm_setupmappings * - * Description + * Description: * Map all of the initial memory regions defined in g_section_mapping[] * ****************************************************************************/ diff --git a/arch/arm/src/bcm2708/bcm_miniuart.c b/arch/arm/src/bcm2708/bcm_miniuart.c index dc17851f61f86a965f7f594c6975804437cd98ce..a035bd12136f8f0e16ba34db9cfc2bc339fe6bab 100644 --- a/arch/arm/src/bcm2708/bcm_miniuart.c +++ b/arch/arm/src/bcm2708/bcm_miniuart.c @@ -640,7 +640,7 @@ static bool bcm_rxavailable(struct uart_dev_s *dev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index b98fd6ecac9eb28e3615c24b167d58b474ba5b43..b92f2f20948691b6d9dac2383bba00af3050273c 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -439,7 +439,7 @@ static void c5471_macassign(struct c5471_driver_s *priv); /**************************************************************************** * Name: c5471_dumpbuffer * - * Description + * Description: * Debug only * ****************************************************************************/ @@ -461,7 +461,7 @@ static inline void c5471_dumpbuffer(const char *msg, const uint8_t *buffer, /**************************************************************************** * Name: c5471_mdtxbit * - * Description + * Description: * A helper routine used when serially communicating with the c547X's * external ethernet transeiver device. GPIO pins are connected to the * transeiver's MDCLK and MDIO pins and are used to accomplish the serial @@ -528,7 +528,7 @@ static void c5471_mdtxbit (int bit_state) /**************************************************************************** * Name: c5471_mdrxbit * - * Description + * Description: * A helper routine used when serially communicating with the c547X's * external ethernet transeiver device. GPIO pins are connected to the * transeiver's MDCLK and MDIO pins and are used to accomplish the serial @@ -589,7 +589,7 @@ static int c5471_mdrxbit (void) /**************************************************************************** * Name: c5471_mdwrite * - * Description + * Description: * A helper routine used when serially communicating with the c547X's * external ethernet transeiver device. GPIO pins are connected to the * transeiver's MDCLK and MDIO pins and are used to accomplish the serial @@ -651,7 +651,7 @@ static void c5471_mdwrite (int adr, int reg, int data) /**************************************************************************** * Name: c5471_mdread * - * Description + * Description: * A helper routine used when serially communicating with the c547X's * external ethernet transeiver device. GPIO pins are connected to the * transeiver's MDCLK and MDIO pins and are used to accomplish the serial @@ -716,7 +716,7 @@ static int c5471_mdread (int adr, int reg) /**************************************************************************** * Name: c5471_phyinit * - * Description + * Description: * The c547X EVM board uses a Lucent LU3X31T-T64 transeiver device to * handle the physical layer (PHY). It's a h/w block that on the one end * offers a Media Independent Interface (MII) which is connected to the @@ -820,7 +820,7 @@ static int c5471_phyinit (void) /**************************************************************************** * Name: c5471_inctxcpu * - * Description + * Description: * ****************************************************************************/ @@ -843,7 +843,7 @@ static inline void c5471_inctxcpu(struct c5471_driver_s *priv) /**************************************************************************** * Name: c5471_incrxcpu * - * Description + * Description: * ****************************************************************************/ @@ -2073,7 +2073,7 @@ static int c5471_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac) /**************************************************************************** * Name: c5471_eimreset * - * Description + * Description: * The C547x docs states that a module should generally be reset according * to the following algorithm: * @@ -2121,7 +2121,7 @@ static void c5471_eimreset (struct c5471_driver_s *priv) /**************************************************************************** * Name: c5471_eimconfig * - * Description + * Description: * Assumes that all registers are currently in the power-up reset state. * This routine then modifies that state to provide our specific ethernet * configuration. @@ -2332,7 +2332,7 @@ static void c5471_eimconfig(struct c5471_driver_s *priv) /**************************************************************************** * Name: c5471_reset * - * Description + * Description: * ****************************************************************************/ @@ -2352,7 +2352,7 @@ static void c5471_reset(struct c5471_driver_s *priv) /**************************************************************************** * Name: c5471_macassign * - * Description + * Description: * Set the mac address of our CPU ether port so that when the SWITCH * receives packets from the PROMISCUOUS ENET0 it will switch them to the * CPU port and cause a packet arrival event on the Switch's CPU TX queue @@ -2447,7 +2447,7 @@ void up_netinitialize(void) #endif g_c5471[0].c_dev.d_private = (void *)g_c5471; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ g_c5471[0].c_txpoll = wd_create(); /* Create periodic poll timer */ g_c5471[0].c_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/common/up_checkstack.c b/arch/arm/src/common/up_checkstack.c index 03423fd426a28deb0cfd3674253a158dee409c65..fe75ed99cd32b4ececd61068b4abe616671afa31 100644 --- a/arch/arm/src/common/up_checkstack.c +++ b/arch/arm/src/common/up_checkstack.c @@ -72,7 +72,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack); * alloc - Allocation base address of the stack * size - The size of the stack in bytes * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ @@ -182,7 +182,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) * Input Parameters: * None * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ diff --git a/arch/arm/src/common/up_createstack.c b/arch/arm/src/common/up_createstack.c index 6643f94def72428f18b55ea1abd5805c581f9d5e..2f3bd3b4d4c1941c29ab7c67f4ea067998de7b8b 100644 --- a/arch/arm/src/common/up_createstack.c +++ b/arch/arm/src/common/up_createstack.c @@ -97,7 +97,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/arm/src/common/up_releasestack.c b/arch/arm/src/common/up_releasestack.c index 9be9740a5b5b6f91cbafc41fb596a2a6a7f0fc13..7090916dde2ca6782523f937e9e4182ab2be9089 100644 --- a/arch/arm/src/common/up_releasestack.c +++ b/arch/arm/src/common/up_releasestack.c @@ -69,7 +69,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/arm/src/common/up_stackframe.c b/arch/arm/src/common/up_stackframe.c index dace2e9239fa7f4071a5e4ca3491271d9e0d4261..c3a1f055eb449ad42bce0514515452a5c4bb5ec2 100644 --- a/arch/arm/src/common/up_stackframe.c +++ b/arch/arm/src/common/up_stackframe.c @@ -98,7 +98,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/arm/src/common/up_usestack.c b/arch/arm/src/common/up_usestack.c index 55c6a0526f5645787d7ed7d03665015814e1edec..7748fbd652eac64bc458cca79dd5a50652352096 100644 --- a/arch/arm/src/common/up_usestack.c +++ b/arch/arm/src/common/up_usestack.c @@ -89,7 +89,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/arm/src/common/up_vfork.c b/arch/arm/src/common/up_vfork.c index 5a69e310e3815d92adb927e505fa9d283d132c7b..ff43c9cc970fb2fd269512119edafe6b3fbb9c57 100644 --- a/arch/arm/src/common/up_vfork.c +++ b/arch/arm/src/common/up_vfork.c @@ -101,7 +101,7 @@ * Input Parameters: * context - Caller context information saved by vfork() * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and * returns the process ID of the child process to the parent process. * Otherwise, -1 is returned to the parent, no child process is created, diff --git a/arch/arm/src/dm320/dm320_framebuffer.c b/arch/arm/src/dm320/dm320_framebuffer.c index dcedcb62e5d277cd46d2280e1055017ef09db437..94b69e65d3b96b9e5420586c9b40719c6e1c8ab0 100644 --- a/arch/arm/src/dm320/dm320_framebuffer.c +++ b/arch/arm/src/dm320/dm320_framebuffer.c @@ -1367,7 +1367,7 @@ static int dm320_setcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_setcurs * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -1403,7 +1403,7 @@ int up_fbinitialize(int display) * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/arch/arm/src/efm32/Make.defs b/arch/arm/src/efm32/Make.defs index e02561c77bb5908b34ceef36521334f737d14501..9d24cd2c37b12585eedfb102e3c408dd6b43d09d 100644 --- a/arch/arm/src/efm32/Make.defs +++ b/arch/arm/src/efm32/Make.defs @@ -39,7 +39,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copyfullstate.c CMN_CSRCS += up_createstack.c up_doirq.c up_exit.c up_hardfault.c diff --git a/arch/arm/src/efm32/efm32_adc.c b/arch/arm/src/efm32/efm32_adc.c index e79c2a61ef53b568ffbc67e4557d9e62e2e87f06..abe463ca37562278d92a5ea20bb6cf2f9e113374 100644 --- a/arch/arm/src/efm32/efm32_adc.c +++ b/arch/arm/src/efm32/efm32_adc.c @@ -705,7 +705,7 @@ endif /* defined(ADC_COUNT) && (ADC_COUNT > 0) */ * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the ADC block status * * Returned Value: @@ -847,9 +847,9 @@ static void adc_hw_reset(struct efm32_dev_s *priv, bool reset) /**************************************************************************** * Name: adc_enable * - * Description : Enables or disables the specified ADC peripheral. - * Also, starts a conversion when the ADC is not - * triggered by timers + * Description: + * Enables or disables the specified ADC peripheral. Also, starts a + * conversion when the ADC is not triggered by timers * * Input Parameters: * diff --git a/arch/arm/src/efm32/efm32_bitband.c b/arch/arm/src/efm32/efm32_bitband.c index fa45b660b8348279fe4c020d3b42c1ff312a9e66..a4810705c35c3d76e2fbc04b1cdfb13dd4f80740 100644 --- a/arch/arm/src/efm32/efm32_bitband.c +++ b/arch/arm/src/efm32/efm32_bitband.c @@ -86,7 +86,7 @@ * Note * This function is only atomic on cores which fully support bitbanding. * - * Input Parmeters: + * Input Parameters: * addr Peripheral address location to modify bit in. * bit Bit position to modify, 0-31. * val Value to set bit to, 0 or 1. @@ -115,7 +115,7 @@ inline void bitband_set_peripheral(uint32_t addr, uint32_t bit, uint32_t val) * Note * This function is only atomic on cores which fully support bitbanding. * - * Input Parmeters: + * Input Parameters: * addr Peripheral address location to read. * bit Bit position to modify, 0-31. * @@ -145,7 +145,7 @@ inline uint32_t bitband_get_peripheral(uint32_t addr, uint32_t bit) * Note * This function is only atomic on cores which fully support bitbanding. * - * Input Parmeters: + * Input Parameters: * addr SRAM address location to modify bit in. * bit Bit position to modify, 0-31. * val Value to set bit to, 0 or 1. @@ -174,7 +174,7 @@ inline void bitband_set_sram(uint32_t addr, uint32_t bit, uint32_t val) * Note * This function is only atomic on cores which fully support bitbanding. * - * Input Parmeters: + * Input Parameters: * addr Peripheral address location to read. * bit Bit position to modify, 0-31. * diff --git a/arch/arm/src/efm32/efm32_dma.c b/arch/arm/src/efm32/efm32_dma.c index ef97e08d6c503fbe163b2ca2f41a881feb6e1547..f93497b4d30d3a4372e9e2146b6ad06e9cf8a0a2 100644 --- a/arch/arm/src/efm32/efm32_dma.c +++ b/arch/arm/src/efm32/efm32_dma.c @@ -319,7 +319,7 @@ void weak_function up_dmainitialize(void) * until the holder of a channel relinquishes the channel by calling * efm32_dmafree(). * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/arch/arm/src/efm32/efm32_dma.h b/arch/arm/src/efm32/efm32_dma.h index 813b30bf703d4cfb63b6e67a150001aefe0fea3d..19eec8b0e930cb1a578cecfe8eb0601b33ed0f30 100644 --- a/arch/arm/src/efm32/efm32_dma.h +++ b/arch/arm/src/efm32/efm32_dma.h @@ -173,7 +173,7 @@ extern "C" * If no DMA channel is available, then efm32_dmachannel() will wait until the * holder of a channel relinquishes the channel by calling efm32_dmafree(). * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/arch/arm/src/efm32/efm32_flash.c b/arch/arm/src/efm32/efm32_flash.c index 1353bbbdb12f2cccec47425947f324cf1eb913c2..d02f9d2fa53cc31052d685bf5b9237d6854b60eb 100644 --- a/arch/arm/src/efm32/efm32_flash.c +++ b/arch/arm/src/efm32/efm32_flash.c @@ -258,7 +258,7 @@ int __ramfunc__ msc_load_verify_address(uint32_t *address) } /**************************************************************************** - * Name:msc_load_data + * Name: msc_load_data * * Description: * Perform data phase of FLASH write cycle. diff --git a/arch/arm/src/efm32/efm32_i2c.h b/arch/arm/src/efm32/efm32_i2c.h index 16e51434bef338805e641197a898d2ca2cb2ac98..6218da8435e9ef943717b29c1286b9d5ecaf5a02 100644 --- a/arch/arm/src/efm32/efm32_i2c.h +++ b/arch/arm/src/efm32/efm32_i2c.h @@ -56,7 +56,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -72,7 +72,7 @@ FAR struct i2c_master_s *efm32_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the efm32_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/efm32/efm32_pm.h b/arch/arm/src/efm32/efm32_pm.h index 6846de31a394e61ba9f5c9c0aba60de1401acab2..413eda45c1d51037ad84c09e9ecbbd0482a68b04 100644 --- a/arch/arm/src/efm32/efm32_pm.h +++ b/arch/arm/src/efm32/efm32_pm.h @@ -110,7 +110,7 @@ int efm32_pmstop(bool lpds); * Input Parameters: * None * - * Returned Value. + * Returned Value: * On success, this function will not return (STANDBY mode can only be * terminated with a reset event). Otherwise, STANDBY mode did not occur * and a negated errno value is returned to indicate the cause of the diff --git a/arch/arm/src/efm32/efm32_pwm.c b/arch/arm/src/efm32/efm32_pwm.c index b9c7bd0271d7fc47ec791c2410c2daacc29d8dbd..ec0ac7955515b7aa13bb4a302005e64a02bf6322 100644 --- a/arch/arm/src/efm32/efm32_pwm.c +++ b/arch/arm/src/efm32/efm32_pwm.c @@ -284,7 +284,7 @@ static void pwm_putreg(struct efm32_pwmtimer_s *priv, int offset, uint32_t value * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -345,7 +345,7 @@ static void pwm_dumpregs(struct efm32_pwmtimer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -433,7 +433,7 @@ static int pwm_timer(FAR struct efm32_pwmtimer_s *priv, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * Standard interrupt handler arguments. * * Returned Value: @@ -529,7 +529,7 @@ static int pwm_interrupt(int irq, void *context, FAR void *arg) * Description: * Pick an optimal pulse count to program the RCR. * - * Input parameters: + * Input Parameters: * count - The total count remaining * * Returned Value: @@ -583,7 +583,7 @@ static uint8_t pwm_pulsecount(uint32_t count) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -643,7 +643,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -678,7 +678,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -717,7 +717,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -761,7 +761,7 @@ static int pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/efm32/efm32_rmu.c b/arch/arm/src/efm32/efm32_rmu.c index 57d7b0e02b76d82a03a67010b6d0da4a6f98163b..fbed325339ef3de000d4006c36395450920d1287 100644 --- a/arch/arm/src/efm32/efm32_rmu.c +++ b/arch/arm/src/efm32/efm32_rmu.c @@ -184,7 +184,7 @@ uint32_t g_efm32_rstcause; * Description: * Return next reset cause string, NULL if no more reset cause. * - * Input Parmeters: + * Input Parameters: * reg: reset cause register to decode (like g_efm32_rstcause) * idx: Use to keep in maind reset cause decoding position. * set *idx to zero before first call. diff --git a/arch/arm/src/efm32/efm32_rmu.h b/arch/arm/src/efm32/efm32_rmu.h index 1bcfec2d33f0952fbd1bc9753dcc1aec951dcda1..9a7a32dbdc810692822c0bcc48dd82a78b16a85b 100644 --- a/arch/arm/src/efm32/efm32_rmu.h +++ b/arch/arm/src/efm32/efm32_rmu.h @@ -90,7 +90,7 @@ const char* efm32_reset_cause_list_str(uint32_t reg, unsigned int *idx); * Description: * Return next reset cause string, NULL if no more reset cause. * - * Input Parmeters: + * Input Parameters: * reg: reset cause register to decode (like g_efm32_rstcause) * idx: Use to keep in maind reset cause decoding position. * set *idx to zero before first call. diff --git a/arch/arm/src/efm32/efm32_spi.c b/arch/arm/src/efm32/efm32_spi.c index f16d196e64a7521fdfaf7f0fc2db9260a0b5c171..7fe5139666d49fb80cf07616a41c5c3454f2b8e3 100644 --- a/arch/arm/src/efm32/efm32_spi.c +++ b/arch/arm/src/efm32/efm32_spi.c @@ -1493,7 +1493,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, ret = wd_start(priv->wdog, (int)ticks, spi_dma_timeout, 1, (uint32_t)priv); if (ret < 0) { - spierr("ERROR: Failed to start timeout\n"); + spierr("ERROR: Failed to start timeout: %d\n", ret); } /* Then wait for each to complete. TX should complete first */ @@ -1570,7 +1570,7 @@ static void spi_recvblock(struct spi_dev_s *dev, void *rxbuffer, * Initialize the selected SPI port in its default state (Master, 8-bit, * mode 0, etc.) * - * Input Parameter: + * Input Parameters: * priv - private SPI device structure * * Returned Value: @@ -1695,7 +1695,7 @@ errout: * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * port - SPI port number to initialize. One of {0,1,2} * * Returned Value: diff --git a/arch/arm/src/efm32/efm32_spi.h b/arch/arm/src/efm32/efm32_spi.h index 9e84fb68dc3f0686b4f36214ccefac2c898c5544..bcaff84e134a294386d8cbaf32f57a75c5dd4ff0 100644 --- a/arch/arm/src/efm32/efm32_spi.h +++ b/arch/arm/src/efm32/efm32_spi.h @@ -59,7 +59,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * port - SPI port number to initialize. One of {0,1,2} * * Returned Value: diff --git a/arch/arm/src/efm32/efm32_timer.c b/arch/arm/src/efm32/efm32_timer.c index 6264c3a378243369f4b713c9dae04b20982c787a..f8c1b1eaafea6ba2dae7936a396b1d573f094233 100644 --- a/arch/arm/src/efm32/efm32_timer.c +++ b/arch/arm/src/efm32/efm32_timer.c @@ -77,7 +77,7 @@ * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * base - A base address of timer * * Returned Value: @@ -132,7 +132,7 @@ void efm32_timer_dumpregs(uintptr_t base, FAR const char *msg) * Description: * reset timer into reset state * - * Input parameters: + * Input Parameters: * base - A base address of timer * * Returned Value: @@ -192,7 +192,7 @@ void efm32_timer_reset(uintptr_t base) * Description: * set prescaler and top timer with best value to have "freq" * - * Input parameters: + * Input Parameters: * base - A base address of timer * clk_freq - Clock soure of timer. * freq - Wanted freqency. diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c index cce11725fdd9454bf69acbb6d19339758a5a5406..8c1866a7977fc9fd1cea06c06f914d925722462f 100644 --- a/arch/arm/src/efm32/efm32_usbhost.c +++ b/arch/arm/src/efm32/efm32_usbhost.c @@ -1340,7 +1340,7 @@ static int efm32_ctrlchan_alloc(FAR struct efm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1402,7 +1402,7 @@ static int efm32_ctrlep_alloc(FAR struct efm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3791,7 +3791,7 @@ static void efm32_txfe_enable(FAR struct efm32_usbhost_s *priv, int chidx) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3882,7 +3882,7 @@ static int efm32_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4010,7 +4010,7 @@ static int efm32_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4069,7 +4069,7 @@ static int efm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4126,7 +4126,7 @@ static int efm32_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4194,7 +4194,7 @@ static int efm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4240,7 +4240,7 @@ static int efm32_alloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4276,7 +4276,7 @@ static int efm32_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4320,7 +4320,7 @@ static int efm32_ioalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4363,7 +4363,7 @@ static int efm32_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4566,7 +4566,7 @@ static int efm32_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4638,7 +4638,7 @@ static ssize_t efm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4694,7 +4694,7 @@ static int efm32_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4783,7 +4783,7 @@ static int efm32_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4834,7 +4834,7 @@ static int efm32_connect(FAR struct usbhost_driver_s *drvr, * drvr - The USB host driver instance obtained as a parameter from the call to * the class create() method. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/imx1/imx_cspi.h b/arch/arm/src/imx1/imx_cspi.h index f15872c49b142751513eb924aacf6120df7b0391..3d80a3d540b161ce041ce3d6adaf5de02fdb54b3 100644 --- a/arch/arm/src/imx1/imx_cspi.h +++ b/arch/arm/src/imx1/imx_cspi.h @@ -193,7 +193,7 @@ struct spi_dev_s; /* Forward reference */ * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/imx1/imx_spi.c b/arch/arm/src/imx1/imx_spi.c index 92208b78be3faf92b3144cab3a2d0f1bcd9b91d4..682805fdb7055a08cc4460e37f4f7d9ce84fdad0 100644 --- a/arch/arm/src/imx1/imx_spi.c +++ b/arch/arm/src/imx1/imx_spi.c @@ -1024,7 +1024,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/imx6/Make.defs b/arch/arm/src/imx6/Make.defs index c551c22d97b3d024a5c728914f4cfb99b4eba5b9..3950f54a98d5bfb2b963570a77d5e87a8d6c1ab8 100644 --- a/arch/arm/src/imx6/Make.defs +++ b/arch/arm/src/imx6/Make.defs @@ -58,7 +58,7 @@ endif CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S arm_vfork.S -CMN_ASRCS += arm_testset.S +CMN_ASRCS += arm_testset.S arm_fetchadd.S CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S diff --git a/arch/arm/src/imx6/imx_boot.c b/arch/arm/src/imx6/imx_boot.c index 6abc6f8b15753ea4479657b7a8a341b6d0ff7703..f48b3e70a286caf79e7fb407f2642c38097c6477 100644 --- a/arch/arm/src/imx6/imx_boot.c +++ b/arch/arm/src/imx6/imx_boot.c @@ -91,7 +91,7 @@ extern uint32_t _vector_end; /* End+1 of vector block */ /**************************************************************************** * Name: imx_setupmappings * - * Description + * Description: * Map all of the initial memory regions defined in g_section_mapping[] * ****************************************************************************/ @@ -115,7 +115,7 @@ static inline void imx_setupmappings(void) /**************************************************************************** * Name: imx_remap * - * Description + * Description: * Map all of the final memory regions defined in g_operational_mapping[] * ****************************************************************************/ diff --git a/arch/arm/src/imx6/imx_cpuboot.c b/arch/arm/src/imx6/imx_cpuboot.c index 818b327a4bc4c3cee317fbefdb7d7c8ee3891685..e747b701cfa19399adb5d842daf08253e331aff7 100644 --- a/arch/arm/src/imx6/imx_cpuboot.c +++ b/arch/arm/src/imx6/imx_cpuboot.c @@ -249,7 +249,7 @@ void imx_cpu_enable(void) * This function must be provided by the each ARMv7-A MCU and implement * MCU-specific initialization logic. * - * Input parameters: + * Input Parameters: * cpu - The CPU index. This is the same value that would be obtained by * calling up_cpu_index(); * diff --git a/arch/arm/src/imx6/imx_ecspi.c b/arch/arm/src/imx6/imx_ecspi.c index 42c8017fc0c0a9c83936230df9dfd0bf0e4eab00..0a20c514b9f47cab28a1f7eab8a83179e676d95d 100644 --- a/arch/arm/src/imx6/imx_ecspi.c +++ b/arch/arm/src/imx6/imx_ecspi.c @@ -1209,7 +1209,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/imx6/imx_ecspi.h b/arch/arm/src/imx6/imx_ecspi.h index ac30d2291f9428ff331c50e7a3860450ed13268b..4e3f8b977e12bca4619ab8acfab027bbe409e83f 100644 --- a/arch/arm/src/imx6/imx_ecspi.h +++ b/arch/arm/src/imx6/imx_ecspi.h @@ -85,7 +85,7 @@ struct spi_dev_s; /* Forward reference */ * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs index 4d9907907ed95856c97d4c3d67c240d9ee00a3bf..7e47c09e0357acf9b10338f2238df88cb7846c8c 100644 --- a/arch/arm/src/kinetis/Make.defs +++ b/arch/arm/src/kinetis/Make.defs @@ -43,7 +43,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_initialize.c up_memfault.c diff --git a/arch/arm/src/kinetis/kinetis.h b/arch/arm/src/kinetis/kinetis.h index a1558179fd07f1ac446e6cc583a58821cc4b18b1..ef91886626725884639345cf7637dafc3a9fad53 100644 --- a/arch/arm/src/kinetis/kinetis.h +++ b/arch/arm/src/kinetis/kinetis.h @@ -418,7 +418,7 @@ void kinetis_lowsetup(void); * Input Parameters: * first: - First TTY number to assign * - * Returns Value: + * Returned Value: * The next TTY number available for assignment * ****************************************************************************/ @@ -437,7 +437,7 @@ unsigned int kinetis_uart_serialinit(unsigned int first); * Input Parameters: * first: - First TTY number to assign * - * Returns Value: + * Returned Value: * The next TTY number available for assignment * ****************************************************************************/ @@ -587,7 +587,7 @@ void kinetis_pinirqinitialize(void); * pinisr - Pin interrupt service routine * arg - An argument that will be provided to the interrupt service routine. * - * Return Value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on any * failure to indicate the nature of the failure. * @@ -678,10 +678,10 @@ void kinetis_clrpend(int irq); * Description: * Initialize SDIO for operation. * - * Input parameters: + * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -705,7 +705,7 @@ FAR struct sdio_dev_s *sdhc_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -725,7 +725,7 @@ void sdhc_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 8f51cc6a7b8706e6c5baab83a331540f76a23f88..73d2f76892e5b60048b234bfdaccb6675ec859c9 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/kinetis/kinetis_enet.c * - * Copyright (C) 2011-2012, 2014-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2014-2018 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * David Sidrane * @@ -158,19 +158,21 @@ # define BOARD_PHYID1 MII_PHYID1_KSZ8041 # define BOARD_PHYID2 MII_PHYID2_KSZ8041 # define BOARD_PHY_STATUS MII_KSZ8041_PHYCTRL2 +# define BOARD_PHY_10BASET(s) (((s) & MII_PHYCTRL2_MODE_10HDX) != 0) +# define BOARD_PHY_100BASET(s) (((s) & MII_PHYCTRL2_MODE_100HDX) != 0) +# define BOARD_PHY_ISDUPLEX(s) (((s) & MII_PHYCTRL2_MODE_DUPLEX) != 0) #elif defined(CONFIG_ETH0_PHY_KSZ8081) # define BOARD_PHY_NAME "KSZ8081" # define BOARD_PHYID1 MII_PHYID1_KSZ8081 # define BOARD_PHYID2 MII_PHYID2_KSZ8081 -# define BOARD_PHY_STATUS MII_KSZ8081_PHYCTRL2 +# define BOARD_PHY_STATUS MII_KSZ8081_PHYCTRL1 +# define BOARD_PHY_10BASET(s) (((s) & MII_PHYCTRL1_MODE_10HDX) != 0) +# define BOARD_PHY_100BASET(s) (((s) & MII_PHYCTRL1_MODE_100HDX) != 0) +# define BOARD_PHY_ISDUPLEX(s) (((s) & MII_PHYCTRL1_MODE_DUPLEX) != 0) #else # error "Unrecognized or missing PHY selection" #endif -#define BOARD_PHY_10BASET(s) (((s) & (1 << MII_PHYCTRL2_MODE_SHIFT)) != 0) -#define BOARD_PHY_100BASET(s) (((s) & (2 << MII_PHYCTRL2_MODE_SHIFT)) != 0) -#define BOARD_PHY_ISDUPLEX(s) (((s) & (4 << MII_PHYCTRL2_MODE_SHIFT)) != 0) - /* Estimate the MII_SPEED in order to get an MDC close to 2.5MHz, based on the internal module (ENET) clock: * @@ -310,7 +312,7 @@ static int kinetis_addmac(struct net_driver_s *dev, static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int kinetis_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -1449,48 +1451,52 @@ static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int kinetis_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { - int ret; +#ifdef CONFIG_NETDEV_PHY_IOCTL FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)dev->d_private; +#endif + int ret; switch (cmd) - { - case SIOCGMIIPHY: /* Get MII PHY address */ { - struct mii_ioctl_data_s *req = - (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; +#ifdef CONFIG_NETDEV_PHY_IOCTL + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = + (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = - (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = kinetis_readmii(priv, req->phy_id, req->reg_num, &req->val_out); - } - break; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = + (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = kinetis_readmii(priv, req->phy_id, req->reg_num, &req->val_out); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = - (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = kinetis_writemii(priv, req->phy_id, req->reg_num, req->val_in); - } - break; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = + (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = kinetis_writemii(priv, req->phy_id, req->reg_num, req->val_in); + } + break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: kinetis_initmii @@ -2127,12 +2133,12 @@ int kinetis_netinitialize(int intf) priv->dev.d_addmac = kinetis_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = kinetis_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = kinetis_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_enet; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/kinetis/kinetis_i2c.c b/arch/arm/src/kinetis/kinetis_i2c.c index 3e409986501b5eb00577643d691c12f4169db1c9..1a7af792a83d41129fcf3b76c31c527066d4882b 100644 --- a/arch/arm/src/kinetis/kinetis_i2c.c +++ b/arch/arm/src/kinetis/kinetis_i2c.c @@ -1183,8 +1183,8 @@ static int kinetis_i2c_transfer(struct i2c_master_s *dev, /* Wait for transfer complete */ - wd_start(priv->timeout, I2C_TIMEOUT, kinetis_i2c_timeout, 1, - (uint32_t) priv); + (void)wd_start(priv->timeout, I2C_TIMEOUT, kinetis_i2c_timeout, 1, + (uint32_t)priv); kinetis_i2c_wait(priv); wd_cancel(priv->timeout); diff --git a/arch/arm/src/kinetis/kinetis_i2c.h b/arch/arm/src/kinetis/kinetis_i2c.h index 098e4d39add5981788688eff46db049908210a33..8cb4246a17faba5745ccb6708da4c0fec774a217 100644 --- a/arch/arm/src/kinetis/kinetis_i2c.h +++ b/arch/arm/src/kinetis/kinetis_i2c.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *kinetis_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc43_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/kinetis/kinetis_lpserial.c b/arch/arm/src/kinetis/kinetis_lpserial.c index 262bda4a8a4e907e989b5cfaf16a5cf4aae74655..3de8f6e3a6ca63e5facd752602438aa61a7496ad 100644 --- a/arch/arm/src/kinetis/kinetis_lpserial.c +++ b/arch/arm/src/kinetis/kinetis_lpserial.c @@ -965,7 +965,7 @@ static bool kinetis_rxavailable(struct uart_dev_s *dev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is @@ -1145,7 +1145,7 @@ void kinetis_lpuart_earlyserialinit(void) * Input Parameters: * first: - First TTY number to assign * - * Returns Value: + * Returned Value: * The next TTY number available for assignment * ****************************************************************************/ diff --git a/arch/arm/src/kinetis/kinetis_pin.c b/arch/arm/src/kinetis/kinetis_pin.c index 8a2e3294321a6ce237c2dd19be73404fa4751d50..4a084f6c27527bd7a33ac5a7501bd0893fca4e5c 100644 --- a/arch/arm/src/kinetis/kinetis_pin.c +++ b/arch/arm/src/kinetis/kinetis_pin.c @@ -214,7 +214,7 @@ int kinetis_pinconfig(uint32_t cfgset) * Configure the digital filter associated with a port. The digital filter * capabilities of the PORT module are available in all digital pin muxing modes. * - * Input parmeters: + * Input Parameters: * port - Port number. See KINETIS_PORTn definitions in kinetis_port.h * lpo - true: Digital Filters are clocked by the bus clock * false: Digital Filters are clocked by the 1 kHz LPO clock diff --git a/arch/arm/src/kinetis/kinetis_pinirq.c b/arch/arm/src/kinetis/kinetis_pinirq.c index f40be80a8e44cadd302da347df4a194cf10e9588..0a015b6ad49d37006ae78dde156392463d2535ee 100644 --- a/arch/arm/src/kinetis/kinetis_pinirq.c +++ b/arch/arm/src/kinetis/kinetis_pinirq.c @@ -267,7 +267,7 @@ void kinetis_pinirqinitialize(void) * pinisr - Pin interrupt service routine * arg - An argument that will be provided to the interrupt service routine. * - * Returns: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on any * failure to indicate the nature of the failure. * diff --git a/arch/arm/src/kinetis/kinetis_pwm.c b/arch/arm/src/kinetis/kinetis_pwm.c index 83f6c76699bea27e692439aa3d842e97df1e00be..b4dd646c9a641c489db61163b0e5eb16a9a6dfbf 100644 --- a/arch/arm/src/kinetis/kinetis_pwm.c +++ b/arch/arm/src/kinetis/kinetis_pwm.c @@ -248,7 +248,7 @@ static void pwm_putreg(struct kinetis_pwmtimer_s *priv, int offset, uint32_t val * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -347,7 +347,7 @@ static void pwm_dumpregs(struct kinetis_pwmtimer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -541,7 +541,7 @@ static int pwm_timer(FAR struct kinetis_pwmtimer_s *priv, * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -589,7 +589,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -622,7 +622,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -644,7 +644,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -728,7 +728,7 @@ static int pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c index 1a3a0b53b7f443b80b9a9549b625eb598b512b80..816a4ee18b38c5d4438d53b0d3daaee9755c4f13 100644 --- a/arch/arm/src/kinetis/kinetis_sdhc.c +++ b/arch/arm/src/kinetis/kinetis_sdhc.c @@ -2465,7 +2465,7 @@ static sdio_eventset_t kinetis_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)kinetis_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2795,7 +2795,7 @@ static void kinetis_callback(void *arg) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -2909,7 +2909,7 @@ FAR struct sdio_dev_s *sdhc_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -2956,7 +2956,7 @@ void sdhc_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/kinetis/kinetis_serial.c b/arch/arm/src/kinetis/kinetis_serial.c index 0f2a4b2ee46dbdaf05771af1585bf09f8453cc74..23d327ec09acb593403162ba189cc13103a6aaf2 100644 --- a/arch/arm/src/kinetis/kinetis_serial.c +++ b/arch/arm/src/kinetis/kinetis_serial.c @@ -1334,7 +1334,7 @@ static bool up_rxavailable(struct uart_dev_s *dev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is @@ -1561,7 +1561,7 @@ void kinetis_uart_earlyserialinit(void) * Input Parameters: * first: - First TTY number to assign * - * Returns Value: + * Returned Value: * The next TTY number available for assignment * ****************************************************************************/ diff --git a/arch/arm/src/kinetis/kinetis_spi.c b/arch/arm/src/kinetis/kinetis_spi.c index 3fc63b901e4e84328cf3d12e2320ad5f72a9e5fd..ce3971518e8a20878d36d86b26af4691dbb04dc5 100644 --- a/arch/arm/src/kinetis/kinetis_spi.c +++ b/arch/arm/src/kinetis/kinetis_spi.c @@ -1109,7 +1109,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/kinetis/kinetis_spi.h b/arch/arm/src/kinetis/kinetis_spi.h index 8222af442467f44bbd8e7e5dfcf519f26ba4a70a..4d3ce60ce241526809b1f7ff54a1c43b49969719 100644 --- a/arch/arm/src/kinetis/kinetis_spi.h +++ b/arch/arm/src/kinetis/kinetis_spi.h @@ -75,7 +75,7 @@ struct spi_dev_s; * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * bus number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/kinetis/kinetis_usbdev.c b/arch/arm/src/kinetis/kinetis_usbdev.c index 4d10d422fd7021a268e9014fe32733648fb34b8a..9fd71b3e78432b7cede413f718439c804b7d85a2 100644 --- a/arch/arm/src/kinetis/kinetis_usbdev.c +++ b/arch/arm/src/kinetis/kinetis_usbdev.c @@ -1112,7 +1112,8 @@ static void khci_delayedrestart(struct khci_usbdev_s *priv, uint8_t epno) /* And start (or re-start) the watchdog timer */ - wd_start(priv->wdog, RESTART_DELAY, khci_rqrestart, 1, (uint32_t)priv); + (void)wd_start(priv->wdog, RESTART_DELAY, khci_rqrestart, 1, + (uint32_t)priv); } /**************************************************************************** diff --git a/arch/arm/src/kl/kl_gpio.h b/arch/arm/src/kl/kl_gpio.h index 4a81acd27e46ce2c5f8f00d050c307fa7e96140c..78f7fdc122273c883fb4cc6452e6aebb3daf51e4 100644 --- a/arch/arm/src/kl/kl_gpio.h +++ b/arch/arm/src/kl/kl_gpio.h @@ -370,7 +370,7 @@ bool kl_gpioread(uint32_t pinset); * - pinisr: Pin interrupt service routine * - pinarg: The argument that will accompany the pin interrupt * - * Returns: + * Returned Value: * Zero (OK) is returned on success; On any failure, a negated errno value is * returned to indicate the nature of the failure. * diff --git a/arch/arm/src/kl/kl_gpioirq.c b/arch/arm/src/kl/kl_gpioirq.c index 38f30c0870f1e9f29895ef9744e6e1b1460a75d3..a42be056ab7edd1c3d83532a63519f9526b51a20 100644 --- a/arch/arm/src/kl/kl_gpioirq.c +++ b/arch/arm/src/kl/kl_gpioirq.c @@ -230,8 +230,8 @@ void kl_gpioirqinitialize(void) * - pinisr: Pin interrupt service routine * - pinarg: The argument that will accompany the pin interrupt * - * Returns: - * Returns: + * Returned Value: + * Returned Value: * Zero (OK) is returned on success; On any failure, a negated errno value is * returned to indicate the nature of the failure. * diff --git a/arch/arm/src/kl/kl_pwm.c b/arch/arm/src/kl/kl_pwm.c index a34aa0f8175b08e9130051208edd70ce36301a19..cfa024b4779b246948dbe53beb7c0312bf902c89 100644 --- a/arch/arm/src/kl/kl_pwm.c +++ b/arch/arm/src/kl/kl_pwm.c @@ -226,7 +226,7 @@ static void pwm_putreg(struct kl_pwmtimer_s *priv, int offset, uint32_t value) * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -307,7 +307,7 @@ static void pwm_dumpregs(struct kl_pwmtimer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -488,7 +488,7 @@ static int pwm_timer(FAR struct kl_pwmtimer_s *priv, * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -529,7 +529,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -562,7 +562,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -584,7 +584,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -660,7 +660,7 @@ static int pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/kl/kl_spi.c b/arch/arm/src/kl/kl_spi.c index 81cda9c9da5e159a2c2ee53d0a83c10b27609f00..187ae75e9e1b9ef168ad78c613b1517c4866dd1e 100644 --- a/arch/arm/src/kl/kl_spi.c +++ b/arch/arm/src/kl/kl_spi.c @@ -612,7 +612,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/kl/kl_spi.h b/arch/arm/src/kl/kl_spi.h index fd621858a61eee7808139f5bd4d2055f29f5921e..968cf6abeff7779ad4bfbe0c56eeb64195cc22ba 100644 --- a/arch/arm/src/kl/kl_spi.h +++ b/arch/arm/src/kl/kl_spi.h @@ -71,7 +71,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lc823450/lc823450_cpuidlestack.c b/arch/arm/src/lc823450/lc823450_cpuidlestack.c index e9418abfcc87c142d22a26029967cfbfb1baf1f5..3c7a6e58fdbb99b2f676e543695e1f185b6befaf 100644 --- a/arch/arm/src/lc823450/lc823450_cpuidlestack.c +++ b/arch/arm/src/lc823450/lc823450_cpuidlestack.c @@ -82,7 +82,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - cpu: CPU index that indicates which CPU the IDLE task is * being created for. * - tcb: The TCB of new CPU IDLE task diff --git a/arch/arm/src/lc823450/lc823450_i2s.c b/arch/arm/src/lc823450/lc823450_i2s.c index 3eced5cb4f246d282cf4b122b2ac7adf91330c6e..2b993d6a1c988ecea256f04f99a1e1559a5e604b 100644 --- a/arch/arm/src/lc823450/lc823450_i2s.c +++ b/arch/arm/src/lc823450/lc823450_i2s.c @@ -45,12 +45,17 @@ #include #include +#include #include #include #include #include #include +#ifdef CONFIG_SMP +# include +#endif + #include "up_arch.h" #include "lc823450_dma.h" #include "lc823450_i2s.h" @@ -460,8 +465,32 @@ FAR struct i2s_dev_s *lc823450_i2sdev_initialize(void) nxsem_init(&_sem_txdma, 0, 0); nxsem_init(&_sem_buf_under, 0, 0); +#ifdef CONFIG_SMP + cpu_set_t cpuset0; + cpu_set_t cpuset1; + + CPU_ZERO(&cpuset1); + CPU_SET(0, &cpuset1); + + /* Backup the current affinity */ + + (void)nxsched_getaffinity(getpid(), sizeof(cpuset0), &cpuset0); + + /* Set the new affinity which assigns to CPU0 */ + + (void)nxsched_setaffinity(getpid(), sizeof(cpuset1), &cpuset1); + nxsig_usleep(10 * 1000); +#endif + irq_attach(LC823450_IRQ_AUDIOBUF0, _i2s_isr, NULL); +#ifdef CONFIG_SMP + /* Restore the original affinity */ + + (void)nxsched_setaffinity(getpid(), sizeof(cpuset0), &cpuset0); + nxsig_usleep(10 * 1000); +#endif + /* Enable IRQ for Audio Buffer */ up_enable_irq(LC823450_IRQ_AUDIOBUF0); diff --git a/arch/arm/src/lc823450/lc823450_irq.c b/arch/arm/src/lc823450/lc823450_irq.c index 9339f7cd632a291821f2668b6d3b1ab27d707cbc..bd159ef545e6c25a551e76e8ffd388c81530d88d 100644 --- a/arch/arm/src/lc823450/lc823450_irq.c +++ b/arch/arm/src/lc823450/lc823450_irq.c @@ -711,7 +711,9 @@ void up_ack_irq(int irq) #ifdef CONFIG_SMP if (irq > LC823450_IRQ_LPDSP0 && 1 == up_cpu_index()) { - irqwarn("*** warning irq(%d) handled on CPU1."); + /* IRQ should be handled on CPU0 */ + + ASSERT(false); } #endif diff --git a/arch/arm/src/lc823450/lc823450_sdc.c b/arch/arm/src/lc823450/lc823450_sdc.c index b0f0a357e2e299ce1cff0d3d63df6584e1c7438f..e47ab04dcb6258ec69d5ba4139d1ae15dfa33c98 100644 --- a/arch/arm/src/lc823450/lc823450_sdc.c +++ b/arch/arm/src/lc823450/lc823450_sdc.c @@ -355,7 +355,9 @@ int lc823450_sdc_setclock(uint32_t ch, uint32_t limitclk, uint32_t sysclk) /**************************************************************************** * Name: lc823450_sdc_refmediatype * - * Return Values: 0(sd), 1(emmc) + * Returned Value: + * 0(sd), 1(emmc) + * ****************************************************************************/ int lc823450_sdc_refmediatype(uint32_t ch) diff --git a/arch/arm/src/lc823450/lc823450_spi.c b/arch/arm/src/lc823450/lc823450_spi.c index 038351d79a8c781eee8ed63d94c0bc9f0c33113f..51451b6001db2b9691c4e2a4a5987227159ef717 100644 --- a/arch/arm/src/lc823450/lc823450_spi.c +++ b/arch/arm/src/lc823450/lc823450_spi.c @@ -512,7 +512,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lc823450/lc823450_syscontrol.c b/arch/arm/src/lc823450/lc823450_syscontrol.c index 82e6c2ee01885489de549b52033781fe0b4087d2..cd5458729b4cc581f358112d322bcf11c4238a21 100644 --- a/arch/arm/src/lc823450/lc823450_syscontrol.c +++ b/arch/arm/src/lc823450/lc823450_syscontrol.c @@ -102,7 +102,7 @@ uint32_t get_cpu_ver(void) /**************************************************************************** * Name: mod_stby_regs * - * Input parameters: + * Input Parameters: * enabits : specify regions to be enabled * disbits : specify regions to be disabled * diff --git a/arch/arm/src/lc823450/lc823450_wdt.c b/arch/arm/src/lc823450/lc823450_wdt.c index 80f7b49c2153e034f5cc5d49ad76e60e2e01c9a2..cdd351c095ca5c2c7b56703418e0c891bf8313be 100644 --- a/arch/arm/src/lc823450/lc823450_wdt.c +++ b/arch/arm/src/lc823450/lc823450_wdt.c @@ -182,7 +182,7 @@ static void wdg_work_func(void *arg) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -223,7 +223,7 @@ static int lc823450_wdt_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -246,7 +246,7 @@ static int lc823450_wdt_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -271,7 +271,7 @@ static int lc823450_wdt_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -299,7 +299,7 @@ static int lc823450_wdt_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * stawtus - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -362,7 +362,7 @@ static int lc823450_wdt_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in millisecnds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -430,7 +430,7 @@ static int lc823450_wdt_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -496,7 +496,7 @@ static xcpt_t lc823450_wdt_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -526,7 +526,7 @@ static int lc823450_wdt_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * Input Parameters: * None * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.c b/arch/arm/src/lpc11xx/lpc11_i2c.c index 1c94939da92933f9d35f98c0ef6e26059b17c0a5..5873a18ff3a556ae502377da6382a61015891bc1 100644 --- a/arch/arm/src/lpc11xx/lpc11_i2c.c +++ b/arch/arm/src/lpc11xx/lpc11_i2c.c @@ -215,7 +215,8 @@ static int lpc11_i2c_start(struct lpc11_i2cdev_s *priv) priv->base + LPC11_I2C_CONCLR_OFFSET); putreg32(I2C_CONSET_STA, priv->base + LPC11_I2C_CONSET_OFFSET); - wd_start(priv->timeout, I2C_TIMEOUT, lpc11_i2c_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, I2C_TIMEOUT, lpc11_i2c_timeout, 1, + (uint32_t)priv); nxsem_wait(&priv->wait); wd_cancel(priv->timeout); diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.h b/arch/arm/src/lpc11xx/lpc11_i2c.h index a9bc6fa3f75fd87660a3fb5d34fd84042a157ae4..cd739be1a3a4c76837a8b3eaf71b498d9a0797ae 100644 --- a/arch/arm/src/lpc11xx/lpc11_i2c.h +++ b/arch/arm/src/lpc11xx/lpc11_i2c.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *lpc11_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc11_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/lpc11xx/lpc11_serial.c b/arch/arm/src/lpc11xx/lpc11_serial.c index 941a4475b4b148195b15b37bab2fcea93e153313..4799e4ed514f03d524f7f2977b0213ebee0a75bf 100644 --- a/arch/arm/src/lpc11xx/lpc11_serial.c +++ b/arch/arm/src/lpc11xx/lpc11_serial.c @@ -362,7 +362,7 @@ static inline void lpc11_uart0config(void) /************************************************************************************ * Name: lpc11_uartdl * - * Descrption: + * Description: * Select a divider to produce the BAUD from the UART PCLK. * * BAUD = PCLK / (16 * DL), or diff --git a/arch/arm/src/lpc11xx/lpc11_spi.c b/arch/arm/src/lpc11xx/lpc11_spi.c index 363cd6466adde7add1322a675226347c623546ea..e1bb8e0d6cad1d8dab1e697c9619aa59635bcbd9 100644 --- a/arch/arm/src/lpc11xx/lpc11_spi.c +++ b/arch/arm/src/lpc11xx/lpc11_spi.c @@ -526,7 +526,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc11xx/lpc11_spi.h b/arch/arm/src/lpc11xx/lpc11_spi.h index 1a6786d2180e012ee2f0fcf6657d8e8e4a0f76d0..30ee2bbecff8673b7e1121910ec9705b6e93e8d7 100644 --- a/arch/arm/src/lpc11xx/lpc11_spi.h +++ b/arch/arm/src/lpc11xx/lpc11_spi.h @@ -76,7 +76,7 @@ extern "C" * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc11xx/lpc11_ssp.c b/arch/arm/src/lpc11xx/lpc11_ssp.c index 32cccc29f36ff0440a3b5ad16800b5930a03dcc1..c0c1498f7e6cb59ab0a871910f5827c708919245 100644 --- a/arch/arm/src/lpc11xx/lpc11_ssp.c +++ b/arch/arm/src/lpc11xx/lpc11_ssp.c @@ -776,7 +776,7 @@ static void ssp_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * Description: * Initialize the SSP0 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -830,7 +830,7 @@ static inline FAR struct lpc11_sspdev_s *lpc11_ssp0initialize(void) * Description: * Initialize the SSP1 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -884,7 +884,7 @@ static inline FAR struct lpc11_sspdev_s *lpc11_ssp1initialize(void) * Description: * Initialize the SSP2 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -941,7 +941,7 @@ static inline FAR struct lpc11_sspdev_s *lpc11_ssp2initialize(void) * Description: * Initialize the selected SSP port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc11xx/lpc11_ssp.h b/arch/arm/src/lpc11xx/lpc11_ssp.h index f117b1cf034d6b23a5545888779fec7280ccee26..825c67faa3afffbd430f71363baf7d010e454a9f 100644 --- a/arch/arm/src/lpc11xx/lpc11_ssp.h +++ b/arch/arm/src/lpc11xx/lpc11_ssp.h @@ -76,7 +76,7 @@ extern "C" * Description: * Initialize the selected SSP port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc11xx/lpc11_timer.c b/arch/arm/src/lpc11xx/lpc11_timer.c index a9ce65a073a57645e8953559dbad8e060657a096..75d3d334a43234a244a15297f44ff2132d1a2d8e 100644 --- a/arch/arm/src/lpc11xx/lpc11_timer.c +++ b/arch/arm/src/lpc11xx/lpc11_timer.c @@ -214,7 +214,7 @@ static void timer_putreg(struct lpc11_timer_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -256,7 +256,7 @@ static void timer_dumpregs(struct lpc11_timer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -291,7 +291,7 @@ static int timer_timer(FAR struct lpc11_timer_s *priv, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * * Returned Value: @@ -325,7 +325,7 @@ static int timer_interrupt(struct lpc11_timer_s *priv) * Description: * Handle timer 1 and 8 interrupts. * - * Input parameters: + * Input Parameters: * Standard NuttX interrupt inputs * * Returned Value: @@ -348,7 +348,7 @@ static int timer_tim1interrupt(int irq, void *context) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -436,7 +436,7 @@ static int timer_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * * Returned Value: @@ -462,7 +462,7 @@ static int timer_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * info - A reference to the characteristics of the pulsed output * @@ -484,7 +484,7 @@ static int timer_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * * Returned Value: @@ -542,7 +542,7 @@ static int timer_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/lpc17xx/Make.defs b/arch/arm/src/lpc17xx/Make.defs index 115a3222a2b19fba204dac39bef454b796b03e02..c164c95f13f6ff291f370d1b2a163bc29c892d96 100644 --- a/arch/arm/src/lpc17xx/Make.defs +++ b/arch/arm/src/lpc17xx/Make.defs @@ -47,7 +47,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_initialize.c up_memfault.c diff --git a/arch/arm/src/lpc17xx/chip/lpc17_uart.h b/arch/arm/src/lpc17xx/chip/lpc17_uart.h index d7706561cd8a31abf94b07c317582f00d1255041..478c18b70a21cbbd06e0377b7d46bcbf5c62de9c 100644 --- a/arch/arm/src/lpc17xx/chip/lpc17_uart.h +++ b/arch/arm/src/lpc17xx/chip/lpc17_uart.h @@ -342,7 +342,7 @@ #define UART_FDR_DIVADDVAL_SHIFT (0) /* Bits 0-3: Baud-rate generation pre-scaler divisor value */ #define UART_FDR_DIVADDVAL_MASK (15 << UART_FDR_DIVADDVAL_SHIFT) -#define UART_FDR_MULVAL_SHIFT (3) /* Bits 4-7 Baud-rate pre-scaler multiplier value */ +#define UART_FDR_MULVAL_SHIFT (4) /* Bits 4-7 Baud-rate pre-scaler multiplier value */ #define UART_FDR_MULVAL_MASK (15 << UART_FDR_MULVAL_SHIFT) /* Bits 8-31: Reserved */ /* TER Transmit Enable Register (all) */ diff --git a/arch/arm/src/lpc17xx/lpc17_can.c b/arch/arm/src/lpc17xx/lpc17_can.c index 94f1987280c41aeadc4ee8ad8c7994231d2be2e5..d7e8fcc461be15152fe07b1593e0457a9529abf0 100644 --- a/arch/arm/src/lpc17xx/lpc17_can.c +++ b/arch/arm/src/lpc17xx/lpc17_can.c @@ -1109,7 +1109,7 @@ static int can12_interrupt(int irq, void *context, FAR void *arg) * Where: * Tcan is the period of the APB clock (PCLK = CCLK / CONFIG_CAN1_DIVISOR). * - * Input Parameter: + * Input Parameters: * priv - A reference to the CAN block status * * Returned Value: @@ -1210,7 +1210,7 @@ static int can_bittiming(struct up_dev_s *priv) * Description: * Initialize the selected can port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple can interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_can.h b/arch/arm/src/lpc17xx/lpc17_can.h index e15eaced5a5aa02cb8d9bf787523c9f2480be6d7..2cbb8014a9f8e1c9f3803018e39e40f2a2d09c00 100644 --- a/arch/arm/src/lpc17xx/lpc17_can.h +++ b/arch/arm/src/lpc17xx/lpc17_can.h @@ -71,7 +71,7 @@ extern "C" * Description: * Initialize the selected can port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple can interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c index dd1c05d0d143f9d45a2cd6a1e6008314192cf1ed..196b15bab83b74e75e5167bb47f4581d2be48e67 100644 --- a/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -3056,7 +3056,7 @@ static inline int lpc17_ethinitialize(int intf) priv->lp_irq = ??; /* Ethernet controller IRQ number */ #endif - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->lp_txpoll = wd_create(); /* Create periodic poll timer */ priv->lp_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/lpc17xx/lpc17_i2c.c b/arch/arm/src/lpc17xx/lpc17_i2c.c index 579e943336af10724438a568977f821cfdffed26..522afae6836f127cde0332a694b376efa9d5e473 100644 --- a/arch/arm/src/lpc17xx/lpc17_i2c.c +++ b/arch/arm/src/lpc17xx/lpc17_i2c.c @@ -215,7 +215,8 @@ static int lpc17_i2c_start(struct lpc17_i2cdev_s *priv) priv->base + LPC17_I2C_CONCLR_OFFSET); putreg32(I2C_CONSET_STA, priv->base + LPC17_I2C_CONSET_OFFSET); - wd_start(priv->timeout, I2C_TIMEOUT, lpc17_i2c_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, I2C_TIMEOUT, lpc17_i2c_timeout, 1, + (uint32_t)priv); nxsem_wait(&priv->wait); wd_cancel(priv->timeout); diff --git a/arch/arm/src/lpc17xx/lpc17_i2c.h b/arch/arm/src/lpc17xx/lpc17_i2c.h index a7a6322461940cbcc88af415d024d38f12a82437..044f0560c778ba5aaa2941e51b65a963c11cc8ec 100644 --- a/arch/arm/src/lpc17xx/lpc17_i2c.h +++ b/arch/arm/src/lpc17xx/lpc17_i2c.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *lpc17_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc17_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_lcd.c b/arch/arm/src/lpc17xx/lpc17_lcd.c index 90332fc12e9d072bde96e8e135d4deea28650b12..e7aebe109fa6e577d0d442f8878708cda7f1476f 100644 --- a/arch/arm/src/lpc17xx/lpc17_lcd.c +++ b/arch/arm/src/lpc17xx/lpc17_lcd.c @@ -458,7 +458,7 @@ static int lpc17_setcursor(FAR struct fb_vtable_s *vtable, * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -717,7 +717,7 @@ int up_fbinitialize(int display) * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/arch/arm/src/lpc17xx/lpc17_lowputc.c b/arch/arm/src/lpc17xx/lpc17_lowputc.c index 3670014588087c8175003b8407a837f871707969..8f163f3440383511235cbd377140cdfe9493ce52 100644 --- a/arch/arm/src/lpc17xx/lpc17_lowputc.c +++ b/arch/arm/src/lpc17xx/lpc17_lowputc.c @@ -389,6 +389,13 @@ void lpc17_lowsetup(void) putreg32(UART_FCR_FIFOEN | UART_FCR_RXTRIGGER_8, CONSOLE_BASE + LPC17_UART_FCR_OFFSET); + /* Disable FDR (fractional divider), + * ignored by baudrate calculation => has to be disabled + */ + + putreg32((1 << UART_FDR_MULVAL_SHIFT) + (0 << UART_FDR_DIVADDVAL_SHIFT), + CONSOLE_BASE + LPC17_UART_FDR_OFFSET); + /* Set up the LCR and set DLAB=1 */ putreg32(CONSOLE_LCR_VALUE | UART_LCR_DLAB, diff --git a/arch/arm/src/lpc17xx/lpc17_mcpwm.c b/arch/arm/src/lpc17xx/lpc17_mcpwm.c index db0d1a9d67de95932697df6894bc0a8bc6e6ff23..c076a10ce5eb6f820fdc9a50ee717f97543a34b8 100644 --- a/arch/arm/src/lpc17xx/lpc17_mcpwm.c +++ b/arch/arm/src/lpc17xx/lpc17_mcpwm.c @@ -215,7 +215,7 @@ static void mcpwm_putreg(struct lpc17_mcpwmtimer_s *priv, int offset, uint32_t v * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -258,7 +258,7 @@ static void mcpwm_dumpregs(FAR struct lpc17_mcpwmtimer_s *priv, * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -290,7 +290,7 @@ static int mcpwm_timer(FAR struct lpc17_mcpwmtimer_s *priv, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * * Returned Value: @@ -324,7 +324,7 @@ static int mcpwm_interrupt(struct lpc17_mcpwmtimer_s *priv) * Description: * Handle timer 1 and 8 interrupts. * - * Input parameters: + * Input Parameters: * Standard NuttX interrupt inputs * * Returned Value: @@ -343,7 +343,7 @@ static int mcpwm_tim1interrupt(int irq, void *context) * Description: * Enable or disable APB clock for the timer peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -387,7 +387,7 @@ static void mcpwm_set_apb_clock(FAR struct lpc17_mcpwmtimer_s *priv, bool on) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -488,7 +488,7 @@ static int mcpwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -514,7 +514,7 @@ static int mcpwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -536,7 +536,7 @@ static int mcpwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -594,7 +594,7 @@ static int mcpwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/lpc17xx/lpc17_pwm.c b/arch/arm/src/lpc17xx/lpc17_pwm.c index df3be30a74a95a79911ea2983c238f66a6764b7a..f28c0996267123090724dd1d56802c68ae679c99 100644 --- a/arch/arm/src/lpc17xx/lpc17_pwm.c +++ b/arch/arm/src/lpc17xx/lpc17_pwm.c @@ -231,7 +231,7 @@ static void pwm_putreg(struct lpc17_pwmtimer_s *priv, int offset, uint32_t value * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -273,7 +273,7 @@ static void pwm_dumpregs(struct lpc17_pwmtimer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -308,7 +308,7 @@ static int pwm_timer(FAR struct lpc17_pwmtimer_s *priv, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * * Returned Value: @@ -342,7 +342,7 @@ static int pwm_interrupt(struct lpc17_pwmtimer_s *priv) * Description: * Handle timer 1 and 8 interrupts. * - * Input parameters: + * Input Parameters: * Standard NuttX interrupt inputs * * Returned Value: @@ -361,7 +361,7 @@ static int pwm_tim1interrupt(int irq, void *context, FAR void *arg) * Description: * Enable or disable APB clock for the timer peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -405,7 +405,7 @@ static void pwm_set_apb_clock(FAR struct lpc17_pwmtimer_s *priv, bool on) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -459,7 +459,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -485,7 +485,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -507,7 +507,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -565,7 +565,7 @@ static int pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/lpc17xx/lpc17_sdcard.c b/arch/arm/src/lpc17xx/lpc17_sdcard.c index 3d7fdffe705a9378360909c0359960670a714784..1d21e582c5822e7ebc0e998b2b41ff63e7801d6f 100644 --- a/arch/arm/src/lpc17xx/lpc17_sdcard.c +++ b/arch/arm/src/lpc17xx/lpc17_sdcard.c @@ -2307,7 +2307,7 @@ static sdio_eventset_t lpc17_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)lpc17_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2701,7 +2701,7 @@ static void lpc17_default(void) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SD card interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -2787,7 +2787,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -2833,7 +2833,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SD card driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc17xx/lpc17_sdcard.h b/arch/arm/src/lpc17xx/lpc17_sdcard.h index 520175ec25c08347e5f7fe6e948102cb7f136e54..82f94264c7c2009da5f96ed23803758d62bd4532 100644 --- a/arch/arm/src/lpc17xx/lpc17_sdcard.h +++ b/arch/arm/src/lpc17xx/lpc17_sdcard.h @@ -71,7 +71,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -93,7 +93,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -111,7 +111,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc17xx/lpc17_serial.c b/arch/arm/src/lpc17xx/lpc17_serial.c index 9c13a06d4a1986fdb323619b63eac69945ed8724..c321e23eb2f3c3294bdff2f461ba09eb45e7e065 100644 --- a/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/arch/arm/src/lpc17xx/lpc17_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc17xx/lpc17_serial.c * - * Copyright (C) 2010-2013, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2013, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -550,7 +550,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) /************************************************************************************ * Name: lpc17_uartcclkdiv * - * Descrption: + * Description: * Select a CCLK divider to produce the UART PCLK. The stratey is to select the * smallest divisor that results in an solution within range of the 16-bit * DLM and DLL divisor: @@ -667,7 +667,7 @@ static inline uint32_t lpc17_uartcclkdiv(uint32_t baud) /************************************************************************************ * Name: lpc17_uart0config, uart1config, uart2config, and uart3config * - * Descrption: + * Description: * Configure the UART. UART0/1/2/3 peripherals are configured using the following * registers: * @@ -815,7 +815,7 @@ static inline void lpc17_uart3config(void) /************************************************************************************ * Name: lpc17_uartdl * - * Descrption: + * Description: * Select a divider to produce the BAUD from the UART PCLK. * * BAUD = PCLK / (16 * DL), or @@ -920,6 +920,13 @@ static int up_setup(struct uart_dev_s *dev) lcr |= (UART_LCR_PE | UART_LCR_PS_EVEN); } + /* Disable FDR (fractional divider), + * ignored by baudrate calculation => has to be disabled + */ + + up_serialout(priv, LPC17_UART_FDR_OFFSET, + (1 << UART_FDR_MULVAL_SHIFT) + (0 << UART_FDR_DIVADDVAL_SHIFT)); + /* Enter DLAB=1 */ up_serialout(priv, LPC17_UART_LCR_OFFSET, (lcr | UART_LCR_DLAB)); diff --git a/arch/arm/src/lpc17xx/lpc17_spi.c b/arch/arm/src/lpc17xx/lpc17_spi.c index 60deac4fb54f3613e2126b79866f52c33102f862..f653df2d3681914def2e82eecec6b9840c5418d3 100644 --- a/arch/arm/src/lpc17xx/lpc17_spi.c +++ b/arch/arm/src/lpc17xx/lpc17_spi.c @@ -518,7 +518,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_spi.h b/arch/arm/src/lpc17xx/lpc17_spi.h index 27d9ba8bb935e429e90d6ebc9aed7b28672c96f4..f0be0e9978184178194c3ae0714006151e83bdf0 100644 --- a/arch/arm/src/lpc17xx/lpc17_spi.h +++ b/arch/arm/src/lpc17xx/lpc17_spi.h @@ -78,7 +78,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_ssp.c b/arch/arm/src/lpc17xx/lpc17_ssp.c index 98220105dc0bb0f01df1ae9640ceb2dc1d70c8b5..af8fb4bc422a30f907ba6a47ee6bd2bf6bcbd95c 100644 --- a/arch/arm/src/lpc17xx/lpc17_ssp.c +++ b/arch/arm/src/lpc17xx/lpc17_ssp.c @@ -765,7 +765,7 @@ static void ssp_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the SSP0 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -819,7 +819,7 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp0initialize(void) * Description: * Initialize the SSP1 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -873,7 +873,7 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp1initialize(void) * Description: * Initialize the SSP2 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -930,7 +930,7 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp2initialize(void) * Description: * Initialize the selected SSP port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_ssp.h b/arch/arm/src/lpc17xx/lpc17_ssp.h index c679206ca1e475b6596e59759b14d47975fb3723..dd8ba3c766f3c2d5dc76965c58d8e1caf07bebd7 100644 --- a/arch/arm/src/lpc17xx/lpc17_ssp.h +++ b/arch/arm/src/lpc17xx/lpc17_ssp.h @@ -76,7 +76,7 @@ extern "C" * Description: * Initialize the selected SSP port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc17xx/lpc17_timer.c b/arch/arm/src/lpc17xx/lpc17_timer.c index 434f416021ffaa6775ce31183ba8ba23eb94528f..8540d1b3862c2dde4fc560f03b40c837e810dc9d 100644 --- a/arch/arm/src/lpc17xx/lpc17_timer.c +++ b/arch/arm/src/lpc17xx/lpc17_timer.c @@ -215,7 +215,7 @@ static void timer_putreg(struct lpc17_timer_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -257,7 +257,7 @@ static void timer_dumpregs(struct lpc17_timer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -292,7 +292,7 @@ static int timer_timer(FAR struct lpc17_timer_s *priv, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * * Returned Value: @@ -326,7 +326,7 @@ static int timer_interrupt(struct lpc17_timer_s *priv) * Description: * Handle timer 1 and 8 interrupts. * - * Input parameters: + * Input Parameters: * Standard NuttX interrupt inputs * * Returned Value: @@ -349,7 +349,7 @@ static int timer_tim1interrupt(int irq, void *context) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -437,7 +437,7 @@ static int timer_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * * Returned Value: @@ -463,7 +463,7 @@ static int timer_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * info - A reference to the characteristics of the pulsed output * @@ -485,7 +485,7 @@ static int timer_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * * Returned Value: @@ -543,7 +543,7 @@ static int timer_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half TIMER driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/lpc17xx/lpc17_usbhost.c b/arch/arm/src/lpc17xx/lpc17_usbhost.c index fd51d9df2c45d3bd5f0529c0a6a9aaf90086decd..fb8abb6467be52b02081c154f3549fd1fb0d479f 100644 --- a/arch/arm/src/lpc17xx/lpc17_usbhost.c +++ b/arch/arm/src/lpc17xx/lpc17_usbhost.c @@ -1933,7 +1933,7 @@ static int lpc17_usbinterrupt(int irq, void *context, FAR void *arg) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -2029,7 +2029,7 @@ static int lpc17_wait(struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2128,7 +2128,7 @@ static int lpc17_enumerate(FAR struct usbhost_connection_s *conn, * mps (maxpacketsize) - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2183,7 +2183,7 @@ static int lpc17_ep0configure(struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2339,7 +2339,7 @@ static int lpc17_epalloc(struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2422,7 +2422,7 @@ static int lpc17_epfree(struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2468,7 +2468,7 @@ static int lpc17_alloc(struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2508,7 +2508,7 @@ static int lpc17_free(struct usbhost_driver_s *drvr, uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2553,7 +2553,7 @@ static int lpc17_ioalloc(struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2600,7 +2600,7 @@ static int lpc17_iofree(struct usbhost_driver_s *drvr, uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2701,7 +2701,7 @@ static int lpc17_ctrlout(struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -2779,7 +2779,7 @@ static int lpc17_transfer_common(struct lpc17_usbhost_s *priv, * buflen - The length of the data to be sent or received. * alloc - The location to return the allocated DMA buffer. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -2851,7 +2851,7 @@ static int lpc17_dma_alloc(struct lpc17_usbhost_s *priv, * buflen - The length of the data to be sent or received. * alloc - The allocated DMA buffer to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -2913,7 +2913,7 @@ static void lpc17_dma_free(struct lpc17_usbhost_s *priv, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -3087,7 +3087,7 @@ errout_with_sem: * ep - The IN or OUT endpoint descriptor for the device endpoint on which the * transfer was performed. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3189,7 +3189,7 @@ static void lpc17_asynch_completion(struct lpc17_usbhost_s *priv, * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3306,7 +3306,7 @@ errout_with_sem: * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -3451,7 +3451,7 @@ static int lpc17_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -3502,7 +3502,7 @@ static int lpc17_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3531,7 +3531,7 @@ static void lpc17_disconnect(struct usbhost_driver_s *drvr, * Input Parameters: * priv - private driver state instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc214x/lpc214x_spi.h b/arch/arm/src/lpc214x/lpc214x_spi.h index 69c94d89c0fc782290a96290d4c434e7fe0bbbb2..e4934d9d38c8b255bb0aec572850d61b6121961e 100644 --- a/arch/arm/src/lpc214x/lpc214x_spi.h +++ b/arch/arm/src/lpc214x/lpc214x_spi.h @@ -171,7 +171,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc2378/lpc23xx_i2c.c b/arch/arm/src/lpc2378/lpc23xx_i2c.c index 00d44687ea300b5c8593993774ff4348c80293f8..2a99c2a084425a3cd133ce9fc970b686e43cf02b 100644 --- a/arch/arm/src/lpc2378/lpc23xx_i2c.c +++ b/arch/arm/src/lpc2378/lpc23xx_i2c.c @@ -220,7 +220,8 @@ static int lpc2378_i2c_start(struct lpc2378_i2cdev_s *priv) priv->base + I2C_CONCLR_OFFSET); putreg32(I2C_CONSET_STA, priv->base + I2C_CONSET_OFFSET); - wd_start(priv->timeout, I2C_TIMEOUT, lpc2378_i2c_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, I2C_TIMEOUT, lpc2378_i2c_timeout, 1, + (uint32_t)priv); nxsem_wait(&priv->wait); wd_cancel(priv->timeout); diff --git a/arch/arm/src/lpc2378/lpc23xx_i2c.h b/arch/arm/src/lpc2378/lpc23xx_i2c.h index 5658269f20ae834b3c7837825e6bee9d2a07e43d..1ae069c5f7699139937df1f3698da507f1cbae76 100644 --- a/arch/arm/src/lpc2378/lpc23xx_i2c.h +++ b/arch/arm/src/lpc2378/lpc23xx_i2c.h @@ -163,7 +163,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -179,7 +179,7 @@ FAR struct i2c_master_s *lpc2378_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc2378_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/lpc2378/lpc23xx_io.c b/arch/arm/src/lpc2378/lpc23xx_io.c index 94e7f99c548f23651f09a01c0a4ccde18a39c3c9..f871ce17f80a2133918f69aea36e08bd258afeb0 100644 --- a/arch/arm/src/lpc2378/lpc23xx_io.c +++ b/arch/arm/src/lpc2378/lpc23xx_io.c @@ -55,7 +55,8 @@ /**************************************************************************** * Name: IO_Init() * - * Descriptions: Initialize the target board before running the main() + * Description: + * Initialize the target board before running the main() * ****************************************************************************/ diff --git a/arch/arm/src/lpc2378/lpc23xx_spi.c b/arch/arm/src/lpc2378/lpc23xx_spi.c index bc7f46cf0727e4af83f59f24ac8925d729d9eb61..b9006f4e5ce67b9c9f4b3dde10605f6e44c684b7 100644 --- a/arch/arm/src/lpc2378/lpc23xx_spi.c +++ b/arch/arm/src/lpc2378/lpc23xx_spi.c @@ -525,7 +525,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc2378/lpc23xx_spi.h b/arch/arm/src/lpc2378/lpc23xx_spi.h index 8b5fbda37c5b14db4acfcdad1094a32a85a106bd..280c2f44e20afee17003ccef5147f7c5111f6762 100644 --- a/arch/arm/src/lpc2378/lpc23xx_spi.h +++ b/arch/arm/src/lpc2378/lpc23xx_spi.h @@ -161,7 +161,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc31xx/lpc31.h b/arch/arm/src/lpc31xx/lpc31.h index 00ce6b8e35c70801957df11c2a8601230bf93db3..ca3c0ad8fbd5e198c0f2c37e255e14bc46ad6d32 100644 --- a/arch/arm/src/lpc31xx/lpc31.h +++ b/arch/arm/src/lpc31xx/lpc31.h @@ -176,7 +176,7 @@ void lpc31_clockconfig(void); * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: @@ -315,7 +315,7 @@ void lpc31_usbhost_vbusdrive(int rhport, bool enable); * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -337,7 +337,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -355,7 +355,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc31xx/lpc31_ehci.c b/arch/arm/src/lpc31xx/lpc31_ehci.c index 26772ea81a510f7ace18e3c9efd5b0065270464a..6b90a1b2eb1ca82afc1ed9436a9d40a433be778b 100644 --- a/arch/arm/src/lpc31xx/lpc31_ehci.c +++ b/arch/arm/src/lpc31xx/lpc31_ehci.c @@ -2087,7 +2087,7 @@ static struct lpc31_qtd_s *lpc31_qtd_statusphase(uint32_t tokenbits) * * Assumption: The caller holds the EHCI exclsem. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -2368,7 +2368,7 @@ errout_with_qh: * * Assumption: The caller holds the EHCI exclsem. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -2475,7 +2475,7 @@ errout_with_qh: * complete, but will be re-acquired when before returning. The state of * EHCI resources could be very different upon return. * - * Returned value: + * Returned Value: * On success, this function returns the number of bytes actually transferred. * For control transfers, this size includes the size of the control request * plus the size of the data (which could be short); For bulk transfers, this @@ -2555,7 +2555,7 @@ static ssize_t lpc31_transfer_wait(struct lpc31_epinfo_s *epinfo) * callback - The function to be called when the completes * arg - An arbitrary argument that will be provided with the callback. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -2608,7 +2608,7 @@ static inline int lpc31_ioc_async_setup(struct lpc31_rhport_s *rhport, * epinfo - The IN or OUT endpoint descriptor for the device endpoint on * which the transfer was performed. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3428,7 +3428,7 @@ static int lpc31_ehci_interrupt(int irq, FAR void *context, FAR void *arg) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3530,7 +3530,7 @@ static int lpc31_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3839,7 +3839,7 @@ static int lpc31_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3882,7 +3882,7 @@ static int lpc31_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3965,7 +3965,7 @@ static int lpc31_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4010,7 +4010,7 @@ static int lpc31_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which * to return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4055,7 +4055,7 @@ static int lpc31_alloc(FAR struct usbhost_driver_s *drvr, * to the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4092,7 +4092,7 @@ static int lpc31_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4131,7 +4131,7 @@ static int lpc31_ioalloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4176,7 +4176,7 @@ static int lpc31_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4277,7 +4277,7 @@ static int lpc31_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4387,7 +4387,7 @@ errout_with_sem: * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4480,7 +4480,7 @@ errout_with_sem: * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4677,7 +4677,7 @@ errout_with_sem: * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4728,7 +4728,7 @@ static int lpc31_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/lpc31xx/lpc31_i2c.c b/arch/arm/src/lpc31xx/lpc31_i2c.c index c65d55c47125a0bee54cdb5cad8226b085480f14..b4ff05cd9d12229f33109f5bfe67d23f6d1a70cb 100644 --- a/arch/arm/src/lpc31xx/lpc31_i2c.c +++ b/arch/arm/src/lpc31xx/lpc31_i2c.c @@ -490,7 +490,7 @@ static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs /* Start a watchdog to timeout the transfer if the bus is locked up... */ - wd_start(priv->timeout, I2C_TIMEOUT, i2c_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, I2C_TIMEOUT, i2c_timeout, 1, (uint32_t)priv); /* Wait for the transfer to complete */ diff --git a/arch/arm/src/lpc31xx/lpc31_i2c.h b/arch/arm/src/lpc31xx/lpc31_i2c.h index 10280a577311f83d04b8875b43a37175ca793e2f..ac14998d2224a7c9bed3f6cc6b3582df68611bd4 100644 --- a/arch/arm/src/lpc31xx/lpc31_i2c.h +++ b/arch/arm/src/lpc31xx/lpc31_i2c.h @@ -206,7 +206,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -222,7 +222,7 @@ FAR struct i2c_master_s *lpc31_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc31_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/lpc31xx/lpc31_spi.c b/arch/arm/src/lpc31xx/lpc31_spi.c index d0275a502d21157f9e3048a3902551f0b1545d25..c4e18511638369831d19c6eba69a90f889d164a6 100644 --- a/arch/arm/src/lpc31xx/lpc31_spi.c +++ b/arch/arm/src/lpc31xx/lpc31_spi.c @@ -903,7 +903,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/Make.defs b/arch/arm/src/lpc43xx/Make.defs index d5bd89123723dec372537e7e7dadd7e137ee7731..744768142c03909aaa28edf9f0fa24507f4fc01d 100644 --- a/arch/arm/src/lpc43xx/Make.defs +++ b/arch/arm/src/lpc43xx/Make.defs @@ -36,7 +36,7 @@ HEAD_ASRC = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c CMN_CSRCS += up_createstack.c up_mdelay.c up_udelay.c up_exit.c diff --git a/arch/arm/src/lpc43xx/lpc43_can.c b/arch/arm/src/lpc43xx/lpc43_can.c index 415a7b28efd163130bac8e6079c611b681dd0643..7013ffd6dd6aaafdd818c39a65e5ade3667e0c8e 100644 --- a/arch/arm/src/lpc43xx/lpc43_can.c +++ b/arch/arm/src/lpc43xx/lpc43_can.c @@ -1152,7 +1152,7 @@ static void can_setuprxobj(struct up_dev_s *priv) * Where: * Tcan is the period of the APB clock (PCLK = CCLK / CONFIG_CAN1_DIVISOR). * - * Input Parameter: + * Input Parameters: * priv - A reference to the CAN block status * * Returned Value: @@ -1210,7 +1210,7 @@ static int can_bittiming(struct up_dev_s *priv) * Description: * Initialize the selected can port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple can interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_can.h b/arch/arm/src/lpc43xx/lpc43_can.h index f321c9b72fa087ce403f8e48a75e92847a90b28d..37074c6df34cfd35d5389bf89d2908ae011cc5e0 100644 --- a/arch/arm/src/lpc43xx/lpc43_can.h +++ b/arch/arm/src/lpc43xx/lpc43_can.h @@ -64,7 +64,7 @@ extern "C" * Description: * Initialize the selected can port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple can interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_ehci.c b/arch/arm/src/lpc43xx/lpc43_ehci.c index 3b24b4f282e38b8a4bb32a82405aa389b262f444..3908fb1a8ee177d0c7cda2660123aff3be218e59 100644 --- a/arch/arm/src/lpc43xx/lpc43_ehci.c +++ b/arch/arm/src/lpc43xx/lpc43_ehci.c @@ -1971,7 +1971,7 @@ static struct lpc43_qtd_s *lpc43_qtd_statusphase(uint32_t tokenbits) * * Assumption: The caller holds the EHCI exclsem. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -2251,7 +2251,7 @@ errout_with_qh: * * Assumption: The caller holds the EHCI exclsem. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -2358,7 +2358,7 @@ errout_with_qh: * complete, but will be re-acquired when before returning. The state of * EHCI resources could be very different upon return. * - * Returned value: + * Returned Value: * On success, this function returns the number of bytes actually transferred. * For control transfers, this size includes the size of the control request * plus the size of the data (which could be short); For bulk transfers, this @@ -2420,7 +2420,7 @@ static ssize_t lpc43_transfer_wait(struct lpc43_epinfo_s *epinfo) * callback - The function to be called when the completes * arg - An arbitrary argument that will be provided with the callback. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -2473,7 +2473,7 @@ static inline int lpc43_ioc_async_setup(struct lpc43_rhport_s *rhport, * epinfo - The IN or OUT endpoint descriptor for the device endpoint on * which the transfer was performed. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3265,7 +3265,7 @@ static int lpc43_ehci_interrupt(int irq, FAR void *context, FAR void *arg) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3367,7 +3367,7 @@ static int lpc43_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3676,7 +3676,7 @@ static int lpc43_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3719,7 +3719,7 @@ static int lpc43_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3802,7 +3802,7 @@ static int lpc43_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3847,7 +3847,7 @@ static int lpc43_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which * to return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3889,7 +3889,7 @@ static int lpc43_alloc(FAR struct usbhost_driver_s *drvr, * to the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3926,7 +3926,7 @@ static int lpc43_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3962,7 +3962,7 @@ static int lpc43_ioalloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4007,7 +4007,7 @@ static int lpc43_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4108,7 +4108,7 @@ static int lpc43_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4218,7 +4218,7 @@ errout_with_sem: * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4311,7 +4311,7 @@ errout_with_sem: * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4508,7 +4508,7 @@ errout_with_sem: * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4559,7 +4559,7 @@ static int lpc43_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c index f5a9cb1e580215f2988447e8a629e9d314fafcf4..e598178811781f18b601b32594bdcbcc5d38eab2 100644 --- a/arch/arm/src/lpc43xx/lpc43_ethernet.c +++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc43/lpc43_eth.c * - * Copyright (C) 2011-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -621,7 +621,7 @@ static int lpc43_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int lpc43_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2744,16 +2744,17 @@ static void lpc43_rxdescinit(FAR struct lpc43_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)dev->d_private; #endif int ret; switch (cmd) { +#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_ARCH_PHY_INTERRUPT case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { @@ -2791,6 +2792,7 @@ static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) ret = lpc43_phywrite(req->phy_id, req->reg_num, req->val_in); } break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ default: ret = -ENOTTY; @@ -2799,7 +2801,7 @@ static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: lpc43_phyintenable @@ -3823,12 +3825,12 @@ static inline int lpc43_ethinitialize(void) priv->dev.d_addmac = lpc43_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = lpc43_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = lpc43_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_lpc43ethmac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmission */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/lpc43xx/lpc43_i2c.c b/arch/arm/src/lpc43xx/lpc43_i2c.c index f613470a8f5a1313760576007e896699a4a48159..137a34f1f780a43db23418c810dae9f6173f5353 100644 --- a/arch/arm/src/lpc43xx/lpc43_i2c.c +++ b/arch/arm/src/lpc43xx/lpc43_i2c.c @@ -202,7 +202,8 @@ static int lpc43_i2c_start(struct lpc43_i2cdev_s *priv) priv->base + LPC43_I2C_CONCLR_OFFSET); putreg32(I2C_CONSET_STA, priv->base + LPC43_I2C_CONSET_OFFSET); - wd_start(priv->timeout, I2C_TIMEOUT, lpc43_i2c_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, I2C_TIMEOUT, lpc43_i2c_timeout, 1, + (uint32_t)priv); nxsem_wait(&priv->wait); wd_cancel(priv->timeout); diff --git a/arch/arm/src/lpc43xx/lpc43_i2c.h b/arch/arm/src/lpc43xx/lpc43_i2c.h index ae8d94a7f883e5f25654ebe699ab1be0379a6af8..224fbaa593e35cb07efcd12bc0b8e88a7a0d3f16 100644 --- a/arch/arm/src/lpc43xx/lpc43_i2c.h +++ b/arch/arm/src/lpc43xx/lpc43_i2c.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *lpc43_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc43_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_pinconfig.c b/arch/arm/src/lpc43xx/lpc43_pinconfig.c index 0a274dd6a898bac27314835e74a951e71f8aaa35..738b4b8dafd2bf85924260cebf3ae1ff2f672a14 100644 --- a/arch/arm/src/lpc43xx/lpc43_pinconfig.c +++ b/arch/arm/src/lpc43xx/lpc43_pinconfig.c @@ -68,7 +68,7 @@ * Description: * Configure a pin based on bit-encoded description of the pin. * - * Input Value: + * Input Parameters: * 20-bit encoded value describing the pin. * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_pinconfig.h b/arch/arm/src/lpc43xx/lpc43_pinconfig.h index d3a8a822a6a0d70e11621cfdf5bf9e78872c5bdb..6b82878981af7cfd8741cd7c1eb2cd5bd4b48048 100644 --- a/arch/arm/src/lpc43xx/lpc43_pinconfig.h +++ b/arch/arm/src/lpc43xx/lpc43_pinconfig.h @@ -262,7 +262,7 @@ extern "C" * Description: * Configure a pin based on bit-encoded description of the pin. * - * Input Value: + * Input Parameters: * 20-bit encoded value describing the pin. * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_sdmmc.c b/arch/arm/src/lpc43xx/lpc43_sdmmc.c index 5d4df400b3f00723a24d9da7dc3e03ff33cce892..a84c6b8de99e490fbebde7e7985bb52e14cecc00 100644 --- a/arch/arm/src/lpc43xx/lpc43_sdmmc.c +++ b/arch/arm/src/lpc43xx/lpc43_sdmmc.c @@ -2262,7 +2262,7 @@ static sdio_eventset_t lpc43_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)lpc43_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2709,7 +2709,7 @@ static void lpc43_callback(struct lpc43_dev_s *priv) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SD card interface structure. NULL is returned on failures. * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_sdmmc.h b/arch/arm/src/lpc43xx/lpc43_sdmmc.h index 7a27088415cf16f294218165fe6fc3f73b2d846d..449ee0f7a508f146eac58e8d5393e50d2ec5297e 100644 --- a/arch/arm/src/lpc43xx/lpc43_sdmmc.h +++ b/arch/arm/src/lpc43xx/lpc43_sdmmc.h @@ -71,7 +71,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_spi.c b/arch/arm/src/lpc43xx/lpc43_spi.c index a77996513bd729c3b9b5a871f9f9b4d40900deeb..2181b4fa2f0b291d31074c4e95f3842208c0a118 100644 --- a/arch/arm/src/lpc43xx/lpc43_spi.c +++ b/arch/arm/src/lpc43xx/lpc43_spi.c @@ -505,7 +505,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the SPI port * - * Input Parameter: + * Input Parameters: * port Port number (must be zero) * * Returned Value: @@ -564,7 +564,7 @@ static FAR struct spi_dev_s *lpc43_spiport_initialize(int port) * 1 - SSP0 * 2 - SSP1 * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_spi.h b/arch/arm/src/lpc43xx/lpc43_spi.h index d0414f9af64b142f2c44317c2ebbd7e650ba5909..b642f9c49083eb967d9606357834fa9353428806 100644 --- a/arch/arm/src/lpc43xx/lpc43_spi.h +++ b/arch/arm/src/lpc43xx/lpc43_spi.h @@ -98,7 +98,7 @@ extern "C" * 1 - SSP0 * 2 - SSP1 * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_spifi.c b/arch/arm/src/lpc43xx/lpc43_spifi.c index 57349370c027b401854c2703903c8f09631a79c0..ed2f01f2c90b40ac31c1d3856c618799952820fe 100644 --- a/arch/arm/src/lpc43xx/lpc43_spifi.c +++ b/arch/arm/src/lpc43xx/lpc43_spifi.c @@ -1132,7 +1132,7 @@ static inline int lpc43_rominit(FAR struct lpc43_dev_s *priv) * Input Parameters: * None * - * Returned value: + * Returned Value: * One success, a reference to the initialized MTD device instance is * returned; NULL is returned on any failure. * @@ -1220,7 +1220,7 @@ FAR struct mtd_dev_s *lpc43_spifi_initialize(void) * Input Parameters: * high * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_spifi.h b/arch/arm/src/lpc43xx/lpc43_spifi.h index 4445919259139dae7d863faf488338fc380666db..30f85b83282f83a33bea41d49218d72a930264bf 100644 --- a/arch/arm/src/lpc43xx/lpc43_spifi.h +++ b/arch/arm/src/lpc43xx/lpc43_spifi.h @@ -118,7 +118,7 @@ extern "C" * Input Parameters: * None * - * Returned value: + * Returned Value: * One success, a reference to the initialized MTD device instance is * returned; NULL is returned on any failure. * diff --git a/arch/arm/src/lpc43xx/lpc43_ssp.c b/arch/arm/src/lpc43xx/lpc43_ssp.c index 2660b00654707eee749b2e10e9f843dda6d404fe..a9816b9366e92bba380fe5d35f2aeffd05b49fc8 100644 --- a/arch/arm/src/lpc43xx/lpc43_ssp.c +++ b/arch/arm/src/lpc43xx/lpc43_ssp.c @@ -664,7 +664,7 @@ static void ssp_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * Description: * Initialize the SSP0 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -717,7 +717,7 @@ static inline FAR struct lpc43_sspdev_s *lpc43_ssp0initialize(void) * Description: * Initialize the SSP1 * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -777,7 +777,7 @@ static inline FAR struct lpc43_sspdev_s *lpc43_ssp1initialize(void) * Description: * Initialize the selected SSP port (0=SSP0, 1=SSP1) * - * Input Parameter: + * Input Parameters: * port - Port number (0=SSP0, 1=SSP1) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_ssp.h b/arch/arm/src/lpc43xx/lpc43_ssp.h index 5bf708859e6d54d4b416ee70ac50a73c500eaa21..27be5a5130befebad5f48cabc03948645359919b 100644 --- a/arch/arm/src/lpc43xx/lpc43_ssp.h +++ b/arch/arm/src/lpc43xx/lpc43_ssp.h @@ -95,7 +95,7 @@ extern "C" * Description: * Initialize the selected SSP port (0=SSP0, 1=SSP1) * - * Input Parameter: + * Input Parameters: * port - Port number (0=SSP0, 1=SSP1) * * Returned Value: diff --git a/arch/arm/src/lpc43xx/lpc43_timer.c b/arch/arm/src/lpc43xx/lpc43_timer.c index decc110dd49998f13405d6b8e049fe1497d5e766..7c68ffd449a897e70bc917a5a7c6f1685bc1eb92 100644 --- a/arch/arm/src/lpc43xx/lpc43_timer.c +++ b/arch/arm/src/lpc43xx/lpc43_timer.c @@ -331,7 +331,7 @@ void tmr_clk_disable(uint16_t tmrid) * Input Parameters: * Usual interrupt callback arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -401,7 +401,7 @@ static int lpc43_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -465,7 +465,7 @@ static int lpc43_start(FAR struct timer_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -509,7 +509,7 @@ static int lpc43_stop(FAR struct timer_lowerhalf_s *lower) * half" driver state structure. * status - The location to return the status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -564,7 +564,7 @@ static int lpc43_getstatus(FAR struct timer_lowerhalf_s *lower, * half" driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -627,7 +627,7 @@ static int lpc43_settimeout(FAR struct timer_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous timer expiration function pointer or NULL is there was * no previous function pointer. * @@ -667,7 +667,7 @@ static void lpc43_setcallback(FAR struct timer_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -700,7 +700,7 @@ static int lpc43_ioctl(FAR struct timer_lowerhalf_s *lower, int cmd, * devpath - The full path to the timer. This should be of the form * /dev/tmr0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_timer.h b/arch/arm/src/lpc43xx/lpc43_timer.h index 194d917c3179d58837af19a93a1d6fc95043f9dd..7eed9b2dcd39cdb60e56c042a0746cad236ee54a 100644 --- a/arch/arm/src/lpc43xx/lpc43_timer.h +++ b/arch/arm/src/lpc43xx/lpc43_timer.h @@ -80,7 +80,7 @@ extern "C" * devpath - The full path to the timer. This should be of the form * /dev/timer0 * irq - irq associated with the timer - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_wdt.h b/arch/arm/src/lpc43xx/lpc43_wdt.h index af427504e4dc53fa8c75031ea4d12165852756f7..c1d88a01e6b8ee673e66ebbe0e65719fae765d0a 100644 --- a/arch/arm/src/lpc43xx/lpc43_wdt.h +++ b/arch/arm/src/lpc43xx/lpc43_wdt.h @@ -78,7 +78,7 @@ extern "C" * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_wwdt.c b/arch/arm/src/lpc43xx/lpc43_wwdt.c index 872e8d5f3f5b063c11f0b129cabf09bc0ccd397c..fb60102d420924e3cb3c383e8753da3226b396a2 100644 --- a/arch/arm/src/lpc43xx/lpc43_wwdt.c +++ b/arch/arm/src/lpc43xx/lpc43_wwdt.c @@ -206,7 +206,7 @@ static void lpc43_setwarning(uint32_t warning) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -254,7 +254,7 @@ static int lpc43_interrupt(int irq, FAR void *context) * lower - A pointer the publicly visible representation of the * "lower-half" driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -295,7 +295,7 @@ static int lpc43_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -329,7 +329,7 @@ static int lpc43_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -361,7 +361,7 @@ static int lpc43_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * status - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -419,7 +419,7 @@ static int lpc43_getstatus(FAR struct watchdog_lowerhalf_s *lower, * "lower-half" driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -494,7 +494,7 @@ static int lpc43_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -563,7 +563,7 @@ static xcpt_t lpc43_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -620,7 +620,7 @@ static int lpc43_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc54xx/Kconfig b/arch/arm/src/lpc54xx/Kconfig index bc77fb071992cfa6024976919edebd97e1ddb5e3..947350c773304d33c7d51da5bc609b1eb763549e 100644 --- a/arch/arm/src/lpc54xx/Kconfig +++ b/arch/arm/src/lpc54xx/Kconfig @@ -667,6 +667,24 @@ endif # LPC54_EMC_DYNAMIC endmenu # EMC Configuration +menu "SPI Master configuration" + depends on LPC54_HAVE_SPI_MASTER + +config LPC54_SPI_WIDEDATA + bool "Enable wide data" + default n + ---help--- + The LPC54xxx SPI supports data widths from 4 through 16 bits. For + data from 4 through 8 bits; the receive and transmit data is + represented with a uint8_t type. For the wider data, data is + represented with a uint16_t. There is duplication of logic for this + different widths. By default, SPI wide data is disabled since that + is the less frequently used data type and disabling wide data can + result in some size reduction. Select this option if you need wide + SPI data. + +endmenu # SPI Master configuration + menu "Ethernet configuration" depends on LPC54_ETHERNET diff --git a/arch/arm/src/lpc54xx/Make.defs b/arch/arm/src/lpc54xx/Make.defs index 4ba8c0d6f8f3d21e02bbf01d3157ac8ee755a4a5..0df41b51b8247105fa0792012a820a9e68ae0c40 100644 --- a/arch/arm/src/lpc54xx/Make.defs +++ b/arch/arm/src/lpc54xx/Make.defs @@ -36,7 +36,7 @@ HEAD_ASRC = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c CMN_CSRCS += up_createstack.c up_mdelay.c up_udelay.c up_exit.c diff --git a/arch/arm/src/lpc54xx/chip/lpc54_spi.h b/arch/arm/src/lpc54xx/chip/lpc54_spi.h index 9ab286e18a9a02895093eafd273e5329691b9ba1..21071fbb371f0c491ebac4a379d30fc189b40098 100644 --- a/arch/arm/src/lpc54xx/chip/lpc54_spi.h +++ b/arch/arm/src/lpc54xx/chip/lpc54_spi.h @@ -260,38 +260,146 @@ /* Register bit definitions *************************************************************************/ /* SPI Configuration register */ -#define SPI_CFG_ + +#define SPI_CFG_ENABLE (1 << 0) /* Bit 0: SPI enable */ +#define SPI_CFG_MASTER (1 << 2) /* Bit 2: Master mode select */ +#define SPI_CFG_LSBF (1 << 3) /* Bit 3: LSB First mode enable */ +#define SPI_CFG_CPHA (1 << 4) /* Bit 4: Clock Phase select */ +#define SPI_CFG_CPOL (1 << 5) /* Bit 5: Clock Polarity select */ +#define SPI_CFG_LOOP (1 << 7) /* Bit 7: Loopback mode enable */ +#define SPI_CFG_SPOL0 (1 << 8) /* Bit 8: SSEL0 Polarity select */ +#define SPI_CFG_SPOL1 (1 << 9) /* Bit 9: SSEL1 Polarity select */ +#define SPI_CFG_SPOL2 (1 << 10) /* Bit 10: SSEL2 Polarity select */ +#define SPI_CFG_SPOL3 (1 << 11) /* Bit 11: SSEL3 Polarity select */ + /* SPI Delay register */ -#define SPI_DLY_ + +#define SPI_DLY_PRE_DELAY_SHIFT (0) /* Bits 0-3: Time between SSEL assertion and data transfer */ +#define SPI_DLY_PRE_DELAY_MASK (15 << SPI_DLY_PRE_DELAY_SHIFT) +# define SPI_DLY_PRE_DELAY(n) ((uint32_t)(n) << SPI_DLY_PRE_DELAY_SHIFT) +#define SPI_DLY_POST_DELAY_SHIFT (4) /* Bits 4-7: Time between tdata transfer and SSEL deassertion */ +#define SPI_DLY_POST_DELAY_MASK (15 << SPI_DLY_POST_DELAY_SHIFT) +# define SPI_DLY_POST_DELAY(n) ((uint32_t)(n) << SPI_DLY_POST_DELAY_SHIFT) +#define SPI_DLY_FRAME_DELAY_SHIFT (8) /* Bits 8-11: Minimum amount of time between frames */ +#define SPI_DLY_FRAME_DELAY_MASK (15 << SPI_DLY_FRAME_DELAY_SHIFT) +# define SPI_DLY_FRAME_DELAY(n) ((uint32_t)(n) << SPI_DLY_FRAME_DELAY_SHIFT) +#define SPI_DLY_TRANSFER_DELAY_SHIFT (12) /* Bits 12-15: Time SSEL deasserted between transfers */ +#define SPI_DLY_TRANSFER_DELAY_MASK (15 << SPI_DLY_TRANSFER_DELAY_SHIFT) +# define SPI_DLY_TRANSFER_DELAY(n) ((uint32_t)(n) << SPI_DLY_TRANSFER_DELAY_SHIFT) + /* SPI Status register */ -#define SPI_STAT_ -/* SPI Interrupt Enable read and set */ -#define SPI_INTENSET_ -/* SPI Interrupt Enable Clear */ -#define SPI_INTENCLR_ + +#define SPI_STAT_SSA (1 << 4) /* Bit 4: Slave Select Assert */ +#define SPI_STAT_SSD (1 << 5) /* Bit 5: Slave Select Deassert */ +#define SPI_STAT_STALLED (1 << 6) /* Bit 6: Stalled status flag */ +#define SPI_STAT_ENDTRANSFER (1 << 7) /* Bit 7: End Transfer control bit */ +#define SPI_STAT_MSTIDLE (1 << 8) /* Bit 8: Master idle status flag */ + +/* SPI Interrupt Enable read and set, SPI Interrupt Enable Clear, and SPI Interrupt Status */ + +#define SPI_INT_SSA (1 << 4) /* Bit 4: Slave select assert interrupt */ +#define SPI_INT_SSD (1 << 5) /* Bit 5: Slave select deassert interrupt */ +#define SPI_INT_MSTIDLE (1 << 8) /* Bit 8: Master idle interrupt */ + /* SPI clock Divider */ -#define SPI_DIV_ -/* SPI Interrupt Status */ -#define SPI_INTSTAT_ + +#define SPI_DIV_SHIFT (0) /* Bits 0-15: Rate divider value */ +#define SPI_DIV_MASK (0xffff << SPI_DIV_SHIFT) +# define SPI_DIV(n) ((uint32_t)((n)-1) << SPI_DIV_SHIFT) + /* FIFO configuration and enable register */ -#define SPI_FIFOCFG_ + +#define SPI_FIFOCFG_ENABLETX (1 << 0) /* Bit 0: Enable the transmit FIFO) */ +#define SPI_FIFOCFG_ENABLERX (1 << 1) /* Bit 1: Enable the receive FIFO) */ +#define SPI_FIFOCFG_SIZE_SHIFT (4) /* Bits 4-5: FIFO size configuration (read-only) */ +#define SPI_FIFOCFG_SIZE_MASK (3 << SPI_FIFOCFG_SIZE_SHIFT) +# define SPI_FIFOCFG_SIZE_8x16 (1 << SPI_FIFOCFG_SIZE_SHIFT) /* FIFO is configured as 8 entries of 16 bits */ +#define SPI_FIFOCFG_DMATX (1 << 12) /* Bit 12: DMA configuration for transmit */ +#define SPI_FIFOCFG_DMARX (1 << 13) /* Bit 13: DMA configuration for receive */ +#define SPI_FIFOCFG_WAKETX (1 << 14) /* Bit 14: Wake-up for transmit FIFO level */ +#define SPI_FIFOCFG_WAKERX (1 << 15) /* Bit 15: Wake-up for receive FIFO level */ +#define SPI_FIFOCFG_EMPTYTX (1 << 16) /* Bit 16: Empty command for the transmit FIFO) */ +#define SPI_FIFOCFG_EMPTYRX (1 << 17) /* Bit 17: Empty command for the receive FIFO) */ + /* FIFO status register */ -#define SPI_FIFOSTAT_ + +#define SPI_FIFOSTAT_TXERR (1 << 0) /* Bit 0: TX FIFO error */ +#define SPI_FIFOSTAT_RXERR (1 << 1) /* Bit 1: RX FIFO error */ +#define SPI_FIFOSTAT_PERINT (1 << 3) /* Bit 3: Peripheral interrupt */ +#define SPI_FIFOSTAT_TXEMPTY (1 << 4) /* Bit 4: Transmit FIFO empty */ +#define SPI_FIFOSTAT_TXNOTFULL (1 << 5) /* Bit 5: Transmit FIFO not full */ +#define SPI_FIFOSTAT_RXNOTEMPTY (1 << 6) /* Bit 6: Receive FIFO not empty */ +#define SPI_FIFOSTAT_RXFULL (1 << 7) /* Bit 7: Receive FIFO full */ +#define SPI_FIFOSTAT_TXLVL_SHIFT (8) /* Bits 8-12: Transmit FIFO current level */ +#define SPI_FIFOSTAT_TXLVL_MASK (31 << SPI_FIFOSTAT_TXLVL_SHIFT) +#define SPI_FIFOSTAT_RXLVL_SHIFT (16) /* Bits 16-20: Receive FIFO current level */ +#define SPI_FIFOSTAT_RXLVL_MASK (31 << SPI_FIFOSTAT_RXLVL_SHIFT) + /* FIFO trigger level settings for interrupt and DMA request */ -#define SPI_FIFOTRIG_ -/* FIFO interrupt enable set (enable) and read register */ -#define SPI_FIFOINTENSET_ -/* FIFO interrupt enable clear (disable) and read register */ -#define SPI_FIFOINTENCLR_ -/* FIFO interrupt status register */ -#define SPI_FIFOINTSTAT_ + +#define SPI_FIFOTRIG_TXLVLENA (1 << 0) /* Bit 0: Transmit FIFO level trigger enable */ +#define SPI_FIFOTRIG_RXLVLENA (1 << 1) /* Bit 1: Receive FIFO level trigger enable */ +#define SPI_FIFOTRIG_TXLVL_SHIFT (8) /* Bits 8-11: Transmit FIFO level trigger point */ +#define SPI_FIFOTRIG_TXLVL_MASK (15 << SPI_FIFOTRIG_TXLVL_SHIFT) +# define SPI_FIFOTRIG_TXLVL(n) ((uint32_t)(n) << SPI_FIFOTRIG_TXLVL_SHIFT) +# define SPI_FIFOTRIG_TXLVL_EMPTY (0 << SPI_FIFOTRIG_TXLVL_SHIFT) +# define SPI_FIFOTRIG_TXLVL_NOTFULL (7 << SPI_FIFOTRIG_TXLVL_SHIFT) +#define SPI_FIFOTRIG_RXLVL_SHIFT (16) /* Bits 16-19: Receive FIFO level trigger point */ +#define SPI_FIFOTRIG_RXLVL_MASK (15 << SPI_FIFOTRIG_RXLVL_SHIFT) +# define SPI_FIFOTRIG_RXLVL(n) ((uint32_t)((n)-1) << SPI_FIFOTRIG_RXLVL_SHIFT) +# define SPI_FIFOTRIG_RXLVL_NOTEMPTY (0 << SPI_FIFOTRIG_RXLVL_SHIFT) +# define SPI_FIFOTRIG_RXLVL_FULL (7 << SPI_FIFOTRIG_RXLVL_SHIFT) + +/* FIFO interrupt enable set (enable) and read register, FIFO interrupt enable clear (disable) + * and read register, and FIFO interrupt status register + */ + +#define SPI_FIFOINT_TXERR (1 << 0) /* Bit 0: Transmit error interrupt */ +#define SPI_FIFOINT_RXERR (1 << 1) /* Bit 1: Receive error interrupt */ +#define SPI_FIFOINT_TXLVL (1 << 2) /* Bit 2: Tx FIFO level reached interrupt */ +#define SPI_FIFOINT_RXLVL (1 << 3) /* Bit 3: Rx FIFO level reached interrupt */ +#define SPI_FIFOINTSTAT_PERINT (1 << 4) /* Bit 4: Peripheral interrupt (status only) */ + /* FIFO write data */ -#define SPI_FIFOWR_ -/* FIFO read data */ -#define SPI_FIFORD_ -/* FIFO data read with no FIFO pop */ -#define SPI_FIFORDNOPOP_ + +#define SPI_FIFOWR_TXDATA_SHIFT (0) /* Bits 0-15: Transmit data to the FIFO */ +#define SPI_FIFOWR_TXDATA_MASK (0xffff << SPI_FIFOWR_TXDATA_SHIFT) +# define SPI_FIFOWR_TXDATA(n) ((uint32_t)(n) << SPI_FIFOWR_TXDATA_SHIFT) +#define SPI_FIFOWR_TXSSELN_SHIFT (16) /* Bits 16-19: Transmit Slave Selects */ +#define SPI_FIFOWR_TXSSELN_MASK (15 << SPI_FIFOWR_TXSSELN_SHIFT) +# define SPI_FIFOWR_TXSSELN_ALL (15 << SPI_FIFOWR_TXSSELN_SHIFT) +# define SPI_FIFOWR_TXSSEL0N (1 << 16) /* Bit 16: Transmit Slave Select */ +# define SPI_FIFOWR_TXSSEL1N (1 << 17) /* Bit 17: Transmit Slave Select */ +# define SPI_FIFOWR_TXSSEL2N (1 << 18) /* Bit 18: Transmit Slave Select */ +# define SPI_FIFOWR_TXSSEL3N (1 << 19) /* Bit 19: Transmit Slave Select */ +#define SPI_FIFOWR_EOT (1 << 20) /* Bit 20: End of Transfer */ +#define SPI_FIFOWR_EOF (1 << 21) /* Bit 21: End of Frame */ +#define SPI_FIFOWR_RXIGNORE (1 << 22) /* Bit 22: Receive Ignore */ +#define SPI_FIFOWR_LEN_SHIFT (24) /* Bits 24-27: Data Length */ +#define SPI_FIFOWR_LEN_MASK (15 << SPI_FIFOWR_LEN_SHIFT) +# define SPI_FIFOWR_LEN(n) ((uint32_t)((n)-1) << SPI_FIFOWR_LEN_SHIFT) + +/* FIFO read data and FIFO data read with no FIFO pop */ + +#define SPI_FIFORD_RXDATA_SHIFT (0) /* Bits 0-15: Received data from the FIFO */ +#define SPI_FIFORD_RXDATA_MASK (0xffff << SPI_FIFORD_RXDATA_SHIFT) +#define SPI_FIFORD_RXSSELN_SHIFT (16) /* Bits 16-19: Slave Selects for receive */ +#define SPI_FIFORD_RXSSELN_MASK (15 << SPI_FIFORD_RXSSELN_SHIFT) +# define SPI_FIFORD_RXSSEL0N (1 << 16) /* Bit 16: Slave Select for receive */ +# define SPI_FIFORD_RXSSEL1N (1 << 17) /* Bit 17: Slave Select for receive */ +# define SPI_FIFORD_RXSSEL2N (1 << 18) /* Bit 18: Slave Select for receive */ +# define SPI_FIFORD_RXSSEL3N (1 << 19) /* Bit 19: Slave Select for receive */ +#define SPI_FIFORD_SOT (1 << 20) /* Bit 20: Start of Transfer flag */ + /* SPI module Identification */ -#define SPI_ID_ + +#define SPI_ID_APERTURE_SHIFT (0) /* Bits 0-7: Aperture encoded as (aperture size/4K) -1 */ +#define SPI_ID_APERTURE_MASK (0xff << SPI_ID_APERTURE_SHIFT) +#define SPI_ID_MINORREV_SHIFT (8) /* Bits 8-11: Minor revision of module implementation */ +#define SPI_ID_MINORREV_MASK (15 << SPI_ID_MINORREV_SHIFT) +#define SPI_ID_MAJORREV_SHIFT (12) /* Bits 12-15: Major revision of module implementation */ +#define SPI_ID_MAJORREV_MASK (15 << SPI_ID_MAJORREV_SHIFT) +#define SPI_ID_ID_SHIFT (15) /* Bits 16-31: Unique module identifier for this IP block */ +#define SPI_ID_ID_MASK (0xffff << SPI_ID_ID_SHIFT) #endif /* __ARCH_ARM_SRC_LPC54XX_CHIP_LPC54_SPI_H */ diff --git a/arch/arm/src/lpc54xx/lpc54_ethernet.c b/arch/arm/src/lpc54xx/lpc54_ethernet.c index d89317247dc74004e777795f607c33154658059d..dde91da5c1773f3bb31118f36a30ce7bb6cb4cdd 100644 --- a/arch/arm/src/lpc54xx/lpc54_ethernet.c +++ b/arch/arm/src/lpc54xx/lpc54_ethernet.c @@ -2392,13 +2392,16 @@ static int lpc54_eth_rmmac(struct net_driver_s *dev, const uint8_t *mac) static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct lpc54_ethdriver_s *priv = (struct lpc54_ethdriver_s *)dev->d_private; +#endif int ret; /* Decode and dispatch the driver-specific IOCTL command */ switch (cmd) { +#ifdef CONFIG_NETDEV_PHY_IOCTL case SIOCGMIIPHY: /* Get MII PHY address */ { struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); @@ -2422,6 +2425,7 @@ static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd, ret = OK } break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ default: nerr("ERROR: Unrecognized IOCTL command: %d\n", command); diff --git a/arch/arm/src/lpc54xx/lpc54_i2c_master.c b/arch/arm/src/lpc54xx/lpc54_i2c_master.c index cf4981676f5267a1c352680221365cc9dca38fad..05d171a5971db2a829bb758355bd22e91d5168ba 100644 --- a/arch/arm/src/lpc54xx/lpc54_i2c_master.c +++ b/arch/arm/src/lpc54xx/lpc54_i2c_master.c @@ -765,10 +765,9 @@ static int lpc54_i2c_transfer(FAR struct i2c_master_s *dev, priv->result = OK; /* Set up the transfer timeout */ - /* wd_start(priv->timeout ...); */ - wd_start(priv->timeout, priv->nmsgs * I2C_WDOG_TIMEOUT, lpc54_i2c_timeout, - 1, (uint32_t)priv); + (void)wd_start(priv->timeout, priv->nmsgs * I2C_WDOG_TIMEOUT, + lpc54_i2c_timeout, 1, (uint32_t)priv); /* Initiate the transfer */ diff --git a/arch/arm/src/lpc54xx/lpc54_i2c_master.h b/arch/arm/src/lpc54xx/lpc54_i2c_master.h index 1655d0fec5e174af6ad715ed4e683ff22a44fc58..fc9e80f662a83c5a5986302ae06b9063f6d7d472 100644 --- a/arch/arm/src/lpc54xx/lpc54_i2c_master.h +++ b/arch/arm/src/lpc54xx/lpc54_i2c_master.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *lpc54_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc54_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/lpc54xx/lpc54_lcd.c b/arch/arm/src/lpc54xx/lpc54_lcd.c index 25cb80fc3335eae27060095864f2dd7c0591984e..2b8b5aa262cda268b03e7e3996966f2b54d1e6ee 100644 --- a/arch/arm/src/lpc54xx/lpc54_lcd.c +++ b/arch/arm/src/lpc54xx/lpc54_lcd.c @@ -441,7 +441,7 @@ static int lpc54_setcursor(FAR struct fb_vtable_s *vtable, * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -802,7 +802,7 @@ int up_fbinitialize(int display) * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/arch/arm/src/lpc54xx/lpc54_sdmmc.c b/arch/arm/src/lpc54xx/lpc54_sdmmc.c index 09cb42526777204524ddbdbcdf8da77cc000f531..292732040db4e294a422e4c944b26a1e0675a689 100644 --- a/arch/arm/src/lpc54xx/lpc54_sdmmc.c +++ b/arch/arm/src/lpc54xx/lpc54_sdmmc.c @@ -2262,7 +2262,7 @@ static sdio_eventset_t lpc54_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)lpc54_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2709,7 +2709,7 @@ static void lpc54_callback(struct lpc54_dev_s *priv) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SD card interface structure. NULL is returned on failures. * ****************************************************************************/ diff --git a/arch/arm/src/lpc54xx/lpc54_sdmmc.h b/arch/arm/src/lpc54xx/lpc54_sdmmc.h index 7eb00403c55dd833eac291f54a6e4e46f500a755..a56fe2095bc5cc4414a35bd05de257a194f2ef15 100644 --- a/arch/arm/src/lpc54xx/lpc54_sdmmc.h +++ b/arch/arm/src/lpc54xx/lpc54_sdmmc.h @@ -71,7 +71,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ diff --git a/arch/arm/src/lpc54xx/lpc54_serial.c b/arch/arm/src/lpc54xx/lpc54_serial.c index 7c74dec93be5935cdb4497b6b3e5cf894f6f499f..996affee4caef22105b1d138cf5ad2b425376898 100644 --- a/arch/arm/src/lpc54xx/lpc54_serial.c +++ b/arch/arm/src/lpc54xx/lpc54_serial.c @@ -1421,7 +1421,7 @@ void lpc54_earlyserialinit(void) * Input Parameters: * None * - * Returns Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc54xx/lpc54_spi_master.c b/arch/arm/src/lpc54xx/lpc54_spi_master.c index 665c1a4242dd8e244fbf76077209dfe8f64d5bd6..443bcb3333cea4e87e32197607f64fe332da0871 100644 --- a/arch/arm/src/lpc54xx/lpc54_spi_master.c +++ b/arch/arm/src/lpc54xx/lpc54_spi_master.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc54xx/lpc54_spi.c * - * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,6 +33,16 @@ * ****************************************************************************/ +/* TODO: + * + * - There are no interrupt driven transfers, only polled. I don't + * consider this a significant problem because of the higher rate that + * would be necessary for interrupt driven transfers. + * - Integrate DMA transfers. This is fairly important because it can + * a) improve the data transfer rates and b) free the CPU when the + * SPI driver would otherwise be stuck in a tight polling loop. + */ + /**************************************************************************** * Included Files ****************************************************************************/ @@ -59,6 +69,7 @@ #include "chip/lpc54_spi.h" #include "lpc54_config.h" #include "lpc54_enableclk.h" +#include "lpc54_gpio.h" #include "lpc54_spi_master.h" #ifdef HAVE_SPI_MASTER_DEVICE @@ -67,74 +78,166 @@ * Pre-processor Definitions ****************************************************************************/ +#define SPI_DUMMYDATA8 0xff +#define SPI_DUMMYDATA16 0xffff + +#define SPI_MINWIDTH 4 +#ifdef CONFIG_LPC54_SPI_WIDEDATA +# define SPI_MAXWIDTH 16 +#else +# define SPI_MAXWIDTH 8 +#endif + /**************************************************************************** * Private Types ****************************************************************************/ -/* This structure descibes the state of the SSP driver */ +/* This structure describes the state of the SSP driver */ struct lpc54_spidev_s { - struct spi_dev_s dev; /* Externally visible part of the SPI interface */ - uintptr_t base; /* Base address of Flexcomm registers */ - sem_t exclsem; /* Held while chip is selected for mutual exclusion */ - uint32_t fclock; /* Flexcomm function clock frequency */ - uint32_t frequency; /* Requested clock frequency */ - uint32_t actual; /* Actual clock frequency */ - uint16_t irq; /* Flexcomm IRQ number */ - uint8_t nbits; /* Width of word in bits (8 to 16) */ - uint8_t mode; /* Mode 0,1,2,3 */ + struct spi_dev_s dev; /* Externally visible part of the SPI interface */ + uintptr_t base; /* Base address of Flexcomm registers */ + sem_t exclsem; /* Held while chip is selected for mutual exclusion */ + uint32_t fclock; /* Flexcomm function clock frequency */ + uint32_t frequency; /* Requested clock frequency */ + uint32_t actual; /* Actual clock frequency */ + uint16_t irq; /* Flexcomm IRQ number */ + uint8_t nbits; /* Width of word in bits (SPI_MINWIDTH to SPI_MAXWIDTH) */ + uint8_t mode; /* Mode 0,1,2,3 */ +}; + +/* These structures describes the Rx side of an 8- or 16-bit SPI data + * exchange. + */ + +struct lpc54_rxtransfer8_s +{ + FAR uint8_t *rxptr; /* Pointer into receive buffer */ + unsigned int remaining; /* Bytes remaining in the receive buffer */ + unsigned int expected; /* Bytes expected to be received */ +}; + +#ifdef CONFIG_LPC54_SPI_WIDEDATA +struct lpc54_rxtransfer16_s +{ + FAR uint16_t *rxptr; /* Pointer into receive buffer */ + unsigned int remaining; /* Hwords remaining in the receive buffer */ + unsigned int expected; /* Hwords expected to be received */ +}; +#endif + +/* These structures describes the Tx side of an 8- or 16-bit SPI data + * exchange. + */ + +struct lpc54_txtransfer8_s +{ + uint32_t txctrl; /* Tx control bits */ + FAR const uint8_t *txptr; /* Pointer into transmit buffer */ + unsigned int remaining; /* Bytes remaining in the transmit buffer */ +}; + +#ifdef CONFIG_LPC54_SPI_WIDEDATA +struct lpc54_txtransfer16_s +{ + uint32_t txctrl; /* Tx control bits */ + FAR const uint16_t *txptr; /* Pointer into transmit buffer */ + unsigned int remaining; /* Hwords remaining in the transmit buffer */ +}; +#endif + +struct lpc54_txdummy_s +{ + uint32_t txctrl; /* Tx control bits */ + unsigned int remaining; /* Bytes remaining in the transmit buffer */ }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static inline bool lpc54_spi_16bitmode(FAR struct lpc54_spidev_s *priv); +/* Transfer helpers */ + +static inline unsigned int lpc54_spi_fifodepth(FAR struct lpc54_spidev_s *priv); +static inline bool lpc54_spi_txavailable(FAR struct lpc54_spidev_s *priv); +static inline bool lpc54_spi_rxavailable(FAR struct lpc54_spidev_s *priv); + +static void lpc54_spi_resetfifos(FAR struct lpc54_spidev_s *priv); +static void lpc54_spi_rxtransfer8(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_rxtransfer8_s *xfr); +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_rxtransfer16(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_rxtransfer16_s *xfr); +#endif +static bool lpc54_spi_txtransfer8(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_txtransfer8_s *xfr); +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static bool lpc54_spi_txtransfer16(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_txtransfer16_s *xfr); +#endif +static bool lpc54_spi_txdummy(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_txdummy_s *xfr); +#ifdef CONFIG_SPI_EXCHANGE +static void lpc54_spi_exchange8(FAR struct lpc54_spidev_s *priv, + FAR const void *txbuffer, FAR void *rxbuffer, + size_t nwords); +#ifdefCONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_exchange16(FAR struct lpc54_spidev_s *priv, + FAR const void *txbuffer, FAR void *rxbuffer, + size_t nwords); +#endif +#endif +static void lpc54_spi_sndblock8(FAR struct lpc54_spidev_s *priv, + FAR const void *buffer, size_t nwords); +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_sndblock16(FAR struct lpc54_spidev_s *priv, + FAR const void *buffer, size_t nwords); +#endif +static void lpc54_spi_recvblock8(FAR struct lpc54_spidev_s *priv, + FAR void *buffer, size_t nwords); +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_recvblock16(FAR struct lpc54_spidev_s *priv, + FAR void *buffer, size_t nwords); +#endif /* SPI methods */ static int lpc54_spi_lock(FAR struct spi_dev_s *dev, bool lock); -static void lpc54_spi_select(FAR struct spi_dev_s *dev, uint32_t devid, - bool selected); static uint32_t lpc54_spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency); static void lpc54_spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode); static void lpc54_spi_setbits(FAR struct spi_dev_s *dev, int nbits); static uint16_t lpc54_spi_send(FAR struct spi_dev_s *dev, uint16_t ch); -#ifdef CONFIG_LPC54_SPI_MASTER_DMA -static void lpc54_spi_exchange_nodma(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, FAR void *rxbuffer, - size_t nwords) -#endif +#ifdef CONFIG_SPI_EXCHANGE static void lpc54_spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, FAR void *rxbuffer, size_t nwords); -#ifndef CONFIG_SPI_EXCHANGE +#endif static void lpc54_spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords); static void lpc54_spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords); -#endif /**************************************************************************** * Private Data ****************************************************************************/ -static const struct spi_ops_s g_spi_ops = +#ifdef CONFIG_LPC54_SPI0_MASTER +static const struct spi_ops_s g_spi0_ops = { .lock = lpc54_spi_lock, - .select = lpc54_spiselect, + .select = lpc54_spi0_select, /* Provided externally */ .setfrequency = lpc54_spi_setfrequency, .setmode = lpc54_spi_setmode, .setbits = lpc54_spi_setbits, #ifdef CONFIG_SPI_HWFEATURES - .hwfeatures = 0, /* Not supported */ + .hwfeatures = NULL, /* Not supported */ #endif - .status = lpc54_spistatus, + .status = lpc54_spi0_status, /* Provided externally */ #ifdef CONFIG_SPI_CMDDATA - .cmddata = lpc54_spicmddata, + .cmddata = lpc54_spi0_cmddata, /* Provided externally */ #endif .send = lpc54_spi_send, #ifdef CONFIG_SPI_EXCHANGE @@ -144,101 +247,1003 @@ static const struct spi_ops_s g_spi_ops = .recvblock = lpc54_spi_recvblock, #endif #ifdef CONFIG_SPI_CALLBACK - .registercallback = lpc54_spiregister, /* Provided externally */ + .registercallback = lpc54_spi0_register, /* Provided externally */ #else - .registercallback = 0, /* Not implemented */ + .registercallback = NULL, /* Not implemented */ #endif }; -#ifdef CONFIG_LPC54_I2C0_MASTER static struct lpc54_spidev_s g_spi0_dev; #endif -#ifdef CONFIG_LPC54_I2C1_MASTER + +#ifdef CONFIG_LPC54_SPI1_MASTER +static const struct spi_ops_s g_spi1_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi1_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi1_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi1_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi1_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi1_dev; #endif -#ifdef CONFIG_LPC54_I2C2_MASTER + +#ifdef CONFIG_LPC54_SPI2_MASTER +static const struct spi_ops_s g_spi2_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi2_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi2_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi2_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi2_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi2_dev; #endif -#ifdef CONFIG_LPC54_I2C3_MASTER + +#ifdef CONFIG_LPC54_SPI3_MASTER +static const struct spi_ops_s g_spi3_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi3_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi3_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi3_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi3_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi3_dev; #endif -#ifdef CONFIG_LPC54_I2C4_MASTER + +#ifdef CONFIG_LPC54_SPI4_MASTER +static const struct spi_ops_s g_spi4_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi4_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi4_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi4_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi4_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi4_dev; #endif -#ifdef CONFIG_LPC54_I2C5_MASTER + +#ifdef CONFIG_LPC54_SPI5_MASTER +static const struct spi_ops_s g_spi5_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi5_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi5_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi5_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi5_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi5_dev; #endif -#ifdef CONFIG_LPC54_I2C6_MASTER + +#ifdef CONFIG_LPC54_SPI6_MASTER +static const struct spi_ops_s g_spi6_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi6_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi6_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi6_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi6_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi6_dev; #endif -#ifdef CONFIG_LPC54_I2C7_MASTER + +#ifdef CONFIG_LPC54_SPI7_MASTER +static const struct spi_ops_s g_spi7_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi7_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi7_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi7_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi7_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi7_dev; #endif -#ifdef CONFIG_LPC54_I2C8_MASTER + +#ifdef CONFIG_LPC54_SPI8_MASTER +static const struct spi_ops_s g_spi8_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi8_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi8_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi8_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi8_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi8_dev; #endif -#ifdef CONFIG_LPC54_I2C9_MASTER + +#ifdef CONFIG_LPC54_SPI9_MASTER +static const struct spi_ops_s g_spi9_ops = +{ + .lock = lpc54_spi_lock, + .select = lpc54_spi9_select, /* Provided externally */ + .setfrequency = lpc54_spi_setfrequency, + .setmode = lpc54_spi_setmode, + .setbits = lpc54_spi_setbits, +#ifdef CONFIG_SPI_HWFEATURES + .hwfeatures = NULL, /* Not supported */ +#endif + .status = lpc54_spi9_status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc54_spi9_cmddata, /* Provided externally */ +#endif + .send = lpc54_spi_send, +#ifdef CONFIG_SPI_EXCHANGE + .exchange = lpc54_spi_exchange, +#else + .sndblock = lpc54_spi_sndblock, + .recvblock = lpc54_spi_recvblock, +#endif +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc54_spi9_register, /* Provided externally */ +#else + .registercallback = NULL, /* Not implemented */ +#endif +}; + static struct lpc54_spidev_s g_spi9_dev; #endif -/**************************************************************************** - * Private Functions - ****************************************************************************/ +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lpc54_spi_putreg + * + * Description: + * Write a value to a register at the offset from the Flexcomm base. + * + ****************************************************************************/ + +static inline void lpc54_spi_putreg(struct lpc54_spidev_s *priv, + unsigned int regoffset, uint32_t regval) +{ + putreg32(regval, priv->base + regoffset); +} + +/**************************************************************************** + * Name: lpc54_spi_getreg + * + * Description: + * Read the content of a register at the offset from the Flexcomm base. + * + ****************************************************************************/ + +static inline uint32_t lpc54_spi_getreg(struct lpc54_spidev_s *priv, + unsigned int regoffset) +{ + return getreg32(priv->base + regoffset); +} + +/**************************************************************************** + * Name: lpc54_spi_fifodepth + * + * Description: + * Return the depth of the SPI FIFOs. This is a constant value and could + * be hard coded. + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * The FIFO depth in words of the configured bit width. + * + ****************************************************************************/ + +static inline unsigned int lpc54_spi_fifodepth(FAR struct lpc54_spidev_s *priv) +{ + uint32_t regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOCFG_OFFSET); + return ((regval & SPI_FIFOCFG_SIZE_MASK) >> SPI_FIFOCFG_SIZE_SHIFT) << 3; +} + +/**************************************************************************** + * Name: lpc54_spi_txavailable + * + * Description: + * Return true if the Tx FIFO is not full. + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * true: Tx FIFO is not full. + * + ****************************************************************************/ + +static inline bool lpc54_spi_txavailable(FAR struct lpc54_spidev_s *priv) +{ + uint32_t regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOSTAT_OFFSET); + return ((regval & SPI_FIFOSTAT_TXNOTFULL) != 0); +} + +/**************************************************************************** + * Name: lpc54_spi_rxavailable + * + * Description: + * Return true if the Rx FIFO is not empty. + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * true: Rx FIFO is not empty. + * + ****************************************************************************/ + +static inline bool lpc54_spi_rxavailable(FAR struct lpc54_spidev_s *priv) +{ + uint32_t regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOSTAT_OFFSET); + return ((regval & SPI_FIFOSTAT_RXNOTEMPTY) != 0); +} + +/**************************************************************************** + * Name: lpc54_spi_rxdiscard + * + * Description: + * Read and discard the data until the Rx FIFO is empty. + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void lpc54_spi_rxdiscard(FAR struct lpc54_spidev_s *priv) +{ + while (lpc54_spi_rxavailable(priv)) + { + (void)lpc54_spi_getreg(priv, LPC54_SPI_FIFORD_OFFSET); + } +} + +/**************************************************************************** + * Name: lpc54_spi_resetfifos + * + * Description: + * Clear Tx/Rx errors and empty FIFOs. + * + * Input Parameters: + * priv - Device-specific state data + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void lpc54_spi_resetfifos(FAR struct lpc54_spidev_s *priv) +{ + uint32_t regval; + + /* Clear Tx/Rx errors and empty FIFOs */ + + regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOCFG_OFFSET); + regval |= (SPI_FIFOCFG_EMPTYTX | SPI_FIFOCFG_EMPTYRX); + lpc54_spi_putreg(priv, LPC54_SPI_FIFOCFG_OFFSET, regval); + + regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOSTAT_OFFSET); + regval |= (SPI_FIFOSTAT_TXERR | SPI_FIFOSTAT_RXERR); + lpc54_spi_putreg(priv, LPC54_SPI_FIFOSTAT_OFFSET, regval); +} + +/**************************************************************************** + * Name: lpc54_spi_rxtransfer8 and lpc54_spi_rxtransfer16 + * + * Description: + * Receive one 8- or 16-bit value from the selected SPI device. + * + * Input Parameters: + * priv - Device-specific state data + * xfr - Describes the Rx transfer + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void lpc54_spi_rxtransfer8(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_rxtransfer8_s *xfr) +{ + /* Read one byte if available and expected */ + + if (lpc54_spi_rxavailable(priv)) + { + /* There is something in the Rx FIFO to be read. Are we expecting + * data in the Rx FIFO? Is there space available in the Rx buffer? + */ + + if (xfr->expected == 0 || xfr->remaining == 0) + { + /* No.. then just read and discard the data until the Rx FIFO is empty */ + + lpc54_spi_rxdiscard(priv); + xfr->expected = 0; + } + else + { + /* Read and transfer one byte */ + + *xfr->rxptr = lpc54_spi_getreg(priv, LPC54_SPI_FIFORD_OFFSET); + + /* Update pointers and counts */ + + xfr->rxptr++; + xfr->remaining--; + xfr->expected--; + } + } +} + +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_rxtransfer16(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_rxtransfer16_s *xfr) +{ + /* Read one HWord if available and expected */ + + if (lpc54_spi_rxavailable(priv)) + { + /* There is something in the Rx FIFO to be read. Are we expecting + * data in the Rx FIFO? Is there space available in the Rx buffer? + */ + + if (xfr->expected == 0 || xfr->remaining == 0) + { + /* No.. then just read and discard the data until the Rx FIFO + * is empty. + */ + + lpc54_spi_rxdiscard(priv); + xfr->expected = 0; + } + else + { + /* Read and transfer HWord */ + + *xfr->rxptr = lpc54_spi_getreg(priv, LPC54_SPI_FIFORD_OFFSET); + + /* Update pointers and counts */ + + xfr->rxptr++; + xfr->remaining--; + xfr->expected--; + } + } +} +#endif + +/**************************************************************************** + * Name: lpc54_spi_txtransfer8 and lpc54_spi_txtransfer16 + * + * Description: + * Send one 8- or 16-bit value to the selected SPI device. + * + * Input Parameters: + * priv - Device-specific state data + * xfr - Describes the Tx transfer + * + * Returned Value: + * true: The value was added to the TxFIFO + * + ****************************************************************************/ + +static bool lpc54_spi_txtransfer8(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_txtransfer8_s *xfr) +{ + uint32_t regval; + + /* Transmit if txFIFO is not full and there is more Tx data to be sent */ + + if (lpc54_spi_txavailable(priv) && xfr->remaining > 0) + { + /* Get the next byte to be sent */ + + regval = *xfr->txptr; + + /* And send it */ + + regval |= xfr->txctrl; + lpc54_spi_putreg(priv, LPC54_SPI_FIFOWR_OFFSET, regval); + + /* Update pointers and counts */ + + xfr->txptr++; + xfr->remaining--; + + return true; + } + + return false; +} + +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static bool lpc54_spi_txtransfer16(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_txtransfer16_s *xfr) +{ + uint32_t regval; + + /* Transmit if txFIFO is not full and there is more Tx data to be sent */ + + if (lpc54_spi_txavailable(priv) && xfr->remaining > 0) + { + /* Get the next byte to be sent */ + + regval = *xfr->txptr; + + /* And send it */ + + regval |= xfr->txctrl; + lpc54_spi_putreg(priv, LPC54_SPI_FIFOWR_OFFSET, regval); + + /* Update pointers and counts */ + + xfr->txptr++; + xfr->remaining--; + + return true; + } + + return false; +} +#endif + +/**************************************************************************** + * Name: lpc54_spi_txdummy + * + * Description: + * Send dummy Tx data when we really only care about the Rx data. + * + * Input Parameters: + * priv - Device-specific state data + * xfr - Describes the Tx transfer + * + * Returned Value: + * true: The dummy value was added to the TxFIFO + * + ****************************************************************************/ + +static bool lpc54_spi_txdummy(FAR struct lpc54_spidev_s *priv, + FAR struct lpc54_txdummy_s *xfr) +{ + /* Transmit if txFIFO is not full and there is more Tx data to be sent */ + + if (lpc54_spi_txavailable(priv) && xfr->remaining > 0) + { + /* Send the dummy data */ + + lpc54_spi_putreg(priv, LPC54_SPI_FIFOWR_OFFSET, xfr->txctrl); + + /* Update counts */ + + xfr->remaining--; + return true; + } + + return false; +} + +/**************************************************************************** + * Name: lpc54_spi_exchange8 and lpc54_spi_exchange16 + * + * Description: + * Implements the SPI exchange method for the case of 8- and 16-bit transfers. + * + * Input Parameters: + * priv - Device-specific state data + * txbuffer - A pointer to the buffer of data to be sent + * rxbuffer - A pointer to a buffer in which to receive data + * nwords - the length of data to be exchanged in units of words. + * The wordsize is determined by the number of bits-per-word + * selected for the SPI interface. If nbits <= 8, the data is + * packed into uint8_t's; if nbits >8, the data is packed into + * uint16_t's + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_SPI_EXCHANGE +static void lpc54_spi_exchange8(FAR struct lpc54_spidev_s *priv, + FAR const void *txbuffer, FAR void *rxbuffer, + size_t nwords) +{ + struct lpc54_rxtransfer8_s rxtransfer; + struct lpc54_txtransfer8_s txtransfer; + unsigned int depth; + + DEBUGASSERT(rxbuffer != NULL && txbuffer != NULL); + + /* Get the FIFO depth */ + + depth = lpc54_spi_fifodepth(priv); + + /* Set up the transfer data */ + + txtransfer.txctrl = SPI_FIFOWR_LEN(priv->nbits) | SPI_FIFOWR_TXSSELN_ALL; + txtransfer.txptr = (FAR uint8_t *)txbuffer; + txtransfer.remaining = nwords; + rxtransfer.rxptr = (FAR uint8_t *)rxbuffer; + rxtransfer.remaining = nwords; + rxtransfer.expected = 0; + + /* Clear Tx/Rx errors and empty FIFOs */ + + lpc54_spi_resetfifos(priv); + + /* Loop until all Tx data has been sent and until all Rx data has been + * received. + */ + + while (txtransfer.remaining != 0 || rxtransfer.remaining != 0) + { + /* Transfer one byte from the Rx FIFO to the caller's Rx buffer */ + + lpc54_spi_rxtransfer8(priv, &rxtransfer); + + /* If sending another byte would exceed the capacity of the Rx FIFO + * then read-only until there space freed. + */ + + if (rxtransfer.expected < depth) + { + /* Attempt to transfer one byte from the caller's Tx buffer to + * the Tx FIFO. + */ + + if (lpc54_spi_txtransfer8(priv, &txtransfer)) + { + /* Increment the Rx expected count if successful */ + + rxtransfer.expected++; + } + } + } +} +#endif /* CONFIG_SPI_EXCHANGE */ + +#if defined(CONFIG_SPI_EXCHANGE) && defined(CONFIG_LPC54_SPI_WIDEDATA) +static void lpc54_spi_exchange16(FAR struct lpc54_spidev_s *priv, + FAR const void *txbuffer, FAR void *rxbuffer, + size_t nwords) +{ + struct lpc54_rxtransfer16_s rxtransfer; + struct lpc54_txtransfer16_s txtransfer; + uint32_t regval; + unsigned int depth; + + DEBUGASSERT(rxbuffer != NULL && ((uintptr_t)rxbuffer & 1) == 0); + DEBUGASSERT(txbuffer != NULL && ((uintptr_t)txbuffer & 1) == 0); + + /* Get the FIFO depth */ + + depth = lpc54_spi_fifodepth(priv); -/**************************************************************************** - * Name: lpc54_spi_putreg - * - * Description: - * Write a value to a register at the offset from the Flexcomm base. - * - ****************************************************************************/ + /* Set up the transfer data */ -static inline void lpc54_spi_putreg(struct lpc54_spidev_s *priv, - unsigned int regoffset, uint32_t regval) -{ - putreg32(value, priv->base + regoffset); + txtransfer.txctrl = SPI_FIFOWR_LEN(priv->nbits) | SPI_FIFOWR_TXSSELN_ALL; + txtransfer.txptr = (FAR uint16_t *)txbuffer; + txtransfer.remaining = nwords; + rxtransfer.rxptr = (FAR uint16_t *)rxbuffer; + rxtransfer.remaining = nwords; + rxtransfer.expected = 0; + + /* Clear Tx/Rx errors and empty FIFOs */ + + lpc54_spi_resetfifos(priv); + + /* Loop until all Tx data has been sent and until all Rx data has been + * received. + */ + + while (txtransfer.remaining || rxtransfer.remaining || rxtransfer.expected) + { + /* Transfer one HWord from the Rx FIFO to the caller's Rx buffer */ + + lpc54_spi_rxtransfer16(priv, &rxtransfer); + + /* If sending another byte would exceed the capacity of the Rx FIFO + * then read-only until there space freed. + */ + + if (rxtransfer.expected < depth) + { + /* Attempt to send one more byte */ + + if (lpc54_spi_txtransfer16(priv, &txtransfer)) + { + /* Increment the Rx expected count if successful */ + + rxtransfer.expected++; + } + } + } } +#endif /* CONFIG_SPI_EXCHANGE && CONFIG_LPC54_SPI_WIDEDATA */ /**************************************************************************** - * Name: lpc54_spi_gettreg + * Name: lpc54_spi_sndblock8 and lpc54_spi_sndblock16 * * Description: - * Read the content of a register at the offset from the Flexcomm base. + * Implements the SPI sndblock method for the case of 8- and 16-bit + * transfers. + * + * Input Parameters: + * priv - Device-specific state data + * buffer - A pointer to the buffer of data to be sent + * nwords - the length of data to send from the buffer in number of words. + * The wordsize is determined by the number of bits-per-word + * selected for the SPI interface. If nbits <= 8, the data is + * packed into uint8_t's; if nbits >8, the data is packed into + * uint16_t's + * + * Returned Value: + * None * ****************************************************************************/ -static inline void lpc54_spi_gettreg(struct lpc54_spidev_s *priv, - unsigned int regoffset) +static void lpc54_spi_sndblock8(FAR struct lpc54_spidev_s *priv, + FAR const void *buffer, size_t nwords) { - return getreg32(priv->base + regoffset); + struct lpc54_txtransfer8_s txtransfer; + + DEBUGASSERT(buffer != NULL); + + /* Set up the transfer data. NOTE that we are ignoring returned Rx data */ + + txtransfer.txctrl = SPI_FIFOWR_RXIGNORE | SPI_FIFOWR_LEN(priv->nbits) | + SPI_FIFOWR_TXSSELN_ALL; + txtransfer.txptr = (FAR uint8_t *)buffer; + txtransfer.remaining = nwords; + + /* Clear Tx/Rx errors and empty FIFOs */ + + lpc54_spi_resetfifos(priv); + + /* Loop until all Tx data has been sent */ + + while (txtransfer.remaining != 0) + { + /* Attempt to transfer one byte from the caller's Tx buffer to the + * Tx FIFO. + */ + + (void)lpc54_spi_txtransfer8(priv, &txtransfer); + } +} + +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_sndblock16(FAR struct lpc54_spidev_s *priv, + FAR const void *buffer, size_t nwords) +{ + struct lpc54_txtransfer16_s txtransfer; + + DEBUGASSERT(buffer != NULL); + + /* Set up the transfer data. NOTE that we are ignoring returned Rx data */ + + txtransfer.txctrl = SPI_FIFOWR_RXIGNORE | SPI_FIFOWR_LEN(priv->nbits) | + SPI_FIFOWR_TXSSELN_ALL; + txtransfer.txptr = (FAR uint16_t *)buffer; + txtransfer.remaining = nwords; + + /* Clear Tx/Rx errors and empty FIFOs */ + + lpc54_spi_resetfifos(priv); + + /* Loop until all Tx data has been sent and until all Rx data has been + * received. + */ + + while (txtransfer.remaining != 0) + { + /* Attempt to transfer one byte from the caller's Tx buffer to the + * Tx FIFO. + */ + + lpc54_spi_txtransfer16(priv, &txtransfer); + } } +#endif /*CONFIG_LPC54_SPI_WIDEDATA */ /**************************************************************************** - * Name: lpc54_spi_16bitmode + * Name: lpc54_spi_recvblock8 and lpc54_spi_recvblock16 * * Description: - * Check if the SPI is operating in > 8-bit mode (16-bit accesses) + * Implements the SPI recvblock method for the case of 8- and 16-bit + * transfers. * * Input Parameters: - * priv - Device-specific state data + * priv - Device-specific state data + * buffer - A pointer to the buffer in which to receive data + * nwords - the length of data that can be received in the buffer in + * number of words. The wordsize is determined by the number of + * bits-per-word selected for the SPI interface. If nbits <= 8, + * the data is packed into uint8_t's; if nbits >8, the data is + * packed into uint16_t's * * Returned Value: - * true: 16-bit mode, false: 8-bit mode + * None * ****************************************************************************/ -static inline bool lpc54_spi_16bitmode(FAR struct lpc54_spidev_s *priv) +static void lpc54_spi_recvblock8(FAR struct lpc54_spidev_s *priv, + FAR void *buffer, size_t nwords) { -#warning Missing logic - return false; + struct lpc54_rxtransfer8_s rxtransfer; + struct lpc54_txdummy_s txtransfer; + unsigned int depth; + + DEBUGASSERT(buffer != NULL); + + /* Get the FIFO depth */ + + depth = lpc54_spi_fifodepth(priv); + + /* Set up the transfer data */ + + txtransfer.txctrl = SPI_DUMMYDATA8 | SPI_FIFOWR_LEN(priv->nbits) | + SPI_FIFOWR_TXSSELN_ALL; + txtransfer.remaining = nwords; + rxtransfer.rxptr = (FAR uint8_t *)buffer; + rxtransfer.remaining = nwords; + rxtransfer.expected = 0; + + /* Clear Tx/Rx errors and empty FIFOs */ + + lpc54_spi_resetfifos(priv); + + /* Loop until all Tx data has been sent and until all Rx data has been + * received. + */ + + while (txtransfer.remaining != 0|| rxtransfer.remaining != 0) + { + /* Transfer one byte from the Rx FIFO to the caller's Rx buffer */ + + lpc54_spi_rxtransfer8(priv, &rxtransfer); + + /* If sending another byte would exceed the capacity of the Rx FIFO + * then read-only until there space freed. + */ + + if (rxtransfer.expected < depth) + { + /* Attempt to transfer one dummy byte to the Tx FIFO. */ + + if (lpc54_spi_txdummy(priv, &txtransfer)) + { + /* Increment the Rx expected count if successful */ + + rxtransfer.expected++; + } + } + } +} + +#ifdef CONFIG_LPC54_SPI_WIDEDATA +static void lpc54_spi_recvblock16(FAR struct lpc54_spidev_s *priv, + FAR void *buffer, size_t nwords) +{ + struct lpc54_rxtransfer16_s rxtransfer; + struct lpc54_txdummy_s txtransfer; + unsigned int depth; + + DEBUGASSERT(buffer != NULL); + + /* Get the FIFO depth */ + + depth = lpc54_spi_fifodepth(priv); + + /* Set up the transfer data */ + + txtransfer.txctrl = SPI_DUMMYDATA16 | SPI_FIFOWR_LEN(priv->nbits) | + SPI_FIFOWR_TXSSELN_ALL; + txtransfer.remaining = nwords; + rxtransfer.rxptr = (FAR uint16_t *)rxbuffer; + rxtransfer.remaining = nwords; + rxtransfer.expected = 0; + + /* Clear Tx/Rx errors and empty FIFOs */ + + lpc54_spi_resetfifos(priv); + + /* Loop until all Tx data has been sent and until all Rx data has been + * received. + */ + + while (txtransfer.remaining || rxtransfer.remaining || rxtransfer.expected) + { + /* Transfer one HWord from the Rx FIFO to the caller's Rx buffer */ + + lpc54_spi_rxtransfer16(priv, &rxtransfer); + + /* If sending another byte would exceed the capacity of the Rx FIFO + * then read-only until there space freed. + */ + + if (rxtransfer.expected < depth) + { + /* Attempt to transfer one dummy HWord to the Tx FIFO. */ + + if (lpc54_spi_txdummy(priv, &txtransfer)) + { + /* Increment the Rx expected count if successful */ + + rxtransfer.expected++; + } + } + } } +#endif /* CONFIG_LPC54_SPI_WIDEDATA */ /**************************************************************************** * Name: lpc54_spi_lock * * Description: - * On SPI busses where there are multiple devices, it will be necessary to - * lock SPI to have exclusive access to the busses for a sequence of + * On SPI buses where there are multiple devices, it will be necessary to + * lock SPI to have exclusive access to the buses for a sequence of * transfers. The bus should be locked before the chip is selected. After * locking the SPI bus, the caller should then also call the setfrequency, * setbits, and setmode methods to make sure that the SPI is properly @@ -303,11 +1308,15 @@ static uint32_t lpc54_spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency) { FAR struct lpc54_spidev_s *priv = (FAR struct lpc54_spidev_s *)dev; + uint32_t divider; uint32_t actual; + uint32_t regval; - /* Check if the requested frequence is the same as the frequency selection */ + /* Check if the requested frequency is the same as the current frequency + * selection. + */ - DEBUGASSERT(priv && frequency <= priv->fclock / 2); + DEBUGASSERT(priv != NULL && frequency <= priv->fclock / 2); if (priv->frequency == frequency) { @@ -317,7 +1326,21 @@ static uint32_t lpc54_spi_setfrequency(FAR struct spi_dev_s *dev, } /* Set the new SPI frequency */ -#warning Missing logic + + divider = priv->fclock / frequency; + if (divider > 0x10000) + { + divider = 0x10000; + } + + regval = lpc54_spi_getreg(priv, LPC54_SPI_DIV_OFFSET); + regval &= ~SPI_DIV_MASK; + regval |= SPI_DIV(divider); + lpc54_spi_putreg(priv, LPC54_SPI_DIV_OFFSET, regval); + + /* Calculate the actual frequency */ + + actual = priv->fclock / divider; /* Save the frequency setting */ @@ -354,24 +1377,25 @@ static void lpc54_spi_setmode(FAR struct spi_dev_s *dev, if (mode != priv->mode) { /* Yes... Set the new mode */ -#warning Missing logic + + regval = lpc54_spi_getreg(priv, LPC54_SPI_CFG_OFFSET); + regval &= ~(SPI_CFG_CPHA | SPI_CFG_CPOL); switch (mode) { case SPIDEV_MODE0: /* CPOL=0; CPHA=0 */ -#warning Missing logic break; case SPIDEV_MODE1: /* CPOL=0; CPHA=1 */ -#warning Missing logic + regval |= SPI_CFG_CPHA; break; case SPIDEV_MODE2: /* CPOL=1; CPHA=0 */ -#warning Missing logic + regval |= SPI_CFG_CPOL; break; case SPIDEV_MODE3: /* CPOL=1; CPHA=1 */ -#warning Missing logic + regval |= (SPI_CFG_CPHA | SPI_CFG_CPOL); break; default: @@ -379,9 +1403,9 @@ static void lpc54_spi_setmode(FAR struct spi_dev_s *dev, return; } -#warning Missing logic + lpc54_spi_putreg(priv, LPC54_SPI_CFG_OFFSET, regval); - /* Save the mode so that subsequent re-configuratins will be faster */ + /* Save the mode so that subsequent re-configurations will be faster */ priv->mode = mode; } @@ -405,18 +1429,14 @@ static void lpc54_spi_setmode(FAR struct spi_dev_s *dev, static void lpc54_spi_setbits(FAR struct spi_dev_s *dev, int nbits) { FAR struct lpc54_spidev_s *priv = (FAR struct lpc54_spidev_s *)dev; - uint32_t regval; - /* Has the number of bits changed? */ + /* The valid range of bit selections is SPI_MINWIDTH through SPI_MAXWIDTH */ - DEBUGASSERT(priv && nbits > 7 && nbits < 17); + DEBUGASSERT(priv != NULL && nbits >= SPI_MINWIDTH && nbits <= SPI_MAXWIDTH); - if (nbits != priv->nbits) + if (nbits >= SPI_MINWIDTH && nbits <= SPI_MAXWIDTH) { - /* Yes... Set the number word width */ -#warning Missing logic - - /* Save the selection so the subsequence re-configurations will be faster */ + /* Save the selection. It will be applied when data is transferred. */ priv->nbits = nbits; } @@ -440,28 +1460,46 @@ static void lpc54_spi_setbits(FAR struct spi_dev_s *dev, int nbits) static uint16_t lpc54_spi_send(FAR struct spi_dev_s *dev, uint16_t wd) { - uint16_t ret; + FAR struct lpc54_spidev_s *priv = (FAR struct lpc54_spidev_s *)dev; + uint32_t regval; - /* Write the data to transmitted to the SPI Data Register */ -#warning Missing logic + DEBUGASSERT(priv != NULL); - /* Read the SPI Status Register again to clear the status bit */ -#warning Missing logic + /* Clear Tx/Rx errors and empty FIFOs */ - return ret; + lpc54_spi_resetfifos(priv); + + /* Send the word. Since we just reset the FIFOs, we assume that the Tx + * FIFO is not full and that the Rx FIFO is empty. + */ + + DEBUGASSERT(lpc54_spi_txavailable(priv) || !lpc54_spi_rxavailable(priv)); + + regval = wd | SPI_FIFOWR_LEN(priv->nbits) | SPI_FIFOWR_TXSSELN_ALL; + lpc54_spi_putreg(priv, LPC54_SPI_FIFOWR_OFFSET, regval); + + /* Wait for the Rx FIFO to become non-empty. */ + + while (!lpc54_spi_rxavailable(priv)) + { + } + + /* Then read and return the value from the Rx FIFO */ + + return (uint16_t)lpc54_spi_getreg(priv, LPC54_SPI_FIFORD_OFFSET); } /**************************************************************************** - * Name: lpc54_spi_exchange (no DMA). aka lpc54_spi_exchange_nodma + * Name: lpc54_spi_exchange * * Description: - * Exchange a block of data on SPI without using DMA + * Exchange a block of data on SPI * * Input Parameters: * dev - Device-specific state data * txbuffer - A pointer to the buffer of data to be sent * rxbuffer - A pointer to a buffer in which to receive data - * nwords - the length of data to be exchaned in units of words. + * nwords - the length of data to be exchanged in units of words. * The wordsize is determined by the number of bits-per-word * selected for the SPI interface. If nbits <= 8, the data is * packed into uint8_t's; if nbits >8, the data is packed into @@ -472,125 +1510,52 @@ static uint16_t lpc54_spi_send(FAR struct spi_dev_s *dev, uint16_t wd) * ****************************************************************************/ -#ifndef CONFIG_LPC54_SPI_MASTER_DMA -static void lpc54_spi_exchange(FAR struct spi_dev_s *dev, +#ifdef CONFIG_SPI_EXCHANGE +static void lpc54_spi_exchange(FAR struct lpc54_spidev_s *priv, FAR const void *txbuffer, FAR void *rxbuffer, size_t nwords) -#else -static void lpc54_spi_exchange_nodma(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, size_t nwords) -#endif { FAR struct lpc54_spidev_s *priv = (FAR struct lpc54_spidev_s *)dev; - DEBUGASSERT(priv && priv->base); - spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", - txbuffer, rxbuffer, nwords); + DEBUGASSERT(priv != NULL); - /* 8- or 16-bit mode? */ + /* If there is no data sink, then handle this transfer with + * lpc54_spi_sndblock(). + */ - if (lpc54_spi_16bitmode(priv)) + if (rxbuffer == NULL) { - /* 16-bit mode */ - - const uint16_t *src = (const uint16_t *)txbuffer; - uint16_t *dest = (uint16_t *)rxbuffer; - uint16_t word; - - while (nwords-- > 0) - { - /* Get the next word to write. Is there a source buffer? */ - - if (src) - { - word = *src++; - } - else - { - word = 0xffff; - } - - /* Exchange one word */ - - word = spi_send(dev, word); - - /* Is there a buffer to receive the return value? */ - - if (dest) - { - *dest++ = word; - } - } + lpc54_spi_sndblock(priv, txbuffer, nwords) } - else - { - /* 8-bit mode */ - - const uint8_t *src = (const uint8_t *)txbuffer; - uint8_t *dest = (uint8_t *)rxbuffer; - uint8_t word; - - while (nwords-- > 0) - { - /* Get the next word to write. Is there a source buffer? */ - - if (src) - { - word = *src++; - } - else - { - word = 0xff; - } - /* Exchange one word */ + /* If there is no data source, then handle this transfer with + * lpc54_spi_recvblock(). + */ - word = (uint8_t)spi_send(dev, (uint16_t)word); + else if (txbuffer == NULL) + { + lpc54_spi_recvblock(priv, rxbuffer, nwords) + } - /* Is there a buffer to receive the return value? */ +#ifdef CONFIG_LPC54_SPI_WIDEDATA + /* If the data with is > 8-bits, then handle this transfer with + * lpc54_spi_exchange16(). + */ - if (dest) - { - *dest++ = word; - } - } + else if (priv->nbits > 8) + { + lpc54_spi_exchange16(priv, txbuffer, rxbuffer, nwords); } -} - -/**************************************************************************** - * Name: lpc54_spi_exchange (no DMA). aka lpc54_spi_exchange_nodma - * - * Description: - * Exchange a block of data on SPI without using DMA - * - * Input Parameters: - * dev - Device-specific state data - * txbuffer - A pointer to the buffer of data to be sent - * rxbuffer - A pointer to a buffer in which to receive data - * nwords - the length of data to be exchaned in units of words. - * The wordsize is determined by the number of bits-per-word - * selected for the SPI interface. If nbits <= 8, the data is - * packed into uint8_t's; if nbits >8, the data is packed into - * uint16_t's - * - * Returned Value: - * None - * - ****************************************************************************/ +#endif -#ifdef CONFIG_LPC54_SPI_MASTER_DMA -static void lpc54_spi_exchange(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, FAR void *rxbuffer, - size_t nwords) -{ - /* If the transfer is small, then perform the exchange without using DMA. */ -#warning Missing logic + /* Otherwise, let lpc54_spi_exchange8() do the job */ - /* Otherwise, use DMA */ -#warning Missing logic + else if (priv->nbits > 8) + { + lpc54_spi_exchange8(priv, txbuffer, rxbuffer, nwords); + } } -#endif /* CONFIG_LPC54_SPI_MASTER_DMA */ +#endif /* CONFIG_SPI_EXCHANGE */ /**************************************************************************** * Name: lpc54_spi_sndblock @@ -615,8 +1580,28 @@ static void lpc54_spi_exchange(FAR struct spi_dev_s *dev, static void lpc54_spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords) { - spiinfo("txbuffer=%p nwords=%d\n", txbuffer, nwords); - return lpc54_spi_exchange(dev, txbuffer, NULL, nwords); + FAR struct lpc54_spidev_s *priv = (FAR struct lpc54_spidev_s *)dev; + + spiinfo("buffer=%p nwords=%d\n", buffer, nwords); + DEBUGASSERT(priv != NULL && buffer != NULL); + +#ifdef CONFIG_LPC54_SPI_WIDEDATA + /* If the data with is > 8-bits, then handle this transfer with + * lpc54_spi_sndblock16(). + */ + + if (priv->nbits > 8) + { + lpc54_spi_sndblock16(priv, buffer, nwords); + } + + /* Otherwise, let lpc54_spi_sndblock8() do the job */ + + else if (priv->nbits > 8) +#endif + { + lpc54_spi_sndblock8(priv, buffer, nwords); + } } /**************************************************************************** @@ -627,7 +1612,7 @@ static void lpc54_spi_sndblock(FAR struct spi_dev_s *dev, * * Input Parameters: * dev - Device-specific state data - * buffer - A pointer to the buffer in which to recieve data + * buffer - A pointer to the buffer in which to receive data * nwords - the length of data that can be received in the buffer in * number of words. The wordsize is determined by the number of * bits-per-word selected for the SPI interface. If nbits <= 8, @@ -642,8 +1627,28 @@ static void lpc54_spi_sndblock(FAR struct spi_dev_s *dev, static void lpc54_spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords) { - spiinfo("rxbuffer=%p nwords=%d\n", rxbuffer, nwords); - return lpc54_spi_exchange(dev, NULL, rxbuffer, nwords); + FAR struct lpc54_spidev_s *priv = (FAR struct lpc54_spidev_s *)dev; + + spiinfo("buffer=%p nwords=%d\n", buffer, nwords); + DEBUGASSERT(priv != NULL && buffer != NULL); + +#ifdef CONFIG_LPC54_SPI_WIDEDATA + /* If the data with is > 8-bits, then handle this transfer with + * lpc54_spi_recvblock16(). + */ + + if (priv->nbits > 8) + { + lpc54_spi_recvblock16(priv, buffer, nwords); + } + + /* Otherwise, let lpc54_spi_recvblock8() do the job */ + + else if (priv->nbits > 8) +#endif + { + lpc54_spi_recvblock8(priv, buffer, nwords); + } } /**************************************************************************** @@ -660,7 +1665,7 @@ static void lpc54_spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * ... * 9 - SSP9 * - * Input Parameter: + * Input Parameters: * port - SPI peripheral number. 0..9 * * Returned Value: @@ -672,15 +1677,16 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) { struct lpc54_spidev_s *priv; irqstate_t flags; + uint32_t regval; flags = enter_critical_section(); - /* Configure the requestin SPI peripheral */ + /* Configure the requested SPI peripheral */ /* NOTE: The basic FLEXCOMM initialization was performed in * lpc54_lowputc.c. */ -#ifdef CONFIG_LPC54_I2C0_MASTER +#ifdef CONFIG_LPC54_SPI0_MASTER if (port == 0) { /* Attach 12 MHz clock to FLEXCOMM0 */ @@ -698,14 +1704,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi0_dev; priv->base = LPC54_FLEXCOMM0_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM0; + priv->irq = LPC54_IRQ_FLEXCOMM0; priv->fclock = BOARD_FLEXCOMM0_FCLK; + priv->dev.ops = &g_spi0_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C0_SCK); - lpc54_gpio_config(GPIO_I2C0_MOSI); - lpc54_gpio_config(GPIO_I2C0_MISO); + lpc54_gpio_config(GPIO_SPI0_SCK); + lpc54_gpio_config(GPIO_SPI0_MOSI); + lpc54_gpio_config(GPIO_SPI0_MISO); /* Set up the FLEXCOMM0 function clock */ @@ -713,7 +1720,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C1_MASTER +#ifdef CONFIG_LPC54_SPI1_MASTER if (port == 1) { /* Attach 12 MHz clock to FLEXCOMM1 */ @@ -731,14 +1738,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi1_dev; priv->base = LPC54_FLEXCOMM1_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM1; + priv->irq = LPC54_IRQ_FLEXCOMM1; priv->fclock = BOARD_FLEXCOMM1_FCLK; + priv->dev.ops = &g_spi1_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C1_SCK); - lpc54_gpio_config(GPIO_I2C1_MOSI); - lpc54_gpio_config(GPIO_I2C1_MISO); + lpc54_gpio_config(GPIO_SPI1_SCK); + lpc54_gpio_config(GPIO_SPI1_MOSI); + lpc54_gpio_config(GPIO_SPI1_MISO); /* Set up the FLEXCOMM1 function clock */ @@ -746,7 +1754,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C2_MASTER +#ifdef CONFIG_LPC54_SPI2_MASTER if (port == 2) { /* Attach 12 MHz clock to FLEXCOMM2 */ @@ -764,14 +1772,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi2_dev; priv->base = LPC54_FLEXCOMM2_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM2; + priv->irq = LPC54_IRQ_FLEXCOMM2; priv->fclock = BOARD_FLEXCOMM2_FCLK; + priv->dev.ops = &g_spi2_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C2_SCK); - lpc54_gpio_config(GPIO_I2C2_MOSI); - lpc54_gpio_config(GPIO_I2C2MISO); + lpc54_gpio_config(GPIO_SPI2_SCK); + lpc54_gpio_config(GPIO_SPI2_MOSI); + lpc54_gpio_config(GPIO_SPI2MISO); /* Set up the FLEXCOMM2 function clock */ @@ -779,7 +1788,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C3_MASTER +#ifdef CONFIG_LPC54_SPI3_MASTER if (port == 3) { /* Attach 12 MHz clock to FLEXCOMM3 */ @@ -797,14 +1806,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi3_dev; priv->base = LPC54_FLEXCOMM3_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM3; + priv->irq = LPC54_IRQ_FLEXCOMM3; priv->fclock = BOARD_FLEXCOMM3_FCLK; + priv->dev.ops = &g_spi3_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C3_SCK); - lpc54_gpio_config(GPIO_I2C3_MOSI); - lpc54_gpio_config(GPIO_I2C3_MISO); + lpc54_gpio_config(GPIO_SPI3_SCK); + lpc54_gpio_config(GPIO_SPI3_MOSI); + lpc54_gpio_config(GPIO_SPI3_MISO); /* Set up the FLEXCOMM3 function clock */ @@ -812,7 +1822,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C4_MASTER +#ifdef CONFIG_LPC54_SPI4_MASTER if (port == 4) { /* Attach 12 MHz clock to FLEXCOMM4 */ @@ -830,14 +1840,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi4_dev; priv->base = LPC54_FLEXCOMM4_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM4; + priv->irq = LPC54_IRQ_FLEXCOMM4; priv->fclock = BOARD_FLEXCOMM4_FCLK; + priv->dev.ops = &g_spi4_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C4_SCK); - lpc54_gpio_config(GPIO_I2C4_MOSI); - lpc54_gpio_config(GPIO_I2C4_MISO); + lpc54_gpio_config(GPIO_SPI4_SCK); + lpc54_gpio_config(GPIO_SPI4_MOSI); + lpc54_gpio_config(GPIO_SPI4_MISO); /* Set up the FLEXCOMM4 function clock */ @@ -845,7 +1856,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C5_MASTER +#ifdef CONFIG_LPC54_SPI5_MASTER if (port == 5) { /* Attach 12 MHz clock to FLEXCOMM5 */ @@ -863,14 +1874,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi5_dev; priv->base = LPC54_FLEXCOMM5_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM5; + priv->irq = LPC54_IRQ_FLEXCOMM5; priv->fclock = BOARD_FLEXCOMM5_FCLK; + priv->dev.ops = &g_spi5_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C5_SCK); - lpc54_gpio_config(GPIO_I2C5_MOSI); - lpc54_gpio_config(GPIO_I2C5_MISO); + lpc54_gpio_config(GPIO_SPI5_SCK); + lpc54_gpio_config(GPIO_SPI5_MOSI); + lpc54_gpio_config(GPIO_SPI5_MISO); /* Set up the FLEXCOMM5 function clock */ @@ -878,7 +1890,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C6_MASTER +#ifdef CONFIG_LPC54_SPI6_MASTER if (port == 6) { /* Attach 12 MHz clock to FLEXCOMM6 */ @@ -896,14 +1908,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi6_dev; priv->base = LPC54_FLEXCOMM6_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM6; + priv->irq = LPC54_IRQ_FLEXCOMM6; priv->fclock = BOARD_FLEXCOMM6_FCLK; + priv->dev.ops = &g_spi6_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C6_SCK); - lpc54_gpio_config(GPIO_I2C6_MOSI); - lpc54_gpio_config(GPIO_I2C6_MISO); + lpc54_gpio_config(GPIO_SPI6_SCK); + lpc54_gpio_config(GPIO_SPI6_MOSI); + lpc54_gpio_config(GPIO_SPI6_MISO); /* Set up the FLEXCOMM6 function clock */ @@ -911,7 +1924,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C7_MASTER +#ifdef CONFIG_LPC54_SPI7_MASTER if (port == 7) { /* Attach 12 MHz clock to FLEXCOMM7 */ @@ -929,14 +1942,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi7_dev; priv->base = LPC54_FLEXCOMM7_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM7; + priv->irq = LPC54_IRQ_FLEXCOMM7; priv->fclock = BOARD_FLEXCOMM7_FCLK; + priv->dev.ops = &g_spi7_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C7_SCK); - lpc54_gpio_config(GPIO_I2C7_MOSI); - lpc54_gpio_config(GPIO_I2C7_MISO); + lpc54_gpio_config(GPIO_SPI7_SCK); + lpc54_gpio_config(GPIO_SPI7_MOSI); + lpc54_gpio_config(GPIO_SPI7_MISO); /* Set up the FLEXCOMM7 function clock */ @@ -944,7 +1958,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C8_MASTER +#ifdef CONFIG_LPC54_SPI8_MASTER if (port == 8) { /* Attach 12 MHz clock to FLEXCOMM8 */ @@ -962,14 +1976,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi8_dev; priv->base = LPC54_FLEXCOMM8_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM8; + priv->irq = LPC54_IRQ_FLEXCOMM8; priv->fclock = BOARD_FLEXCOMM8_FCLK; + priv->dev.ops = &g_spi8_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C8_SCK); - lpc54_gpio_config(GPIO_I2C8_MOSI); - lpc54_gpio_config(GPIO_I2C8_MISO); + lpc54_gpio_config(GPIO_SPI8_SCK); + lpc54_gpio_config(GPIO_SPI8_MOSI); + lpc54_gpio_config(GPIO_SPI8_MISO); /* Set up the FLEXCOMM8 function clock */ @@ -977,7 +1992,7 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) } else #endif -#ifdef CONFIG_LPC54_I2C9_MASTER +#ifdef CONFIG_LPC54_SPI9_MASTER if (port == 9) { /* Attach 12 MHz clock to FLEXCOMM9 */ @@ -995,14 +2010,15 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) priv = &g_spi9_dev; priv->base = LPC54_FLEXCOMM9_BASE; - priv->irqid = LPC54_IRQ_FLEXCOMM9; + priv->irq = LPC54_IRQ_FLEXCOMM9; priv->fclock = BOARD_FLEXCOMM9_FCLK; + priv->dev.ops = &g_spi9_ops; /* Configure SPI pins (defined in board.h) */ - lpc54_gpio_config(GPIO_I2C9_SCK); - lpc54_gpio_config(GPIO_I2C9_MOSI); - lpc54_gpio_config(GPIO_I2C9_MISO); + lpc54_gpio_config(GPIO_SPI9_SCK); + lpc54_gpio_config(GPIO_SPI9_MOSI); + lpc54_gpio_config(GPIO_SPI9_MISO); /* Set up the FLEXCOMM9 function clock */ @@ -1016,24 +2032,69 @@ FAR struct spi_dev_s *lpc54_spibus_initialize(int port) leave_critical_section(flags); - /* Enable the SPI peripheral*/ - /* Configure 8-bit SPI mode and master mode */ -#warning Missing logic - /* Set the initial SPI configuration */ priv->frequency = 0; priv->nbits = 8; priv->mode = SPIDEV_MODE0; - priv->dev.ops = &g_spi_ops; + + /* Initialize the SPI semaphore that enforces mutually exclusive access */ + + nxsem_init(&priv->exclsem, 0, 1); + + /* Configure master mode in mode 0: + * + * ENABLE - Disabled for now (0) + * MASTER - Master mode (1) + * LSBF - MSB first (0) + * CPHA/CPOL - Mode 0 (0,0) + * LOOP - Disable loopback mode (0) + * SPOLn - Active low (0,0,0) + */ + + regval = lpc54_spi_getreg(priv, LPC54_SPI_CFG_OFFSET); + regval &= ~(SPI_CFG_ENABLE | SPI_CFG_LSBF | SPI_CFG_CPHA | SPI_CFG_CPOL | + SPI_CFG_LOOP | SPI_CFG_SPOL0 | SPI_CFG_SPOL1 | SPI_CFG_SPOL2 | + SPI_CFG_SPOL3); + regval |= SPI_CFG_MASTER; + lpc54_spi_putreg(priv, LPC54_SPI_CFG_OFFSET, regval); + + /* Enable FIFOs */ + + regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOCFG_OFFSET); + regval |= (SPI_FIFOCFG_EMPTYTX | SPI_FIFOCFG_EMPTYRX); + lpc54_spi_putreg(priv, LPC54_SPI_FIFOCFG_OFFSET, regval); + + regval |= (SPI_FIFOCFG_ENABLETX | SPI_FIFOCFG_ENABLERX); + lpc54_spi_putreg(priv, LPC54_SPI_FIFOCFG_OFFSET, regval); + + /* Set FIFO trigger levels: Empty for Tx FIFO; 1 word for RxFIFO */ + + regval = lpc54_spi_getreg(priv, LPC54_SPI_FIFOCFG_OFFSET); + regval &= ~(SPI_FIFOTRIG_TXLVL_MASK | SPI_FIFOTRIG_RXLVL_MASK); + regval |= (SPI_FIFOTRIG_TXLVL_EMPTY | SPI_FIFOTRIG_RXLVL_NOTEMPTY); + + /* Enable generation of interrupts for selected FIFO trigger levels */ + + regval |= (SPI_FIFOTRIG_TXLVLENA | SPI_FIFOTRIG_RXLVLENA); + lpc54_spi_putreg(priv, LPC54_SPI_FIFOCFG_OFFSET, regval); + + /* Set the delay configuration (not used) */ + + regval = (SPI_DLY_PRE_DELAY(0) | SPI_DLY_POST_DELAY(0) | SPI_DLY_FRAME_DELAY(0) | + SPI_DLY_TRANSFER_DELAY(0)); + lpc54_spi_putreg(priv, LPC54_SPI_DLY_OFFSET, regval); /* Select a default frequency of approx. 400KHz */ lpc54_spi_setfrequency((FAR struct spi_dev_s *)priv, 400000); - /* Initialize the SPI semaphore that enforces mutually exclusive access */ + /* Enable the SPI peripheral */ + + regval = lpc54_spi_getreg(priv, LPC54_SPI_CFG_OFFSET); + regval |= SPI_CFG_ENABLE; + lpc54_spi_putreg(priv, LPC54_SPI_CFG_OFFSET, regval); - nxsem_init(&priv->exclsem, 0, 1); return &priv->dev; } diff --git a/arch/arm/src/lpc54xx/lpc54_spi_master.h b/arch/arm/src/lpc54xx/lpc54_spi_master.h index 376c3a6e7680796629856439072abc6906d52bbb..9205dd66f45942e36fbe6c340157716739979ec9 100644 --- a/arch/arm/src/lpc54xx/lpc54_spi_master.h +++ b/arch/arm/src/lpc54xx/lpc54_spi_master.h @@ -98,7 +98,7 @@ extern "C" * ... * 9 - SPI9 * - * Input Parameter: + * Input Parameters: * port - SPI peripheral number, 0.. 9. * * Returned Value: @@ -109,45 +109,111 @@ extern "C" FAR struct spi_dev_s *lpc54_spibus_initialize(int port); /************************************************************************************ - * Name: lpc54_spiselect, lpc54_spistatus, and lpc54_spicmddata + * Name: lpc54_spiN_select, lpc54_spiN_status, and lpc54_spiN_cmddata * * Description: * These functions must be provided in your board-specific logic. The - * lpc54_spiselect function will perform chip selection and the lpc54_spistatus + * lpc54_spiN_select function will perform chip selection and the lpc54_spiN_status * will perform status operations using GPIOs in the way your board is configured. * * If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, then - * lpc54_spicmddata must also be provided. This functions performs cmd/data + * lpc54_spiN_cmddata must also be provided. This functions performs cmd/data * selection operations using GPIOs in the way your board is configured. * ************************************************************************************/ -void lpc54_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t lpc54_spistatus(FAR struct spi_dev_s *dev, uint32_t devid); +#ifdef CONFIG_LPC54_SPI0_MASTER +void lpc54_spi0_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi0_status(FAR struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int lpc54_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int lpc54_spi0_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif #endif -/************************************************************************************ - * Name: spi_flush - * - * Description: - * Flush and discard any words left in the RX fifo. This can be called from - * spiselect after a device is deselected (if you worry about such things). - * - * Input Parameters: - * dev - Device-specific state data - * - * Returned Value: - * None - * - ************************************************************************************/ +#ifdef CONFIG_LPC54_SPI1_MASTER +void lpc54_spi1_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi1_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi1_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI2_MASTER +void lpc54_spi2_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi2_status(FAR struct spi_dev_s *dev, uint32_t devid); -void spi_flush(FAR struct spi_dev_s *dev); +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi2_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI3_MASTER +void lpc54_spi3_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi3_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi3_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI4_MASTER +void lpc54_spi4_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi4_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi4_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI5_MASTER +void lpc54_spi5_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi5_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi5_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI6_MASTER +void lpc54_spi6_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi6_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi6_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI7_MASTER +void lpc54_spi7_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi7_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi7_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI8_MASTER +void lpc54_spi8_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi8_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi8_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif + +#ifdef CONFIG_LPC54_SPI9_MASTER +void lpc54_spi9_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected); +uint8_t lpc54_spi9_status(FAR struct spi_dev_s *dev, uint32_t devid); + +#ifdef CONFIG_SPI_CMDDATA +int lpc54_spi9_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +#endif +#endif /************************************************************************************ - * Name: lpc54_spi/spiregister + * Name: lpc54_spiN_register * * Description: * If the board supports a card detect callback to inform the SPI-based MMC/SD @@ -167,8 +233,37 @@ void spi_flush(FAR struct spi_dev_s *dev); ************************************************************************************/ #ifdef CONFIG_SPI_CALLBACK -int lpc54_spiregister(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#ifdef CONFIG_LPC54_SPI0_MASTER +int lpc54_spi0_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI1_MASTER +int lpc54_spi1_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI2_MASTER +int lpc54_spi2_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI3_MASTER +int lpc54_spi3_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI4_MASTER +int lpc54_spi4_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI5_MASTER +int lpc54_spi5_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI6_MASTER +int lpc54_spi6_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI7_MASTER +int lpc54_spi7_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI8_MASTER +int lpc54_spi8_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); +#endif +#ifdef CONFIG_LPC54_SPI9_MASTER +int lpc54_spi9_register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, void *arg); #endif +#endif /* CONFIG_SPI_CALLBACK */ #undef EXTERN #if defined(__cplusplus) diff --git a/arch/arm/src/lpc54xx/lpc54_wwdt.c b/arch/arm/src/lpc54xx/lpc54_wwdt.c index a664d2ba99246fd2b6bf40bd1ab3ab31508200e6..c442ee318e888ccd5867b59921f57b6a8eaa4cd0 100644 --- a/arch/arm/src/lpc54xx/lpc54_wwdt.c +++ b/arch/arm/src/lpc54xx/lpc54_wwdt.c @@ -207,7 +207,7 @@ static void lpc54_setwarning(uint32_t warning) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -255,7 +255,7 @@ static int lpc54_wwdt_interrupt(int irq, FAR void *context) * lower - A pointer the publicly visible representation of the * "lower-half" driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -296,7 +296,7 @@ static int lpc54_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -330,7 +330,7 @@ static int lpc54_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -362,7 +362,7 @@ static int lpc54_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * status - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -420,7 +420,7 @@ static int lpc54_getstatus(FAR struct watchdog_lowerhalf_s *lower, * "lower-half" driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -495,7 +495,7 @@ static int lpc54_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -564,7 +564,7 @@ static xcpt_t lpc54_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -621,7 +621,7 @@ static int lpc54_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/lpc54xx/lpc54_wwdt.h b/arch/arm/src/lpc54xx/lpc54_wwdt.h index db0822a48ea87fbaf877e452eeea182056b9cc4f..baffd8c167e1000195e56d08fd9a8b54b7759726 100644 --- a/arch/arm/src/lpc54xx/lpc54_wwdt.h +++ b/arch/arm/src/lpc54xx/lpc54_wwdt.h @@ -78,7 +78,7 @@ extern "C" * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/nuc1xx/nuc_gpio.c b/arch/arm/src/nuc1xx/nuc_gpio.c index 0e2b11d54c14f22cc81b67225f2a8be2491d82aa..e5c86c29347314ac50aff4461e45a6ba7e7c5b02 100644 --- a/arch/arm/src/nuc1xx/nuc_gpio.c +++ b/arch/arm/src/nuc1xx/nuc_gpio.c @@ -74,7 +74,7 @@ * function, it must be unconfigured with nuc_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * ERROR on invalid port, or when pin is locked as ALT function. * diff --git a/arch/arm/src/nuc1xx/nuc_gpio.h b/arch/arm/src/nuc1xx/nuc_gpio.h index 1fca1dc0e50933c0ae6f6a1142c67d8f7f6cac5a..9d08dbac1ad9cd506bdca38818363ab8c794fadd 100644 --- a/arch/arm/src/nuc1xx/nuc_gpio.h +++ b/arch/arm/src/nuc1xx/nuc_gpio.h @@ -208,7 +208,7 @@ extern "C" * function, it must be unconfigured with nuc_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * ERROR on invalid port, or when pin is locked as ALT function. * diff --git a/arch/arm/src/sam34/Kconfig b/arch/arm/src/sam34/Kconfig index 862b381418b3b56e1a88cb94f869ad2b4dc8d0a0..692bfd062f20451f4a9c089f3c5c52e8673f156c 100644 --- a/arch/arm/src/sam34/Kconfig +++ b/arch/arm/src/sam34/Kconfig @@ -247,6 +247,7 @@ config ARCH_CHIP_SAM4CM default n select ARCH_HAVE_MULTICPU select ARCH_HAVE_TICKLESS + select ARCH_GLOBAL_IRQDISABLE config ARCH_CHIP_SAM4L bool diff --git a/arch/arm/src/sam34/Make.defs b/arch/arm/src/sam34/Make.defs index 9ca94574306d696ca27d16a144a7133241852442..12a35528fb6293f80850d6b91ecb37bab118b7a4 100644 --- a/arch/arm/src/sam34/Make.defs +++ b/arch/arm/src/sam34/Make.defs @@ -47,7 +47,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_initialize.c diff --git a/arch/arm/src/sam34/sam4cm_cpuidlestack.c b/arch/arm/src/sam34/sam4cm_cpuidlestack.c index 411ebfaad77efb449d82af9a9b3ac502aface7a6..1f3dd7fad8cc85ef6144d55a7d597d90aa5acea1 100644 --- a/arch/arm/src/sam34/sam4cm_cpuidlestack.c +++ b/arch/arm/src/sam34/sam4cm_cpuidlestack.c @@ -115,7 +115,7 @@ void up_idle(void) * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - cpu: CPU index that indicates which CPU the IDLE task is * being created for. * - tcb: The TCB of new CPU IDLE task diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index c45ea9f3838459f4552094cafb4d4255d7e80b0d..88d43258d56be27af665580ed2146a593b18a1ee 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sam34/sam_emac.c * - * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic derives from the SAM34D3 Ethernet driver. @@ -408,7 +408,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2309,86 +2309,90 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = sam_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - /* Read from the requested register */ + /* Read from the requested register */ - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - /* Write to the requested register */ + /* Write to the requested register */ - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -3630,7 +3634,7 @@ void up_netinitialize(void) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_emac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/sam34/sam_hsmci.c b/arch/arm/src/sam34/sam_hsmci.c index 0ac187982b7e3fe2067df2d0c151ff1f12ccc643..0a1f1c2d325915fa256d816b9a4c16688c808df7 100644 --- a/arch/arm/src/sam34/sam_hsmci.c +++ b/arch/arm/src/sam34/sam_hsmci.c @@ -2317,7 +2317,7 @@ static sdio_eventset_t sam_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2670,7 +2670,7 @@ static void sam_callback(void *arg) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -2745,7 +2745,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -2792,7 +2792,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_hsmci.h b/arch/arm/src/sam34/sam_hsmci.h index 3339c2d2958abf25b50c903c1dd0bc8436eb7d5a..78dc02069c47ef6eddfb3051193597fb388ed583 100644 --- a/arch/arm/src/sam34/sam_hsmci.h +++ b/arch/arm/src/sam34/sam_hsmci.h @@ -87,7 +87,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -109,7 +109,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -127,7 +127,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_rtt.c b/arch/arm/src/sam34/sam_rtt.c index 7978b01bf38467eb798dea642ecf91f37766eb12..1b945e42e8fe12b6158808e5e2d2e42ba56cda98 100644 --- a/arch/arm/src/sam34/sam_rtt.c +++ b/arch/arm/src/sam34/sam_rtt.c @@ -270,7 +270,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -354,7 +354,7 @@ static int sam34_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -417,7 +417,7 @@ static int sam34_start(FAR struct timer_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -456,7 +456,7 @@ static int sam34_stop(FAR struct timer_lowerhalf_s *lower) * driver state structure. * status - The location to return the status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -507,7 +507,7 @@ static int sam34_getstatus(FAR struct timer_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -559,7 +559,7 @@ static int sam34_settimeout(FAR struct timer_lowerhalf_s *lower, * behavior is restored, * arg - Argument that will be provided in the callback * - * Returned Values: + * Returned Value: * The previous timer expiration function pointer or NULL is there was * no previous function pointer. * @@ -599,7 +599,7 @@ static void sam34_setcallback(FAR struct timer_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -632,7 +632,7 @@ static int sam34_ioctl(FAR struct timer_lowerhalf_s *lower, int cmd, * devpath - The full path to the timer. This should be of the form * /dev/rtt0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_rtt.h b/arch/arm/src/sam34/sam_rtt.h index f300747efb3f5aff624ff55f42156273a86f878c..3a00c17fbdd5ff45ec9a562626d5a7125ea03e14 100644 --- a/arch/arm/src/sam34/sam_rtt.h +++ b/arch/arm/src/sam34/sam_rtt.h @@ -80,7 +80,7 @@ extern "C" * devpath - The full path to the timer. This should be of the form * /dev/rtt0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_spi.c b/arch/arm/src/sam34/sam_spi.c index 0dc57e7a6c103ed53194789a74ee44d34562d35e..df2be897165826524c517c956226508a8ee8c530 100644 --- a/arch/arm/src/sam34/sam_spi.c +++ b/arch/arm/src/sam34/sam_spi.c @@ -79,6 +79,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ /* When SPI DMA is enabled, small DMA transfers will still be performed by * polling logic. But we need a threshold value to determine what is small. @@ -193,7 +194,7 @@ struct sam_spics_s typedef void (*select_t)(uint32_t devid, bool selected); -/* Chip select register offsetrs */ +/* Chip select register offsets */ /* The overall state of one SPI controller */ @@ -1002,7 +1003,8 @@ static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency) return spics->actual; } - /* Configure SPI to a frequency as close as possible to the requested frequency. + /* Configure SPI to a frequency as close as possible to the requested + * frequency. * * SPCK frequency = SPI_CLK / SCBR, or SCBR = SPI_CLK / frequency */ @@ -1110,7 +1112,7 @@ static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode) * 3 1 0 */ - offset = (unsigned int)g_csroffset[spics->cs]; + offset = (unsigned int)g_csroffset[spics->cs]; regval = spi_getreg(spi, offset); regval &= ~(SPI_CSR_CPOL | SPI_CSR_NCPHA); @@ -1184,7 +1186,9 @@ static void spi_setbits(struct spi_dev_s *dev, int nbits) spiinfo("csr[offset=%02x]=%08x\n", offset, regval); - /* Save the selection so the subsequence re-configurations will be faster */ + /* Save the selection so the subsequence re-configurations will be + * faster. + */ spics->nbits = nbits; } @@ -1233,7 +1237,7 @@ static uint16_t spi_send(struct spi_dev_s *dev, uint16_t wd) * that performs DMA SPI transfers, but only when a larger block of * data is being transferred. And (2) another version that does polled * SPI transfers. When CONFIG_SAM34_SPI_DMA=n the latter is the only - * version avaialable; when CONFIG_SAM34_SPI_DMA=y, this version is only + * version available; when CONFIG_SAM34_SPI_DMA=y, this version is only * used for short SPI transfers and gets renamed as spi_exchange_nodma). * * Input Parameters: @@ -1268,7 +1272,8 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, uint8_t *rxptr8; uint8_t *txptr8; - spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", txbuffer, rxbuffer, nwords); + spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", + txbuffer, rxbuffer, nwords); /* Set up PCS bits */ @@ -1414,7 +1419,8 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, return; } - spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", txbuffer, rxbuffer, nwords); + spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", + txbuffer, rxbuffer, nwords); spics = (struct sam_spics_s *)dev; spi = spi_device(spics); @@ -1590,7 +1596,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, ret = wd_start(spics->dmadog, DMA_TIMEOUT_TICKS, (wdentry_t)spi_dmatimeout, 1, (uint32_t)spics); - if (ret != OK) + if (ret < 0) { spierr("ERROR: wd_start failed: %d\n", ret); } @@ -1711,7 +1717,7 @@ static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords) * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * cs - Chip select number (identifying the "logical" SPI port) * * Returned Value: diff --git a/arch/arm/src/sam34/sam_spi.h b/arch/arm/src/sam34/sam_spi.h index 8cebb2f121b4864484d74c4864a3fec6baca8528..b9cbcce76df2f724b8a458b1617b9e5a5933e956 100644 --- a/arch/arm/src/sam34/sam_spi.h +++ b/arch/arm/src/sam34/sam_spi.h @@ -117,7 +117,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * cs - Chip select number (identifying the "logical" SPI port) * * Returned Value: @@ -182,7 +182,7 @@ struct spi_dev_s *sam_spibus_initialize(int port); * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -204,7 +204,7 @@ void sam_spi1select(uint32_t devid, bool selected); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -235,7 +235,7 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_tc.c b/arch/arm/src/sam34/sam_tc.c index 1faab8b159f170cdff8b24429ca733d0c0c16917..3212174623864deadf897dc6ff41b3ee3fa060bf 100644 --- a/arch/arm/src/sam34/sam_tc.c +++ b/arch/arm/src/sam34/sam_tc.c @@ -250,7 +250,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -309,7 +309,7 @@ static int sam34_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -365,7 +365,7 @@ static int sam34_start(FAR struct timer_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -401,7 +401,7 @@ static int sam34_stop(FAR struct timer_lowerhalf_s *lower) * driver state structure. * status - The location to return the status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -454,7 +454,7 @@ static int sam34_getstatus(FAR struct timer_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -507,7 +507,7 @@ static int sam34_settimeout(FAR struct timer_lowerhalf_s *lower, * behavior is restored, * arg - Argument to be provided with the callback. * - * Returned Values: + * Returned Value: * The previous timer expiration function pointer or NULL is there was * no previous function pointer. * @@ -547,7 +547,7 @@ static void sam34_setcallback(FAR struct timer_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -580,7 +580,7 @@ static int sam34_ioctl(FAR struct timer_lowerhalf_s *lower, int cmd, * devpath - The full path to the timer. This should be of the form * /dev/tc0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_tc.h b/arch/arm/src/sam34/sam_tc.h index df7b3caf29011e8e006039bcd58965744577ae79..3667213d75200d75dbfe810ec84ca9f4395c846c 100644 --- a/arch/arm/src/sam34/sam_tc.h +++ b/arch/arm/src/sam34/sam_tc.h @@ -79,7 +79,7 @@ extern "C" * devpath - The full path to the timer. This should be of the form * /dev/tc0 * irq - irq associated with the timer - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c index 18b510cbcbd0e7bae0b122ffdbbb487c7464625a..7f733790f706c6e4ac65425a13c167d0b4a451b3 100644 --- a/arch/arm/src/sam34/sam_twi.c +++ b/arch/arm/src/sam34/sam_twi.c @@ -386,7 +386,7 @@ static int twi_wait(struct twi_dev_s *priv) { /* Start a timeout to avoid hangs */ - wd_start(priv->timeout, TWI_TIMEOUT, twi_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, TWI_TIMEOUT, twi_timeout, 1, (uint32_t)priv); /* Wait for either the TWI transfer or the timeout to complete */ diff --git a/arch/arm/src/sam34/sam_twi.h b/arch/arm/src/sam34/sam_twi.h index 87c31b30321b70017756d42cd83ecb15c9ce5b53..06868044b2a4552575af05aff2d16b2277f92d4e 100644 --- a/arch/arm/src/sam34/sam_twi.h +++ b/arch/arm/src/sam34/sam_twi.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *sam_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the sam_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c index 908716ebb087de813c447d37b24fc7a1e97ca548..c2edada328c773fdba0ebf147fa7a37cb46b8c06 100644 --- a/arch/arm/src/sam34/sam_udp.c +++ b/arch/arm/src/sam34/sam_udp.c @@ -2525,7 +2525,7 @@ static void sam_resume(struct sam_usbdev_s *priv) /**************************************************************************** * Name: sam_ep_reset * - * Description + * Description: * Reset and disable one endpoints. * ****************************************************************************/ @@ -2565,7 +2565,7 @@ static void sam_ep_reset(struct sam_usbdev_s *priv, uint8_t epno) /**************************************************************************** * Name: sam_epset_reset * - * Description + * Description: * Reset and disable a set of endpoints. * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_wdt.c b/arch/arm/src/sam34/sam_wdt.c index cf88b37fec1e515a2865e2eccbc152c6ded95302..4e902f46b5ffb229825404c23813b8ead5636e2e 100644 --- a/arch/arm/src/sam34/sam_wdt.c +++ b/arch/arm/src/sam34/sam_wdt.c @@ -251,7 +251,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -294,7 +294,7 @@ static int sam34_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -338,7 +338,7 @@ static int sam34_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -369,7 +369,7 @@ static int sam34_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -393,7 +393,7 @@ static int sam34_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * status - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -449,7 +449,7 @@ static int sam34_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in millisecnds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -516,7 +516,7 @@ static int sam34_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -589,7 +589,7 @@ static xcpt_t sam34_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -649,7 +649,7 @@ static int sam34_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sam34/sam_wdt.h b/arch/arm/src/sam34/sam_wdt.h index 77a1fbab40e3dd684031c8ab1e7a459c427cf83c..3330cc01e73349e1171b9ff89451ace27ff59396 100644 --- a/arch/arm/src/sam34/sam_wdt.h +++ b/arch/arm/src/sam34/sam_wdt.h @@ -79,7 +79,7 @@ extern "C" * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sama5/Kconfig b/arch/arm/src/sama5/Kconfig index ae701198f1460953d4c43092c0c22005bf01e487..35f4efe98c0754dd6828817d980674df12985ba5 100644 --- a/arch/arm/src/sama5/Kconfig +++ b/arch/arm/src/sama5/Kconfig @@ -165,7 +165,7 @@ config SAMA5_HAVE_VDEC bool default n -# Summary configuratinos +# Summary configurations config SAMA5_FLEXCOM bool diff --git a/arch/arm/src/sama5/Make.defs b/arch/arm/src/sama5/Make.defs index 716f5581d25d17655f8e012cef89f81a459aa451..3c447aae1f0f36a1685d2385308a1f9b30ce4de5 100644 --- a/arch/arm/src/sama5/Make.defs +++ b/arch/arm/src/sama5/Make.defs @@ -55,7 +55,7 @@ endif CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S arm_vfork.S -CMN_ASRCS += arm_testset.S +CMN_ASRCS += arm_testset.S arm_fetchadd.S CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S diff --git a/arch/arm/src/sama5/sam_adc.c b/arch/arm/src/sama5/sam_adc.c index c61f44a3df5aa90c32b715bc81b79d6bce93ce40..d6975391a4610a21b93ec425da3fc22e9e014d64 100644 --- a/arch/arm/src/sama5/sam_adc.c +++ b/arch/arm/src/sama5/sam_adc.c @@ -591,7 +591,7 @@ static bool sam_adc_checkreg(struct sam_adc_s *priv, bool wr, * thread sets ready when it has completed processing the last sample * data. * - * Input Parameters + * Input Parameters: * arg - The ADC private data structure cast to (void *) * * Returned Value: @@ -838,7 +838,7 @@ static int sam_adc_dmasetup(FAR struct sam_adc_s *priv, FAR uint8_t *buffer, * sam_adc_endconversion will re-enable EOC interrupts when it completes * processing all pending EOC events. * - * Input Parameters + * Input Parameters: * arg - The ADC private data structure cast to (void *) * * Returned Value: diff --git a/arch/arm/src/sama5/sam_boot.c b/arch/arm/src/sama5/sam_boot.c index 0098100945f27d4a745874326748a9570404825d..609f147608092246371b80d4d23fcb2e4121f08a 100644 --- a/arch/arm/src/sama5/sam_boot.c +++ b/arch/arm/src/sama5/sam_boot.c @@ -84,7 +84,7 @@ extern uint32_t _vector_end; /* End+1 of vector block */ /**************************************************************************** * Name: sam_setupmappings * - * Description + * Description: * Map all of the initial memory regions defined in g_section_mapping[] * ****************************************************************************/ @@ -106,7 +106,7 @@ static inline void sam_setupmappings(void) /**************************************************************************** * Name: sam_remap * - * Description + * Description: * Map all of the final memory regions defined in g_operational_mapping[] * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_can.c b/arch/arm/src/sama5/sam_can.c index 956ae680e8d5b39cbd6d233c78a33142e7d9dc1e..960c2e53467b931234f1b3c4647edafc3a31ea32 100644 --- a/arch/arm/src/sama5/sam_can.c +++ b/arch/arm/src/sama5/sam_can.c @@ -579,7 +579,7 @@ static void can_semtake(FAR struct sam_can_s *priv) * Description: * Allocate one mailbox * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN peripheral * * Returned Value: @@ -626,7 +626,7 @@ static int can_mballoc(FAR struct sam_can_s *priv) * Description: * Free one mailbox * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN peripheral * mbndx - Index of the mailbox to be freed * @@ -670,7 +670,7 @@ static void can_mbfree(FAR struct sam_can_s *priv, int mbndx) * Description: * Configure and enable mailbox(es) for reception * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN peripheral * * Returned Value: @@ -1592,7 +1592,7 @@ static void can_interrupt(int irq, void *context, FAR void *arg) * Tphs1 = Tq * (PHASE1 + 1) * Tphs2 = Tq * (PHASE2 + 1) * - * Input Parameter: + * Input Parameters: * config - A reference to the CAN constant configuration * * Returned Value: @@ -1706,7 +1706,7 @@ static int can_bittiming(struct sam_can_s *priv) * Description: * Use the SAMA5 auto-baud feature to correct the initial timing * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1776,7 +1776,7 @@ static int can_autobaud(struct sam_can_s *priv) * Description: * CAN cell initialization * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN peripheral * * Returned Value: @@ -1889,7 +1889,7 @@ static int can_hwinitialize(struct sam_can_s *priv) * Description: * Initialize the selected CAN port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple CAN interfaces) * * Returned Value: diff --git a/arch/arm/src/sama5/sam_can.h b/arch/arm/src/sama5/sam_can.h index 83a08f756bb59a93b5307cec0627a25dcb5c0928..bff7c1efbf007fd2fcb7d708eef27ac0ddbde513 100644 --- a/arch/arm/src/sama5/sam_can.h +++ b/arch/arm/src/sama5/sam_can.h @@ -125,7 +125,7 @@ extern "C" * Description: * Initialize the selected CAN port * - * Input Parameter: + * Input Parameters: * Port number: 0=CAN0, 1=CAN1 * * Returned Value: diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c index 9b25316272fe95c7569e3b103657b962bf3fc4e3..bd87be9f93b252fa2d575f0db20a3e7f934919d2 100644 --- a/arch/arm/src/sama5/sam_ehci.c +++ b/arch/arm/src/sama5/sam_ehci.c @@ -1903,7 +1903,7 @@ static struct sam_qtd_s *sam_qtd_statusphase(uint32_t tokenbits) * * Assumption: The caller holds the EHCI exclsem. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -2183,7 +2183,7 @@ errout_with_qh: * * Assumption: The caller holds the EHCI exclsem. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -2290,7 +2290,7 @@ errout_with_qh: * complete, but will be re-acquired when before returning. The state of * EHCI resources could be very different upon return. * - * Returned value: + * Returned Value: * On success, this function returns the number of bytes actually transferred. * For control transfers, this size includes the size of the control request * plus the size of the data (which could be short); For bulk transfers, this @@ -2370,7 +2370,7 @@ static ssize_t sam_transfer_wait(struct sam_epinfo_s *epinfo) * callback - The function to be called when the completes * arg - An arbitrary argument that will be provided with the callback. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -2423,7 +2423,7 @@ static inline int sam_ioc_async_setup(struct sam_rhport_s *rhport, * epinfo - The IN or OUT endpoint descriptor for the device endpoint on * which the transfer was performed. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3265,7 +3265,7 @@ static int sam_uhphs_interrupt(int irq, FAR void *context, FAR void *arg) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3367,7 +3367,7 @@ static int sam_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3659,7 +3659,7 @@ static int sam_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3703,7 +3703,7 @@ static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3786,7 +3786,7 @@ static int sam_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3831,7 +3831,7 @@ static int sam_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which * to return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3876,7 +3876,7 @@ static int sam_alloc(FAR struct usbhost_driver_s *drvr, * to the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3913,7 +3913,7 @@ static int sam_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3952,7 +3952,7 @@ static int sam_ioalloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3996,7 +3996,7 @@ static int sam_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4097,7 +4097,7 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4208,7 +4208,7 @@ errout_with_sem: * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4301,7 +4301,7 @@ errout_with_sem: * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4490,7 +4490,7 @@ errout_with_sem: * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4541,7 +4541,7 @@ static int sam_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 1648cab5258a357bd14018b7d74257bffd98afa9..3a011a5b7cbcaf10b3c6f655adbd6b35a5950cfd 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -4,7 +4,7 @@ * 10/100 Base-T Ethernet driver for the SAMA5D3. Denoted as 'A' to * distinguish it from the SAMA5D4 EMAC driver. * - * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -413,7 +413,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2345,86 +2345,90 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = sam_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - /* Read from the requested register */ + /* Read from the requested register */ - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - /* Write to the requested register */ + /* Write to the requested register */ - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -3672,7 +3676,7 @@ int sam_emac_initialize(void) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_emac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index c9fb251acaceb37297ee9a454b8359d8968e8ac8..9f6f366e245039e5f56d0eca5a4aaa56c6bb4186 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -507,7 +507,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2715,79 +2715,83 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) #ifdef CONFIG_NETDEV_PHY_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ + { + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) - { - /* Enable PHY link up/down interrupts */ + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ - ret = sam_phyintenable(priv); + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - /* Read from the requested register */ + /* Read from the requested register */ - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - /* Write to the requested register */ + /* Write to the requested register */ - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } @@ -4357,9 +4361,9 @@ int sam_emac_initialize(int intf) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) priv->phytype = phytype; /* Type of PHY on port */ #endif #endif diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index d90996219062227d52f86da70a3a9a129b0227d8..d70a40c5a3376096b0f186e43ae25d35f2d7b3b1 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sama5/sam_gmac.c * - * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -338,7 +338,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2300,82 +2300,86 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = sam_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - /* Enable the management port */ + /* Enable the management port */ - sam_enablemdio(priv); + sam_enablemdio(priv); - /* Read from the requested register */ + /* Read from the requested register */ - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - /* Disable the management port */ + /* Disable the management port */ - sam_disablemdio(priv); - } - break; + sam_disablemdio(priv); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - /* Enable the management port */ + /* Enable the management port */ - sam_enablemdio(priv); + sam_enablemdio(priv); - /* Write to the requested register */ + /* Write to the requested register */ - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - /* Disable the management port */ + /* Disable the management port */ - sam_disablemdio(priv); - } - break; + sam_disablemdio(priv); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -3744,12 +3748,12 @@ int sam_gmac_initialize(void) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_gmac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); if (!priv->txpoll) diff --git a/arch/arm/src/sama5/sam_hsmci.c b/arch/arm/src/sama5/sam_hsmci.c index b5093d36b041f027a241cd89121e3f7f837c0a5a..3b8e48610e4e4e9738a2b4a6c5195eaae5ff0c5c 100644 --- a/arch/arm/src/sama5/sam_hsmci.c +++ b/arch/arm/src/sama5/sam_hsmci.c @@ -2745,7 +2745,7 @@ static sdio_eventset_t sam_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { lcderr("ERROR: wd_start failed: %d\n", ret); } @@ -3160,7 +3160,7 @@ static void sam_callback(void *arg) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -3353,7 +3353,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3406,7 +3406,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is write protected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_hsmci.h b/arch/arm/src/sama5/sam_hsmci.h index c28bf89594f6c3894099cb752c7f25ee3946dde1..a3257e7d588807d65dfbcb46796cfaf4a73a137e 100644 --- a/arch/arm/src/sama5/sam_hsmci.h +++ b/arch/arm/src/sama5/sam_hsmci.h @@ -87,7 +87,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -118,7 +118,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * bootloader that brought us into SDRAM and it is that bootloader that * has configured the clocking. * - * Input parameters: + * Input Parameters: * target - The target SD frequency * * Returned Value: @@ -143,7 +143,7 @@ uint32_t sam_hsmci_clkdiv(uint32_t target); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -161,7 +161,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_hsmci_clkdiv.c b/arch/arm/src/sama5/sam_hsmci_clkdiv.c index 4ddba13e82b8da3b4514869a8336dddfea447c21..4a56bed140fb3d012a59b12adba992d3dbe821e7 100644 --- a/arch/arm/src/sama5/sam_hsmci_clkdiv.c +++ b/arch/arm/src/sama5/sam_hsmci_clkdiv.c @@ -97,7 +97,7 @@ * bootloader that brought us into SDRAM and it is that bootloader that * has configured the clocking. * - * Input parameters: + * Input Parameters: * target - The target SD frequency * * Returned Value: diff --git a/arch/arm/src/sama5/sam_irq.c b/arch/arm/src/sama5/sam_irq.c index fd4dfd8c5cc246f7e28df209f7212b9c13b05ae7..fbdc1eda5c564d4030c24c1d9f0e0d930a91e13a 100644 --- a/arch/arm/src/sama5/sam_irq.c +++ b/arch/arm/src/sama5/sam_irq.c @@ -261,7 +261,7 @@ static uint32_t *sam_fiqhandler(int irq, uint32_t *regs) * Description: * Return true if the peripheral secure. * - * Input Parameter: + * Input Parameters: * PID = IRQ number * ****************************************************************************/ @@ -576,7 +576,7 @@ void up_irqinitialize(void) * the irq number of the interrupt and then to call arm_doirq to dispatch * the interrupt. * - * Input parameters: + * Input Parameters: * regs - A pointer to the register save area on the stack. * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_lcd.c b/arch/arm/src/sama5/sam_lcd.c index 4e27e1ef2ab5bcf67a244c2faa1ad8ccbe58d87e..67f1ac0628de87f64c75fb0120c3b1f1d6dbbb02 100644 --- a/arch/arm/src/sama5/sam_lcd.c +++ b/arch/arm/src/sama5/sam_lcd.c @@ -2901,7 +2901,7 @@ static void sam_show_hcr(void) * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -3001,7 +3001,7 @@ int up_fbinitialize(int display) * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/arch/arm/src/sama5/sam_nand.c b/arch/arm/src/sama5/sam_nand.c index ae0c22936d4c7dde0cfb5757c53305809f0da3b1..a0fb369ce1f4b1719cfd736c56da7b4fb2abe3b4 100644 --- a/arch/arm/src/sama5/sam_nand.c +++ b/arch/arm/src/sama5/sam_nand.c @@ -353,10 +353,10 @@ void nand_unlock(void) * Waiting for the completion of a page program, erase and random read * completion. * - * Input parameters: + * Input Parameters: * priv Pointer to a sam_nandcs_s instance. * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -376,13 +376,13 @@ static void nand_wait_ready(struct sam_nandcs_s *priv) * Description: * Use the HOST NAND FLASH controller to send a command to the NFC. * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * cmd - command to send * acycle - address cycle when command access id decoded * cycle0 - address at first cycle * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -414,10 +414,10 @@ static void nand_nfc_cmdsend(struct sam_nandcs_s *priv, uint32_t cmd, * Description: * Check if a program or erase operation completed successfully * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * - * Returned value. + * Returned Value: * OK on success, a negated errnor value on failure * ****************************************************************************/ @@ -451,7 +451,7 @@ static int nand_operation_complete(struct sam_nandcs_s *priv) * address cycles. The resulting values are stored in the provided * variables if they are not null. * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * coladdr - Column address to translate. * rowaddr - Row address to translate. @@ -459,7 +459,7 @@ static int nand_operation_complete(struct sam_nandcs_s *priv) * acycle1234 - Four address cycles. * rowonly - True:Only ROW address is used. * - * Returned value. + * Returned Value: * Number of address cycles converted. * ****************************************************************************/ @@ -565,10 +565,10 @@ static int nand_translate_address(struct sam_nandcs_s *priv, * Description: * Map the number of address cycles the bit setting for the NFC command * - * Input parameters: + * Input Parameters: * ncycles - Number of address cycles * - * Returned value. + * Returned Value: * NFC command value * ****************************************************************************/ @@ -602,7 +602,7 @@ static uint32_t nand_get_acycle(int ncycles) * Description: * Sends NAND CLE/ALE command. * - * Input parameters: + * Input Parameters: * priv - Pointer to a sam_nandcs_s instance. * mode - SMC ALE CLE mode parameter. * cmd1 - First command to be sent. @@ -610,7 +610,7 @@ static uint32_t nand_get_acycle(int ncycles) * coladdr - Column address. * rowaddr - Row address. * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -670,10 +670,10 @@ static void nand_nfc_cleale(struct sam_nandcs_s *priv, uint8_t mode, * Description: * Wait for NFC command done * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -716,10 +716,10 @@ static void nand_wait_cmddone(struct sam_nandcs_s *priv) * Description: * Setup to wait for CMDDONE event * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -758,10 +758,10 @@ static void nand_setup_cmddone(struct sam_nandcs_s *priv) * Description: * Wait for a transfer to complete * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -804,10 +804,10 @@ static void nand_wait_xfrdone(struct sam_nandcs_s *priv) * Description: * Setup to wait for XFDONE event * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -846,10 +846,10 @@ static void nand_setup_xfrdone(struct sam_nandcs_s *priv) * Description: * Wait for read/busy edge detection * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -892,10 +892,10 @@ static void nand_wait_rbedge(struct sam_nandcs_s *priv) * Description: * Setup to wait for RBEDGE0 event * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -934,10 +934,10 @@ static void nand_setup_rbedge(struct sam_nandcs_s *priv) * Description: * Wait for NFC not busy * - * Input parameters: + * Input Parameters: * priv - CS state structure instance * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -965,10 +965,10 @@ static void nand_wait_nfcbusy(struct sam_nandcs_s *priv) * This latching capability function is needed to prevent loss of pending * status when sampling the HSMC_SR register. * - * Input parameters: + * Input Parameters: * None * - * Returned value. + * Returned Value: * Current HSMC_SR register value; * ****************************************************************************/ @@ -1041,10 +1041,10 @@ static uint32_t nand_nfc_poll(void) * Description: * HSMC interrupt handler * - * Input parameters: + * Input Parameters: * Standard interrupt arguments * - * Returned value. + * Returned Value: * Always returns OK * ****************************************************************************/ @@ -1203,10 +1203,10 @@ static void nand_dma_sampledone(struct sam_nandcs_s *priv, int result) * Description: * Wait for the completion of a DMA transfer * - * Input parameters: + * Input Parameters: * Wait for read/busy edge detection * - * Returned value. + * Returned Value: * The result of the DMA. OK on success; a negated ernno value on failure. * ****************************************************************************/ @@ -1266,7 +1266,7 @@ static void nand_dmacallback(DMA_HANDLE handle, void *arg, int result) * nbytes - The number of bytes to transfer * dmaflags - Describes the DMA configuration * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -1355,7 +1355,7 @@ static int nand_dma_read(struct sam_nandcs_s *priv, * nbytes - The number of bytes to transfer * dmaflags - Describes the DMA configuration * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -1440,7 +1440,7 @@ static int nand_dma_write(struct sam_nandcs_s *priv, * offset - If reading from NFC SRAM, this is the offset into * the SRAM. * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -1506,7 +1506,7 @@ static int nand_nfcsram_read(struct sam_nandcs_s *priv, uint8_t *buffer, * nfcsram - True: Use NFC Host SRAM * buffer - Buffer that provides the data for the write * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -1590,13 +1590,13 @@ static int nand_read(struct sam_nandcs_s *priv, uint8_t *buffer, * Description: * Reads the data area of a page of a NAND FLASH into the provided buffer. * - * Input parameters: + * Input Parameters: * priv - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -1743,7 +1743,7 @@ static int nand_read_pmecc(struct sam_nandcs_s *priv, off_t block, * buffer - Buffer that provides the data for the write * offset - Data offset in bytes * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -1806,7 +1806,7 @@ static int nand_nfcsram_write(struct sam_nandcs_s *priv, uint8_t *buffer, * buffer - Buffer that provides the data for the write * offset - Data offset in bytes * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -1891,14 +1891,14 @@ static int nand_write(struct sam_nandcs_s *priv, uint8_t *buffer, * provided buffers. The raw NAND contents are returned with no ECC * corrections. * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2007,13 +2007,13 @@ static int nand_readpage_noecc(struct sam_nandcs_s *priv, off_t block, * Reads the data and/or the spare areas of a page of a NAND FLASH into the * provided buffers. PMECC is used * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2127,14 +2127,14 @@ errout: * Writes the data and/or the spare area of a page on a NAND FLASH chip. * No ECC calculations are performed. * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer conatining the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2281,13 +2281,13 @@ static int nand_writepage_noecc(struct sam_nandcs_s *priv, off_t block, * performed. The redundancy is appended to the page and written in the * spare area. * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2495,11 +2495,11 @@ errout: * Description: * Erases the specified block of the device. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the physical block to erase. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2575,14 +2575,14 @@ static int nand_eraseblock(struct nand_raw_s *raw, off_t block) * Reads the data and/or the spare areas of a page of a NAND FLASH into the * provided buffers. This is a raw read of the flash contents. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2612,14 +2612,14 @@ static int nand_rawread(struct nand_raw_s *raw, off_t block, * Writes the data and/or the spare area of a page on a NAND FLASH chip. * This is a raw write of the flash contents. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer containing the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2651,14 +2651,14 @@ static int nand_rawwrite(struct nand_raw_s *raw, off_t block, * provided buffers. Hardware ECC checking will be performed if so * configured. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2713,14 +2713,14 @@ static int nand_readpage(struct nand_raw_s *raw, off_t block, * Writes the data and/or the spare area of a page on a NAND FLASH chip. * Hardware ECC checking will be performed if so configured. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer conatining the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -2775,10 +2775,10 @@ static int nand_writepage(struct nand_raw_s *raw, off_t block, * Description: * Resets a NAND FLASH device * - * Input parameters: + * Input Parameters: * priv - Lower-half, private NAND FLASH device state * - * Returned value. + * Returned Value: * None * ****************************************************************************/ @@ -2803,11 +2803,11 @@ static void nand_reset(struct sam_nandcs_s *priv) * performed here. Those necessary NAND features are provided by common, * higher level NAND MTD layers found in drivers/mtd. * - * Input parameters: + * Input Parameters: * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned value. + * Returned Value: * On success a non-NULL pointer to an MTD device structure is returned; * NULL is returned on a failure. * diff --git a/arch/arm/src/sama5/sam_nand.h b/arch/arm/src/sama5/sam_nand.h index 808b719aa52d3a94462fb81a64b8a56afec7e64f..69c6b729e9ed336d00d25ce2c58d6054b3712cef 100644 --- a/arch/arm/src/sama5/sam_nand.h +++ b/arch/arm/src/sama5/sam_nand.h @@ -397,11 +397,11 @@ EXTERN struct sam_nand_s g_nand; * performed here. Those necessary NAND features are provided by common, * higher level NAND MTD layers found in drivers/mtd. * - * Input parameters: + * Input Parameters: * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned value. + * Returned Value: * On success a non-NULL pointer to an MTD device structure is returned; * NULL is returned on a failure. * @@ -428,7 +428,7 @@ struct mtd_dev_s *sam_nand_initialize(int cs); * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned Values: + * Returned Value: * OK if the HSMC was successfully configured for this CS. A negated * errno value is returned on a failure. This would fail with -ENODEV, * for example, if the board does not support NAND FLASH on the requested @@ -449,7 +449,7 @@ int board_nandflash_config(int cs); * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned Values: + * Returned Value: * True: NAND is busy, False: NAND is ready * ****************************************************************************/ @@ -470,7 +470,7 @@ bool board_nand_busy(int cs); * are connected on-board). * enable - True: enable Chip Select, False: Disable Chip select * - * Returned Values: + * Returned Value: * OK if the HSMC was successfully configured for this CS. A negated * errno value is returned on a failure. This would fail with -ENODEV, * for example, if the board does not support NAND FLASH on the requested diff --git a/arch/arm/src/sama5/sam_ohci.c b/arch/arm/src/sama5/sam_ohci.c index 7b87c382c6952fd6fc4d24261e9def24f55819a3..fac941d686267fa1fb2135ecfa092637b9a18674 100644 --- a/arch/arm/src/sama5/sam_ohci.c +++ b/arch/arm/src/sama5/sam_ohci.c @@ -1543,7 +1543,7 @@ static int sam_enqueuetd(struct sam_rhport_s *rhport, struct sam_eplist_s *eplis * Input Parameters: * rhpndx - Root hub port index. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1629,7 +1629,7 @@ static int sam_ep0enqueue(struct sam_rhport_s *rhport) * ep0 - The control endpoint to be released. May be the control endpoint for * an attached hub. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -2319,7 +2319,7 @@ static void sam_ohci_bottomhalf(void *arg) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -2437,7 +2437,7 @@ static int sam_wait(struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2564,7 +2564,7 @@ static int sam_enumerate(struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2627,7 +2627,7 @@ static int sam_ep0configure(struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2832,7 +2832,7 @@ errout: * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2924,7 +2924,7 @@ static int sam_epfree(struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2969,7 +2969,7 @@ static int sam_alloc(struct usbhost_driver_s *drvr, * to the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3008,7 +3008,7 @@ static int sam_free(struct usbhost_driver_s *drvr, uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3042,7 +3042,7 @@ static int sam_ioalloc(struct usbhost_driver_s *drvr, uint8_t **buffer, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3087,7 +3087,7 @@ static int sam_iofree(struct usbhost_driver_s *drvr, uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3206,7 +3206,7 @@ static int sam_ctrlout(struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -3296,7 +3296,7 @@ static int sam_transfer_common(struct sam_rhport_s *rhport, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure: * @@ -3445,7 +3445,7 @@ errout: * eplist - The internal representation of the device endpoint on which * to perform the transfer. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3555,7 +3555,7 @@ static void sam_asynch_completion(struct sam_eplist_s *eplist) * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3635,7 +3635,7 @@ errout: * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -3780,7 +3780,7 @@ static int sam_cancel(struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -3831,7 +3831,7 @@ static int sam_connect(struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/sama5/sam_pwm.c b/arch/arm/src/sama5/sam_pwm.c index 90b204eac30c03d958419e8b082d309dfb90de64..1758bee1a7940aaff5c4322f3dc572a345f3006a 100644 --- a/arch/arm/src/sama5/sam_pwm.c +++ b/arch/arm/src/sama5/sam_pwm.c @@ -754,7 +754,7 @@ static void pwm_chan_putreg(struct sam_pwm_chan_s *chan, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * chan - A reference to the PWM channel instance * * Returned Value: @@ -827,7 +827,7 @@ static void pwm_dumpregs(struct sam_pwm_chan_s *chan, FAR const char *msg) * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * Standard interrupt handler inputs * * Returned Value: @@ -854,7 +854,7 @@ static int pwm_interrupt(int irq, void *context, FAR void *arg) * use. It will not, however, output pulses until the start method is * called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -897,7 +897,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -927,7 +927,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -1049,7 +1049,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -1086,7 +1086,7 @@ static int pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command @@ -1145,7 +1145,7 @@ static int pwm_ioctl(FAR struct pwm_lowerhalf_s *dev, int cmd, unsigned long arg * regbits = PWM_CLK_PREB_DIV(prelog2); * prescaler = (1 << prelog2) * - * Input parameters: + * Input Parameters: * mck - The main clock frequency * fclk - The desired clock A or B frequency * @@ -1193,7 +1193,7 @@ static unsigned int pwm_clk_prescaler_log2(uint32_t mck, uint32_t fclk) * * div = MCK / prescaler / frequency * - * Input parameters: + * Input Parameters: * mck - The main clock frequency * fclk - The desired clock A or B frequency * prelog2 - The log2(prescaler) value previously selected by @@ -1231,7 +1231,7 @@ static unsigned int pwm_clk_divider(uint32_t mck, uint32_t fclk, * * frequency = MCK / prescaler / div * - * Input parameters: + * Input Parameters: * mck - The main clock frequency * prelog2 - The log2(prescaler) value previously selected by * pwm_prescale_log2(). @@ -1255,7 +1255,7 @@ static uint32_t pwm_clk_frequency(uint32_t mck, unsigned int prelog2, * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * chan - A reference to the PWM channel instance * * Returned Value: diff --git a/arch/arm/src/sama5/sam_spi.c b/arch/arm/src/sama5/sam_spi.c index ce398400f419ae72c2a3c7b59b9c22e7c295113f..eaf588202065c27cd0b6602d87b991d933d45ff9 100644 --- a/arch/arm/src/sama5/sam_spi.c +++ b/arch/arm/src/sama5/sam_spi.c @@ -1520,7 +1520,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, ret = wd_start(spics->dmadog, DMA_TIMEOUT_TICKS, (wdentry_t)spi_dmatimeout, 1, (uint32_t)spics); - if (ret != OK) + if (ret < 0) { spierr("ERROR: wd_start failed: %d\n", ret); } @@ -1638,7 +1638,7 @@ static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords) * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * cs - Chip select number (identifying the "logical" SPI port) * * Returned Value: diff --git a/arch/arm/src/sama5/sam_spi.h b/arch/arm/src/sama5/sam_spi.h index 705f2248e75fc9df41b9f3440e05e0603e57c126..4a8697f25ab02bab2a9d3d2cd32f9f97247f4288 100644 --- a/arch/arm/src/sama5/sam_spi.h +++ b/arch/arm/src/sama5/sam_spi.h @@ -111,7 +111,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * cs - Chip select number (identifying the "logical" SPI port) * * Returned Value: @@ -175,7 +175,7 @@ struct spi_dev_s *sam_spibus_initialize(int port); * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -197,7 +197,7 @@ void sam_spi1select(uint32_t devid, bool selected); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -228,7 +228,7 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_ssc.c b/arch/arm/src/sama5/sam_ssc.c index 0c8699103084cc815bbba2cccfa195319d884505..176b2235cc0bee516cb6d22240dd3dfa524e37af 100644 --- a/arch/arm/src/sama5/sam_ssc.c +++ b/arch/arm/src/sama5/sam_ssc.c @@ -2786,7 +2786,7 @@ static int ssc_tx_configure(struct sam_ssc_s *priv) * Setup the MCK/2 divider based on the currently selected data width and * the sample rate * - * Input Parameter: + * Input Parameters: * priv - I2C device structure (only the sample rate and data length is * needed at this point). * @@ -2843,7 +2843,7 @@ static uint32_t ssc_mck2divider(struct sam_ssc_s *priv) * Description: * Enable and configure clocking to the SSC * - * Input Parameter: + * Input Parameters: * priv - Partially initialized I2C device structure (only the PID is * needed at this point). * @@ -3394,7 +3394,7 @@ static void ssc1_configure(struct sam_ssc_s *priv) * Description: * Initialize the selected SSC port * - * Input Parameter: + * Input Parameters: * port - I2S "port" number (identifying the "logical" SSC port) * * Returned Value: diff --git a/arch/arm/src/sama5/sam_ssc.h b/arch/arm/src/sama5/sam_ssc.h index b7ecafe5a454591009f0523c484d68988a21bd2c..7ae4dafe079e0450fe03881c173e303ccbec505f 100644 --- a/arch/arm/src/sama5/sam_ssc.h +++ b/arch/arm/src/sama5/sam_ssc.h @@ -83,7 +83,7 @@ extern "C" * Description: * Initialize the selected I2S port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple I2S interfaces) * * Returned Value: diff --git a/arch/arm/src/sama5/sam_tsd.c b/arch/arm/src/sama5/sam_tsd.c index 4ec8d1bf04cd58666254f603a0cf67e38bf648c5..15c96f7f8a6c8181ee1270d2cadca815176167df 100644 --- a/arch/arm/src/sama5/sam_tsd.c +++ b/arch/arm/src/sama5/sam_tsd.c @@ -432,7 +432,7 @@ errout: * The ADC hardware can filter the touchscreen samples by averaging. The * function selects (or de-selects) that filtering. * - * Input Parameters + * Input Parameters: * priv - The touchscreen private data structure * tsav - The new (shifted) value of the TSAV field of the ADC TSMR regsiter. * @@ -494,7 +494,7 @@ static void sam_tsd_setaverage(struct sam_tsd_s *priv, uint32_t tsav) * will re-enable TSD interrupts when it completes processing all pending * TSD events. * - * Input Parameters + * Input Parameters: * arg - The touchscreen private data structure cast to (void *) * * Returned Value: @@ -597,7 +597,8 @@ static void sam_tsd_bottomhalf(void *arg) * this case; we rely on the timer expiry to get us going again. */ - wd_start(priv->wdog, TSD_WDOG_DELAY, sam_tsd_expiry, 1, (uint32_t)priv); + (void)wd_start(priv->wdog, TSD_WDOG_DELAY, sam_tsd_expiry, 1, + (uint32_t)priv); ier = 0; goto ignored; } @@ -675,7 +676,8 @@ static void sam_tsd_bottomhalf(void *arg) /* Continue to sample the position while the pen is down */ - wd_start(priv->wdog, TSD_WDOG_DELAY, sam_tsd_expiry, 1, (uint32_t)priv); + (void)wd_start(priv->wdog, TSD_WDOG_DELAY, sam_tsd_expiry, 1, + (uint32_t)priv); /* Check the thresholds. Bail if (1) this is not the first * measurement and (2) there is no significant difference from @@ -1032,7 +1034,7 @@ errout: } /**************************************************************************** - * Name:sam_tsd_ioctl + * Name: sam_tsd_ioctl ****************************************************************************/ static int sam_tsd_ioctl(struct file *filep, int cmd, unsigned long arg) @@ -1705,7 +1707,7 @@ errout_with_priv: * Description: * Handles ADC interrupts associated with touchscreen channels * - * Input parmeters: + * Input Parameters: * pending - Current set of pending interrupts being handled * * Returned Value: diff --git a/arch/arm/src/sama5/sam_tsd.h b/arch/arm/src/sama5/sam_tsd.h index 3ae36434b792a21f213144a98f13694b1981b551..ff0d6a5ead826217c156ca30306c4b58d6681362 100644 --- a/arch/arm/src/sama5/sam_tsd.h +++ b/arch/arm/src/sama5/sam_tsd.h @@ -119,7 +119,7 @@ int sam_tsd_register(FAR struct sam_adc_s *adc, int minor); * Description: * Handles ADC interrupts associated with touchscreen channels * - * Input parmeters: + * Input Parameters: * pending - Current set of pending interrupts being handled * * Returned Value: diff --git a/arch/arm/src/sama5/sam_twi.c b/arch/arm/src/sama5/sam_twi.c index 7e32dd7720789d4e15b3cfb4c37ee4cec829ba57..11f9cf8801efe78a88ec74674b627d7a611c779c 100644 --- a/arch/arm/src/sama5/sam_twi.c +++ b/arch/arm/src/sama5/sam_twi.c @@ -487,7 +487,7 @@ static int twi_wait(struct twi_dev_s *priv, unsigned int size) * TWI transfer stalls. */ - wd_start(priv->timeout, timeout, twi_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, timeout, twi_timeout, 1, (uint32_t)priv); /* Wait for either the TWI transfer or the timeout to complete */ diff --git a/arch/arm/src/sama5/sam_twi.h b/arch/arm/src/sama5/sam_twi.h index e8d75e133540ecfd66e90cda005cf6bff16832d9..f966bec8f8b5ddd9ec2af97800186f2b9434730a 100644 --- a/arch/arm/src/sama5/sam_twi.h +++ b/arch/arm/src/sama5/sam_twi.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *sam_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the sam_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index 090e10b4d84ce1fdad192fe88d05feccbf4656d2..1c04600e1a710f4691ac5336c4240463aa197e6b 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -3048,7 +3048,7 @@ static void sam_resume(struct sam_usbdev_s *priv) /**************************************************************************** * Name: sam_ep_reset * - * Description + * Description: * Reset and disable a set of endpoints. * ****************************************************************************/ @@ -3090,7 +3090,7 @@ static void sam_ep_reset(struct sam_usbdev_s *priv, uint8_t epno) /**************************************************************************** * Name: sam_epset_reset * - * Description + * Description: * Reset and disable a set of endpoints. * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_wdt.c b/arch/arm/src/sama5/sam_wdt.c index 9d3f7dd61eaed194699b3e485a7712664a01b036..0fd0fa21ee1b3e8b8f9dbffd11b6324cdde88ae2 100644 --- a/arch/arm/src/sama5/sam_wdt.c +++ b/arch/arm/src/sama5/sam_wdt.c @@ -254,7 +254,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -290,7 +290,7 @@ static int sam_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -320,7 +320,7 @@ static int sam_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -350,7 +350,7 @@ static int sam_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -378,7 +378,7 @@ static int sam_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * stawtus - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -435,7 +435,7 @@ static int sam_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in millisecnds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -554,7 +554,7 @@ static int sam_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -619,7 +619,7 @@ static xcpt_t sam_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -649,7 +649,7 @@ static int sam_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * Input Parameters: * None * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_wdt.h b/arch/arm/src/sama5/sam_wdt.h index 0f9eab7b75b871c6e96f466872f916ebc5bb5def..ba3a067b1df0b5277efc4e59b58f12efef6ccc43 100644 --- a/arch/arm/src/sama5/sam_wdt.h +++ b/arch/arm/src/sama5/sam_wdt.h @@ -76,7 +76,7 @@ extern "C" * * At a minimum, this function should call watchdog_register(). * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/arch/arm/src/samdl/Kconfig b/arch/arm/src/samdl/Kconfig index ec8507a048b644819aa63c96995bcabbe8aea4b9..3026bc9fcbaf7392a85a1301683bfff1d4a85ad4 100644 --- a/arch/arm/src/samdl/Kconfig +++ b/arch/arm/src/samdl/Kconfig @@ -572,6 +572,10 @@ config SAMDL_USB default n depends on SAMDL_HAVE_USB +config SAMDL_EIC + bool "External Interrupt Controller" + default n + config SAMDL_WDT bool "Watchdog Timer" default n @@ -716,7 +720,15 @@ config SAMDL_HAVE_SPI bool select SPI -if SAMDL_HAVE_SPI +menu "SPI options" + depends on SAMDL_HAVE_SPI + +config SAMDL_SPI_DMA + bool "SPI DMA" + default n + depends on SAMDL_DMAC && EXPERIMENTAL + ---help--- + Use DMA for SPI SERCOM peripherals. config SAMDL_SPI_REGDEBUG bool "SPI register-Level Debug" @@ -725,13 +737,14 @@ config SAMDL_SPI_REGDEBUG ---help--- Enable very low-level register access debug. Depends on DEBUG_SPI. -endif # SAMDL_HAVE_SPI +endmenu # SPI options config SAMDL_HAVE_I2C bool select I2C -if SAMDL_HAVE_I2C +menu "I2C options" + depends on SAMDL_HAVE_I2C config SAMDL_I2C_REGDEBUG bool "I2C register-Level Debug" @@ -740,9 +753,10 @@ config SAMDL_I2C_REGDEBUG ---help--- Enable very low-level register access debug. Depends on DEBUG_I2C. -endif # SAMDL_HAVE_I2C +endmenu # I2C options -if SAMDL_HAVE_USB +menu "USB options" + depends on SAMDL_HAVE_USB config SAMDL_USB_ENABLE_PPEP bool "Enable Ping-Pong Endpoints" @@ -762,4 +776,5 @@ config SAMDL_USB_REGDEBUG Enable very low-level register access debug. Depends on CONFIG_DEBUG_USB_INFO. -endif # SAMDL_HAVE_USB +endmenu # USB options + diff --git a/arch/arm/src/samdl/Make.defs b/arch/arm/src/samdl/Make.defs index 71b156c6c774f7a8a656af27f8e6cee0c30d0dac..e62eba81f3b982efe7b141f7869293fa04210447 100644 --- a/arch/arm/src/samdl/Make.defs +++ b/arch/arm/src/samdl/Make.defs @@ -102,3 +102,11 @@ endif ifeq ($(CONFIG_SAMDL_USB),y) CHIP_CSRCS += sam_usb.c endif + +ifeq ($(CONFIG_SAMDL_EIC),y) +CHIP_CSRCS += sam_eic.c +endif + +ifeq ($(CONFIG_SAMDL_AC),y) +CHIP_CSRCS += sam_ac.c +endif diff --git a/arch/arm/src/samdl/chip/samd_ac.h b/arch/arm/src/samdl/chip/samd_ac.h new file mode 100644 index 0000000000000000000000000000000000000000..31c896402021e63c2236c5d9b6db811dd4a8975c --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_ac.h @@ -0,0 +1,209 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/samd_ac.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * References: + * "Atmel SAM L21E / SAM L21G / SAM L21J Smart ARM-Based Microcontroller + * Datasheet", Atmel-42385C-SAML21_Datasheet_Preliminary-03/20/15 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_AC_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_AC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAMD21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* AC register offsets **********************************************************************/ + +#define SAM_AC_CTRLA_OFFSET 0x0000 /* Control A Register */ +#define SAM_AC_CTRLB_OFFSET 0x0001 /* Control B Register */ +#define SAM_AC_EVCTRL_OFFSET 0x0002 /* Event Control Register */ +#define SAM_AC_INTENCLR_OFFSET 0x0004 /* Interrupt Enable Clear Register */ +#define SAM_AC_INTENSET_OFFSET 0x0005 /* Interrupt Enable Set Register */ +#define SAM_AC_INTFLAG_OFFSET 0x0006 /* Interrupt Flag Status and Clear Register */ +#define SAM_AC_STATUSA_OFFSET 0x0008 /* Status A Register */ +#define SAM_AC_STATUSB_OFFSET 0x0009 /* Status B Register */ +#define SAM_AC_STATUSC_OFFSET 0x000A /* Status C Register */ +#define SAM_AC_WINCTRL_OFFSET 0x000C /* Window Control Register */ +#define SAM_AC_COMPCTRL0_OFFSET 0x0010 /* Comparator 0 Control Register */ +#define SAM_AC_COMPCTRL1_OFFSET 0x0014 /* Comparator 1 Control Register */ +#define SAM_AC_SCALER0_OFFSET 0x0020 /* Scaler 0 Register */ +#define SAM_AC_SCALER1_OFFSET 0x0021 /* Scaler 1 Register */ + +/* AC register addresses *******************************************************************/ + +#define SAM_AC_CTRLA (SAM_AC_BASE+SAM_AC_CTRLA_OFFSET) +#define SAM_AC_CTRLB (SAM_AC_BASE+SAM_AC_CTRLB_OFFSET) +#define SAM_AC_EVCTRL (SAM_AC_BASE+SAM_AC_EVCTRL_OFFSET) +#define SAM_AC_INTENCLR (SAM_AC_BASE+SAM_AC_INTENCLR_OFFSET) +#define SAM_AC_INTENSET (SAM_AC_BASE+SAM_AC_INTENSET_OFFSET) +#define SAM_AC_INTFLAG (SAM_AC_BASE+SAM_AC_INTFLAG_OFFSET) +#define SAM_AC_STATUSA (SAM_AC_BASE+SAM_AC_STATUSA_OFFSET) +#define SAM_AC_STATUSB (SAM_AC_BASE+SAM_AC_STATUSB_OFFSET) +#define SAM_AC_STATUSC (SAM_AC_BASE+SAM_AC_STATUSC_OFFSET) +#define SAM_AC_WINCTRL (SAM_AC_BASE+SAM_AC_WINCTRL_OFFSET) +#define SAM_AC_COMPCTRL0 (SAM_AC_BASE+SAM_AC_COMPCTRL0_OFFSET) +#define SAM_AC_COMPCTRL1 (SAM_AC_BASE+SAM_AC_COMPCTRL1_OFFSET) +#define SAM_AC_SCALER0 (SAM_AC_BASE+SAM_AC_SCALER0_OFFSET) +#define SAM_AC_SCALER1 (SAM_AC_BASE+SAM_AC_SCALER1_OFFSET) + +/* AC register bit definitions ************************************************************/ + +/* Control A Register */ + +#define AC_CTRLA_SWRTS (1 << 0) /* Bit 0: Software reset */ +#define AC_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable AC */ +#define AC_CTRLA_RUNSTDBY (1 << 2) /* Bit 2: Run in standby */ +#define AC_CTRLA_LPMUX (1 << 7) /* Bit 7: Low-Power Mux */ + +/* Control B Register */ + +#define AC_CTRLB_START0 (1 << 0) /* Bit 0: Comparator 0 start */ +#define AC_CTRLB_START1 (1 << 1) /* Bit 1: Comparator 1 start */ + +/* Event Control Register */ + +#define AC_EVCTRL_COMPEO0 (1 << 0) /* Bit 0: Comparator 0 Event Output enable */ +#define AC_EVCTRL_COMPEO1 (1 << 1) /* Bit 1: Comparator 1 Event Output enable */ +#define AC_EVCTRL_WINEO0 (1 << 4) /* Bit 4: Window 0 Event Output enable */ +#define AC_EVCTRL_COMPEI0 (1 << 8) /* Bit 8: Comparator 0 Event Input enable */ +#define AC_EVCTRL_COMPEI1 (1 << 9) /* Bit 9: Comparator 1 Event Input enable */ + +/* Common bit definitions for Interrupt Enable Clear Register, Interrupt Enable Set + * Register, and Interrupt Flag Status and Clear Register + */ + +#define AC_INT_COMP0 (1 << 0) /* Bit 0: Comparator 0 */ +#define AC_INT_COMP1 (1 << 1) /* Bit 1: Comparator 1 */ +#define AC_INT_WIN0 (1 << 4) /* Bit 4: Window 0 */ +#define AC_INT_ALL 0x13 + +/* Status A Register */ + +#define AC_STATUSA_STATE0 (1 << 0) /* Bit 0: State 0 - Output state of comparator 0 */ +#define AC_STATUSA_STATE1 (1 << 1) /* Bit 1: State 1 - Output state of comparator 1 */ +#define AC_STATUSA_WSTATE_SHIFT (4) +#define AC_STATUSA_WSTATE_MASK (3 << AC_STATUSA_WSTATE_SHIFT) +# define AC_STATUSA_WSTATE_ABOVE (0 << AC_STATUSA_WSTATE_SHIFT) +# define AC_STATUSA_WSTATE_INSIDE (1 << AC_STATUSA_WSTATE_SHIFT) +# define AC_STATUSA_WSTATE_BELOW (2 << AC_STATUSA_WSTATE_SHIFT) + +/* Status B Register */ + +#define AC_STATUSB_READY0 (1 << 0) /* Bit 0: Ready 0 - Comparator 0 ready status */ +#define AC_STATUSB_READY1 (1 << 1) /* Bit 1: Ready 1 - Comparator 1 ready status */ +#define AC_STATUSB_SYNCBUSY (1 << 7) /* Bit 7: Synchronoziation ready */ + +/* Status C Register */ + +/* Window Control Register */ + +#define AC_WINCTRL_WEN0 (1 << 0) /* Bit 0: Window enable (both comparators) */ +#define AC_WINCTRL_WINTSEL_SHIFT (1) +#define AC_WINCTRL_WINTSEL_MASK (3 << AC_WINCTRL_WINTSEL_SHIFT) +# define AC_WINCTRL_WINTSEL_ABOVE (0 << AC_WINCTRL_WINTSEL_SHIFT) +# define AC_WINCTRL_WINTSEL_INSIDE (1 << AC_WINCTRL_WINTSEL_SHIFT) +# define AC_WINCTRL_WINTSEL_BELOW (2 << AC_WINCTRL_WINTSEL_SHIFT) +# define AC_WINCTRL_WINTSEL_OUTSIDE (3 << AC_WINCTRL_WINTSEL_SHIFT) + +/* Comparator Control Registers */ + +#define AC_COMPCTRL_ENABLE (1 << 0) /* Bit 0: Enable Comparator */ +#define AC_COMPCTRL_SINGLE (1 << 1) /* Bit 1: Single Shot Mode */ +#define AC_COMPCTRL_SPEED_SHIFT (2) +#define AC_COMPCTRL_SPEED_MASK (3 << AC_COMPCTRL_SPEED_SHIFT) +# define AC_COMPCTRL_SPEED_LOW (0 << AC_COMPCTRL_SPEED_SHIFT) +# define AC_COMPCTRL_SPEED_HIGH (1 << AC_COMPCTRL_SPEED_SHIFT) +#define AC_COMPCTRL_INTSEL_SHIFT (5) +#define AC_COMPCTRL_INTSEL_MASK (3 << AC_COMPCTRL_INTSEL_SHIFT) +# define AC_COMPCTRL_INTSEL_TOGGLE (0 << AC_COMPCTRL_INTSEL_SHIFT) +# define AC_COMPCTRL_INTSEL_RISING (1 << AC_COMPCTRL_INTSEL_SHIFT) +# define AC_COMPCTRL_INTSEL_FALLING (2 << AC_COMPCTRL_INTSEL_SHIFT) +# define AC_COMPCTRL_INTSEL_EOC (3 << AC_COMPCTRL_INTSEL_SHIFT) +#define AC_COMPCTRL_MUXNEG_SHIFT (8) +#define AC_COMPCTRL_MUXNEG_MASK (7 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_PIN0 (0 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_PIN1 (1 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_PIN2 (2 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_PIN3 (3 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_GND (4 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_VSCALE (5 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_BANDGAP (6 << AC_COMPCTRL_MUXNEG_SHIFT) +# define AC_COMPCTRL_MUXNEG_DAC (7 << AC_COMPCTRL_MUXNEG_SHIFT) +#define AC_COMPCTRL_MUXPOS_SHIFT (12) +#define AC_COMPCTRL_MUXPOS_MASK (3 << AC_COMPCTRL_MUXPOS_SHIFT) +# define AC_COMPCTRL_MUXPOS_PIN0 (0 << AC_COMPCTRL_MUXPOS_SHIFT) +# define AC_COMPCTRL_MUXPOS_PIN1 (1 << AC_COMPCTRL_MUXPOS_SHIFT) +# define AC_COMPCTRL_MUXPOS_PIN2 (2 << AC_COMPCTRL_MUXPOS_SHIFT) +# define AC_COMPCTRL_MUXPOS_PIN3 (3 << AC_COMPCTRL_MUXPOS_SHIFT) +#define AC_COMPCTRL_SWAP (1 << 13) /* Bit 13: Swap Inputs and Invert */ +#define AC_COMPCTRL_OUT_SHIFT (16) +#define AC_COMPCTRL_OUT_MASK (3 << AC_COMPCTRL_OUT_SHIFT) +# define AC_COMPCTRL_OUT_OFF (0 << AC_COMPCTRL_OUT_SHIFT) +# define AC_COMPCTRL_OUT_ASYNC (1 << AC_COMPCTRL_OUT_SHIFT) +# define AC_COMPCTRL_OUT_SYNC (2 << AC_COMPCTRL_OUT_SHIFT) +#define AC_COMPCTRL_HYST (1 << 19) /* Bit 19: Hysteresis Enable */ +#define AC_COMPCTRL_FLEN_SHIFT (24) +#define AC_COMPCTRL_FLEN_MASK (7 << AC_COMPCTRL_FLEN_SHIFT) +# define AC_COMPCTRL_FLEN_OFF (0 << AC_COMPCTRL_FLEN_SHIFT) +# define AC_COMPCTRL_FLEN_MAJ3 (1 << AC_COMPCTRL_FLEN_SHIFT) +# define AC_COMPCTRL_FLEN_MAJ5 (2 << AC_COMPCTRL_FLEN_SHIFT) + +/* Scaler Registers */ + +#define AC_COMPCTRL_SCALER_MASK (0x3f) + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAMD21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_AC_H */ diff --git a/arch/arm/src/samdl/chip/samd_dac.h b/arch/arm/src/samdl/chip/samd_dac.h new file mode 100644 index 0000000000000000000000000000000000000000..274cab701efad1975e8866108e8445b169417f1b --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_dac.h @@ -0,0 +1,136 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/saml_dac.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * References: + * "Atmel SAM L21E / SAM L21G / SAM L21J Smart ARM-Based Microcontroller + * Datasheet", Atmel-42385C-SAML21_Datasheet_Preliminary-03/20/15 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_DAC_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_DAC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAMD21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* DAC register offsets ********************************************************************/ + +#define SAM_DAC_CTRLA_OFFSET 0x0000 /* Control A Register */ +#define SAM_DAC_CTRLB_OFFSET 0x0001 /* Control B Register */ +#define SAM_DAC_EVCTRL_OFFSET 0x0002 /* Event Control Register */ +#define SAM_DAC_INTENCLR_OFFSET 0x0004 /* Interrupt Enable Clear Register */ +#define SAM_DAC_INTENSET_OFFSET 0x0005 /* Interrupt Enable Set Register */ +#define SAM_DAC_INTFLAG_OFFSET 0x0006 /* Interrupt Flag Status and Clear Register */ +#define SAM_DAC_STATUS_OFFSET 0x0007 /* Status Register */ +#define SAM_DAC_DATA0_OFFSET 0x0008 /* Data DAC0 Register */ +#define SAM_DAC_DATA1_OFFSET 0x0009 /* Data DAC1 Register */ +#define SAM_DAC_DATABUF0_OFFSET 0x000C /* Data Buffer DAC0 Register */ +#define SAM_DAC_DATABUF1_OFFSET 0x000D /* Data Buffer DAC1 Register */ + +/* DAC register addresses ******************************************************************/ + +#define SAM_DAC_CTRLA (SAM_DAC_BASE+SAM_DAC_CTRLA_OFFSET) +#define SAM_DAC_CTRLB (SAM_DAC_BASE+SAM_DAC_CTRLB_OFFSET) +#define SAM_DAC_EVCTRL (SAM_DAC_BASE+SAM_DAC_EVCTRL_OFFSET) +#define SAM_DAC_INTENCLR (SAM_DAC_BASE+SAM_DAC_INTENCLR_OFFSET) +#define SAM_DAC_INTENSET (SAM_DAC_BASE+SAM_DAC_INTENSET_OFFSET) +#define SAM_DAC_INTFLAG (SAM_DAC_BASE+SAM_DAC_INTFLAG_OFFSET) +#define SAM_DAC_STATUS (SAM_DAC_BASE+SAM_DAC_STATUS_OFFSET) +#define SAM_DAC_DATA0 (SAM_DAC_BASE+SAM_DAC_DATA0_OFFSET) +#define SAM_DAC_DATA1 (SAM_DAC_BASE+SAM_DAC_DATA1_OFFSET) +#define SAM_DAC_DATABUF0 (SAM_DAC_BASE+SAM_DAC_DATABUF0_OFFSET) +#define SAM_DAC_DATABUF1 (SAM_DAC_BASE+SAM_DAC_DATABUF1_OFFSET) + +/* DAC register bit definitions ************************************************************/ + +/* Control A Register */ + +#define DAC_CTRLA_SWRTS (1 << 0) /* Bit 0: Software reset */ +#define DAC_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable DAC controller */ +#define DAC_CTRLA_RUNSTDBY (1 << 2) /* Bit 1: Run in standby */ + +/* Control B Register */ + +#define DAC_CTRLB_EOEN (1 << 0) /* Bit 0: External Output Enable (to Vout) */ +#define DAC_CTRLB_IOEN (1 << 1) /* Bit 1: Internal Output Enable (to analog comparator) */ +#define DAC_CTRLB_LEFTADJ (1 << 2) /* Bit 2: Left-Adjusted Data */ +#define DAC_CTRLB_VPD (1 << 3) /* Bit 3: Voltage Pump Disabled */ +#define DAC_CTRLB_BDWP (1 << 4) /* Bit 4: Bypass DATABUF Write protection */ +#define DAC_CTRLB_REFSEL_SHIFT (6) /* Bit 7:6: Reference selection */ +#define DAC_CTRLB_REFSEL_MASK (3 << DAC_CTRLB_REFSEL_SHIFT) +# define DAC_CTRLB_REFSEL_INTREF (0 << DAC_CTRLB_REFSEL_SHIFT) /* Internal voltage reference */ +# define DAC_CTRLB_REFSEL_VDDANA (1 << DAC_CTRLB_REFSEL_SHIFT) /* Analog voltage supply */ +# define DAC_CTRLB_REFSEL_VREFA (2 << DAC_CTRLB_REFSEL_SHIFT) /* External voltage reference */ + +/* Event Control Register */ + +#define DAC_EVCTRL_STARTEI (1 << 0) /* Bit 0: Start conversion event input */ +#define DAC_EVCTRL_EMPTYEO (1 << 1) /* Bit 1: Data buffer empty event output */ + +/* Common bit definitions for Interrupt Enable Clear Register, Interrupt Enable Set + * Register, and Interrupt Flag Status and Clear Register + */ + +#define DAC_INT_UNDERRUN (1 << 0) /* Bit 0: Underrun interrupt */ +#define DAC_INT_EMPTY (1 << 1) /* Bit 1: Data buffer empty interrupt */ +#define DAC_INT_SYNCRDY (1 << 2) /* Bit 2: Sync ready */ +#define DAC_INT_ALL 0x07 + +/* Status Register */ + +#define DAC_STATUS_SYNCBUSY (1 << 7) /* Bit 0: Sync busy */ + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAMD21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_DAC_H */ diff --git a/arch/arm/src/samdl/chip/samd_dmac.h b/arch/arm/src/samdl/chip/samd_dmac.h new file mode 100644 index 0000000000000000000000000000000000000000..318fc38a42bb8d20813dda7835a2991f586af786 --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_dmac.h @@ -0,0 +1,399 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/samd_dmac.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * Matt Thompson + * + * References: + * "Atmel SAM L21E / SAM L21G / SAM L21J Smart ARM-Based Microcontroller + * Datasheet", Atmel-42385C-SAML21_Datasheet_Preliminary-03/20/15 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_DMAC_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_DMAC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* DMAC register offsets ********************************************************************/ + +#define SAM_DMAC_CTRL_OFFSET 0x0000 /* Control Register */ +#define SAM_DMAC_CRCCTRL_OFFSET 0x0002 /* CRC Control Register */ +#define SAM_DMAC_CRCDATAIN_OFFSET 0x0004 /* CRC Data Input Register */ +#define SAM_DMAC_CRCCHKSUM_OFFSET 0x0008 /* CRC Checksum Register */ +#define SAM_DMAC_CRCSTATUS_OFFSET 0x000c /* CRC Status Register */ +#define SAM_DMAC_DBGCTRL_OFFSET 0x000d /* Debug Control Register */ +#define SAM_DMAC_QOSCTRL_OFFSET 0x000e /* Quality of Service Control Register */ +#define SAM_DMAC_SWTRIGCTRL_OFFSET 0x0010 /* Software Trigger Control Register */ +#define SAM_DMAC_PRICTRL0_OFFSET 0x0014 /* Priority Control 0 Register */ +#define SAM_DMAC_INTPEND_OFFSET 0x0020 /* Interrupt Pending Register */ +#define SAM_DMAC_INTSTATUS_OFFSET 0x0024 /* Interrupt Status Register */ +#define SAM_DMAC_BUSYCH_OFFSET 0x0028 /* Busy Channels Register */ +#define SAM_DMAC_PENDCH_OFFSET 0x002c /* Pending Channels Register */ +#define SAM_DMAC_ACTIVE_OFFSET 0x0030 /* Active Channels and Levels Register */ +#define SAM_DMAC_BASEADDR_OFFSET 0x0034 /* Descriptor Memory Section Base Address Register */ +#define SAM_DMAC_WRBADDR_OFFSET 0x0038 /* Write-Back Memory Section Base Address Register */ +#define SAM_DMAC_CHID_OFFSET 0x003f /* Channel ID Register */ +#define SAM_DMAC_CHCTRLA_OFFSET 0x0040 /* Channel Control A Register */ +#define SAM_DMAC_CHCTRLB_OFFSET 0x0044 /* Channel Control B Register */ +#define SAM_DMAC_CHINTENCLR_OFFSET 0x004c /* Channel Interrupt Enable Clear Register */ +#define SAM_DMAC_CHINTENSET_OFFSET 0x004d /* Channel Interrupt Enable Set Register */ +#define SAM_DMAC_CHINTFLAG_OFFSET 0x004e /* Channel Interrupt Flag Status and Clear Register */ +#define SAM_DMAC_CHSTATUS_OFFSET 0x004f /* Channel Status Register */ + +/* LPSRAM Registers Relative to BASEADDR or WRBADDR */ + +#define SAM_LPSRAM_BTCTRL_OFFSET 0x0000 /* Block Transfer Control Register */ +#define SAM_LPSRAM_BTCNT_OFFSET 0x0002 /* Block Transfer Count Register */ +#define SAM_LPSRAM_SRCADDR_OFFSET 0x0004 /* Block Transfer Source Address Register */ +#define SAM_LPSRAM_DSTADDR_OFFSET 0x0008 /* Block Transfer Destination Address Register */ +#define SAM_LPSRAM_DESCADDR_OFFSET 0x000c /* Next Address Descriptor Register */ + +/* DMAC register addresses ******************************************************************/ + +#define SAM_DMAC_CTRL (SAM_DMAC_BASE+SAM_DMAC_CTRL_OFFSET) +#define SAM_DMAC_CRCCTRL (SAM_DMAC_BASE+SAM_DMAC_CRCCTRL_OFFSET) +#define SAM_DMAC_CRCDATAIN (SAM_DMAC_BASE+SAM_DMAC_CRCDATAIN_OFFSET) +#define SAM_DMAC_CRCCHKSUM (SAM_DMAC_BASE+SAM_DMAC_CRCCHKSUM_OFFSET) +#define SAM_DMAC_CRCSTATUS (SAM_DMAC_BASE+SAM_DMAC_CRCSTATUS_OFFSET) +#define SAM_DMAC_DBGCTRL (SAM_DMAC_BASE+SAM_DMAC_DBGCTRL_OFFSET) +#define SAM_DMAC_QOSCTRL (SAM_DMAC_BASE+SAM_DMAC_QOSCTRL_OFFSET) +#define SAM_DMAC_SWTRIGCTRL (SAM_DMAC_BASE+SAM_DMAC_SWTRIGCTRL_OFFSET) +#define SAM_DMAC_PRICTRL0 (SAM_DMAC_BASE+SAM_DMAC_PRICTRL0_OFFSET) +#define SAM_DMAC_INTPEND (SAM_DMAC_BASE+SAM_DMAC_INTPEND_OFFSET) +#define SAM_DMAC_INTSTATUS (SAM_DMAC_BASE+SAM_DMAC_INTSTATUS_OFFSET) +#define SAM_DMAC_BUSYCH (SAM_DMAC_BASE+SAM_DMAC_BUSYCH_OFFSET) +#define SAM_DMAC_PENDCH (SAM_DMAC_BASE+SAM_DMAC_PENDCH_OFFSET) +#define SAM_DMAC_ACTIVE (SAM_DMAC_BASE+SAM_DMAC_ACTIVE_OFFSET) +#define SAM_DMAC_BASEADDR (SAM_DMAC_BASE+SAM_DMAC_BASEADDR_OFFSET) +#define SAM_DMAC_WRBADDR (SAM_DMAC_BASE+SAM_DMAC_WRBADDR_OFFSET) +#define SAM_DMAC_CHID (SAM_DMAC_BASE+SAM_DMAC_CHID_OFFSET) +#define SAM_DMAC_CHCTRLA (SAM_DMAC_BASE+SAM_DMAC_CHCTRLA_OFFSET) +#define SAM_DMAC_CHCTRLB (SAM_DMAC_BASE+SAM_DMAC_CHCTRLB_OFFSET) +#define SAM_DMAC_CHINTENCLR (SAM_DMAC_BASE+SAM_DMAC_CHINTENCLR_OFFSET) +#define SAM_DMAC_CHINTENSET (SAM_DMAC_BASE+SAM_DMAC_CHINTENSET_OFFSET) +#define SAM_DMAC_CHINTFLAG (SAM_DMAC_BASE+SAM_DMAC_CHINTFLAG_OFFSET) +#define SAM_DMAC_CHSTATUS (SAM_DMAC_BASE+SAM_DMAC_CHSTATUS_OFFSET) + +/* DMAC register bit definitions ************************************************************/ + +/* Control Register */ + +#define DMAC_CTRL_SWRST (1 << 0) /* Bit 0: Software Reset */ +#define DMAC_CTRL_DMAENABLE (1 << 1) /* Bit 1: DMA Enable */ +#define DMAC_CTRL_CRCENABLE (1 << 2) /* Bit 2: CRC Enable */ +#define DMAC_CTRL_LVLEN0 (1 << 8) /* Bit 8: Priority level 0 Enable */ +#define DMAC_CTRL_LVLEN1 (1 << 9) /* Bit 9: Priority level 1 Enable */ +#define DMAC_CTRL_LVLEN2 (1 << 10) /* Bit 10: Priority level 2 Enable */ +#define DMAC_CTRL_LVLEN3 (1 << 11) /* Bit 10: Priority level 2 Enable */ + +/* CRC Control Register */ + +#define DMAC_CRCCTRL_CRCBEATSIZE_SHIFT (0) /* Bits 0-1: CRC beat size */ +#define DMAC_CRCCTRL_CRCBEATSIZE_MASK (3 < DMAC_CRCCTRL_CRCBEATSIZE_SHIFT) +# define DMAC_CRCCTRL_CRCBEATSIZE_BYTE (0 < DMAC_CRCCTRL_CRCBEATSIZE_SHIFT) /* 8-bit bus transfer */ +# define DMAC_CRCCTRL_CRCBEATSIZE_HWORD (1 < DMAC_CRCCTRL_CRCBEATSIZE_SHIFT) /* 16-bit bus transfer */ +# define DMAC_CRCCTRL_CRCBEATSIZE_WORD (2 < DMAC_CRCCTRL_CRCBEATSIZE_SHIFT) /* 32-bit bus transfer */ +#define DMAC_CRCCTRL_CRCPOLY_SHIFT (2) /* Bits 2-3: CRC polynomial type */ +#define DMAC_CRCCTRL_CRCPOLY_MASK (3 < DMAC_CRCCTRL_CRCPOLY_SHIFT) +# define DMAC_CRCCTRL_CRCPOLY_CRC16 (0 < DMAC_CRCCTRL_CRCPOLY_SHIFT) /* CRC-16 (CRC-CCITT) */ +# define DMAC_CRCCTRL_CRCPOLY_CRC32 (1 < DMAC_CRCCTRL_CRCPOLY_SHIFT) /* CRC32 (IEEE 802.3) */ +#define DMAC_CRCCTRL_CRCSRC_SHIFT (8) /* Bits 8-13: CRC Input Source */ +#define DMAC_CRCCTRL_CRCSRC_MASK (0x3f < DMAC_CRCCTRL_CRCSRC_SHIFT) +# define DMAC_CRCCTRL_CRCSRC_NOACTION (0 < DMAC_CRCCTRL_CRCSRC_SHIFT) /* No action */ +# define DMAC_CRCCTRL_CRCSRC_IO (1 < DMAC_CRCCTRL_CRCSRC_SHIFT) /* I/O interface */ +# define DMAC_CRCCTRL_CRCSRC_CHAN(n) (((uint32_t)(n) + 0x20) < DMAC_CRCCTRL_CRCSRC_SHIFT) + +/* CRC Data Input Register (32-bit value) */ +/* CRC Checksum Register (32-bit value) */ + +/* CRC Status Register */ + +#define DMAC_CRCSTATUS_CRCBUSY (1 << 0) /* Bit 0: CRC module busy */ +#define DMAC_CRCSTATUS_CRCZERO (1 << 1) /* Bit 1: CRC zero */ + +/* Debug Control Register */ + +#define DMAC_DBGCTRL_DBGRUN (1 << 0) /* Bit 0: Debug run */ + +/* Quality of Service Control Register */ + +#define DMAC_QOSCTRL_WRBQOS_SHIFT (0) /* Bits 0-1: Write back quality of service */ +#define DMAC_QOSCTRL_WRBQOS_MASK (3 << DMAC_QOSCTRL_WRBQOS_SHIFT) +# define DMAC_QOSCTRL_WRBQOS_DISABLE (0 << DMAC_QOSCTRL_WRBQOS_SHIFT) /* Background */ +# define DMAC_QOSCTRL_WRBQOS_LOW (1 << DMAC_QOSCTRL_WRBQOS_SHIFT) /* Sensitive bandwidth */ +# define DMAC_QOSCTRL_WRBQOS_MEDIUM (2 << DMAC_QOSCTRL_WRBQOS_SHIFT) /* Sensitive latency */ +# define DMAC_QOSCTRL_WRBQOS_HIGH (3 << DMAC_QOSCTRL_WRBQOS_SHIFT) /* Critical latency */ +#define DMAC_QOSCTRL_FQOS_SHIFT (2) /* Bits 2-3: Fetch quality of service */ +#define DMAC_QOSCTRL_FQOS_MASK (3 << DMAC_QOSCTRL_FQOS_SHIFT) +# define DMAC_QOSCTRL_FQOS_DISABLE (0 << DMAC_QOSCTRL_FQOS_SHIFT) /* Background */ +# define DMAC_QOSCTRL_FQOS_LOW (1 << DMAC_QOSCTRL_FQOS_SHIFT) /* Sensitive bandwidth */ +# define DMAC_QOSCTRL_FQOS_MEDIUM (2 << DMAC_QOSCTRL_FQOS_SHIFT) /* Sensitive latency */ +# define DMAC_QOSCTRL_FQOS_HIGH (3 << DMAC_QOSCTRL_FQOS_SHIFT) /* Critical latency */ +#define DMAC_QOSCTRL_DQOS_SHIFT (4) /* Bits 4-5: Data transfer quality of service */ +#define DMAC_QOSCTRL_DQOS_MASK (3 << DMAC_QOSCTRL_DQOS_SHIFT) +# define DMAC_QOSCTRL_DQOS_DISABLE (0 << DMAC_QOSCTRL_DQOS_SHIFT) /* Background */ +# define DMAC_QOSCTRL_DQOS_LOW (1 << DMAC_QOSCTRL_DQOS_SHIFT) /* Sensitive bandwidth */ +# define DMAC_QOSCTRL_DQOS_MEDIUM (2 << DMAC_QOSCTRL_DQOS_SHIFT) /* Sensitive latency */ +# define DMAC_QOSCTRL_DQOS_HIGH (3 << DMAC_QOSCTRL_DQOS_SHIFT) /* Critical latency */ + +/* Common bit definitions for: Software Trigger Control Register, Interrupt Status Register, + * Busy Channels Register, and Pending Channels Register + */ + +#define DMAC_CHAN(n) (1 << (n)) /* DMAC Channel n, n=0-11 */ + +/* Priority Control 0 Register */ + +#define DMAC_PRICTRL0_LVLPRI0_SHIFT (0) /* Bits 0-3: Level 0 channel priority number */ +#define DMAC_PRICTRL0_LVLPRI0_MASK (15 << DMAC_PRICTRL0_LVLPRI0_SHIFT) +# define DMAC_PRICTRL0_LVLPRI0(n) ((uint32_t)(n) << DMAC_PRICTRL0_LVLPRI0_SHIFT) +#define DMAC_PRICTRL0_RRLVLEN0 (1 << 7) /* Bit 7: Level 0 round-robin arbitrarion enable */ +#define DMAC_PRICTRL0_LVLPRI1_SHIFT (8) /* Bits 8-11: Level 1 channel priority number */ +#define DMAC_PRICTRL0_LVLPRI1_MASK (15 << DMAC_PRICTRL0_LVLPRI1_SHIFT) +# define DMAC_PRICTRL0_LVLPRI1(n) ((uint32_t)(n) << DMAC_PRICTRL0_LVLPRI1_SHIFT) +#define DMAC_PRICTRL0_RRLVLEN1 (1 << 15) /* Bit 15: Level 1 round-robin arbitrarion enable */ +#define DMAC_PRICTRL0_LVLPRI2_SHIFT (16) /* Bits 16-18: Level 2 channel priority number */ +#define DMAC_PRICTRL0_LVLPRI2_MASK (7 << DMAC_PRICTRL0_LVLPRI2_SHIFT) +# define DMAC_PRICTRL0_LVLPRI2(n) ((uint32_t)(n) << DMAC_PRICTRL0_LVLPRI2_SHIFT) +#define DMAC_PRICTRL0_RRLVLEN2 (1 << 23) /* Bit 23: Level 2 round-robin arbitrarion enable */ +#define DMAC_PRICTRL0_LVLPRI3_SHIFT (24) /* Bits 24-27: Level 3 channel priority number */ +#define DMAC_PRICTRL0_LVLPRI3_MASK (7 << DMAC_PRICTRL0_LVLPRI3_SHIFT) +# define DMAC_PRICTRL0_LVLPRI3(n) ((uint32_t)(n) << DMAC_PRICTRL0_LVLPRI3_SHIFT) +#define DMAC_PRICTRL0_RRLVLEN3 (1 << 31) /* Bit 23: Level 3 round-robin arbitrarion enable */ + +/* Interrupt Pending Register */ + +#define DMAC_INTPEND_ID_SHIFT (0) /* Bit 0-3: Channel ID */ +#define DMAC_INTPEND_ID_MASK (15 << DMAC_INTPEND_ID_SHIFT) +#define DMAC_INTPEND_TERR (1 << 8) /* Bit 8: Transfer error */ +#define DMAC_INTPEND_TCMPL (1 << 9) /* Bit 9: Transfer complete */ +#define DMAC_INTPEND_SUSP (1 << 10) /* Bit 10: Channel suspend */ +#define DMAC_INTPEND_FERR (1 << 13) /* Bit 13: Fetch error */ +#define DMAC_INTPEND_BUSY (1 << 14) /* Bit 14: Busy */ +#define DMAC_INTPEND_PEND (1 << 15) /* Bit 15: Pending */ + +/* Interrupt Status Register */ +/* Busy Channels Register */ +/* Pending Channels Register */ + +/* Active Channels and Levels Register */ + +#define DMAC_ACTIVE_LVLEX0 (1 << 0) /* Bit 0: Level 0 channel trigger request executing */ +#define DMAC_ACTIVE_LVLEX1 (1 << 1) /* Bit 1: Level 1 channel trigger request executing */ +#define DMAC_ACTIVE_LVLEX2 (1 << 2) /* Bit 2: Level 2 channel trigger request executing */ +#define DMAC_ACTIVE_LVLEX3 (1 << 3) /* Bit 3: Level 3 channel trigger request executing */ +#define DMAC_ACTIVE_ID_SHIFT (8) /* Bits 8-11: Active channel ID */ +#define DMAC_ACTIVE_ID_MASK (15 << DMAC_ACTIVE_ID_SHIFT) +#define DMAC_ACTIVE_ABUSY (1 << 15) /* Bit 15: Active channel busy */ +#define DMAC_ACTIVE_BTCNT_SHIFT (16) /* Bit 16-31: Active channel block transfer count */ +#define DMAC_ACTIVE_BTCNT_MASK (0xffff << DMAC_ACTIVE_BTCNT_SHIFT) + +/* Descriptor Memory Section Base Address Register (32-bit address) */ +/* Write-Back Memory Section Base Address Register (31-bit address) */ + +/* Channel ID Register */ + +#define DMAC_CHID_MASK 0x0f /* Bits 0-3: Channel ID */ + +/* Channel Control A Register */ + +#define DMAC_CHCTRLA_SWRST (1 << 0) /* Bit 0: Channel software reset */ +#define DMAC_CHCTRLA_ENABLE (1 << 1) /* Bit 1: Channel enable */ + +/* Channel Control B Register */ + +#define DMAC_CHCTRLB_EVACT_SHIFT (0) /* Bits 0-2: Event input action */ +#define DMAC_CHCTRLB_EVACT_MASK (7 << DMAC_CHCTRLB_EVACT_SHIFT) +# define DMAC_CHCTRLB_EVACT_NOACT (0 << DMAC_CHCTRLB_EVACT_SHIFT) /* No action */ +# define DMAC_CHCTRLB_EVACT_TRIG (1 << DMAC_CHCTRLB_EVACT_SHIFT) /* Normal Transfer and Conditional Transfer on Strobe +trigger */ +# define DMAC_CHCTRLB_EVACT_CTRIG (2 << DMAC_CHCTRLB_EVACT_SHIFT) /* Conditional transfer trigger */ +# define DMAC_CHCTRLB_EVACT_CBLOCK (3 << DMAC_CHCTRLB_EVACT_SHIFT) /* Conditional block transfer */ +# define DMAC_CHCTRLB_EVACT_SUSPEND (4 << DMAC_CHCTRLB_EVACT_SHIFT) /* Channel suspend operation */ +# define DMAC_CHCTRLB_EVACT_RESUME (5 << DMAC_CHCTRLB_EVACT_SHIFT) /* Channel resume operation */ +# define DMAC_CHCTRLB_EVACT_SSKIP (6 << DMAC_CHCTRLB_EVACT_SHIFT) /* Skip next block suspend action */ +#define DMAC_CHCTRLB_EVIE (1 << 3) /* Bit 3: Channel event input enable */ +#define DMAC_CHCTRLB_EVOE (1 << 4) /* Bit 4: Channel event output enable */ +#define DMAC_CHCTRLB_LVL_SHIFT (5) /* Bits 5-6: Channel arbitration level */ +#define DMAC_CHCTRLB_LVL_MASK (3 << DMAC_CHCTRLB_LVL_SHIFT) +# define DMAC_CHCTRLB_LVL(n) ((uint32_t)(n) << DMAC_CHCTRLB_LVL_SHIFT) +# define DMAC_CHCTRLB_LVL_LVL0 (0 << DMAC_CHCTRLB_LVL_SHIFT) /* Channel priority level 0 */ +# define DMAC_CHCTRLB_LVL_LVL1 (1 << DMAC_CHCTRLB_LVL_SHIFT) /* Channel priority level 1 */ +# define DMAC_CHCTRLB_LVL_LVL2 (2 << DMAC_CHCTRLB_LVL_SHIFT) /* Channel priority level 2 */ +# define DMAC_CHCTRLB_LVL_LVL3 (3 << DMAC_CHCTRLB_LVL_SHIFT) /* Channel priority level 3 */ +#define DMAC_CHCTRLB_TRIGSRC_SHIFT (8) /* Bits 8-13: Trigger source */ +#define DMAC_CHCTRLB_TRIGSRC_MASK (0x3f << DMAC_CHCTRLB_TRIGSRC_SHIFT) + #define DMAC_CHCTRLB_TRIGSRC(n) ((uint32_t)(n) << DMAC_CHCTRLB_TRIGSRC_SHIFT) +#define DMAC_CHCTRLB_TRIGACT_SHIFT (22) /* Bits 22-23: Trigger action */ +#define DMAC_CHCTRLB_TRIGACT_MASK (3 << DMAC_CHCTRLB_TRIGACT_SHIFT) +# define DMAC_CHCTRLB_TRIGACT_BLOCK (0 << DMAC_CHCTRLB_TRIGACT_SHIFT) /* One trigger required for each action */ +# define DMAC_CHCTRLB_TRIGACT_BEAT (2 << DMAC_CHCTRLB_TRIGACT_SHIFT) /* One trigger required for beat transfer */ +# define DMAC_CHCTRLB_TRIGACT_TRANSACT (3 << DMAC_CHCTRLB_TRIGACT_SHIFT) /* One trigger required for each transaction */ +#define DMAC_CHCTRLB_CMD_SHIFT (24) /* Bits 24-25: Software command */ +#define DMAC_CHCTRLB_CMD_MASK (3 << DMAC_CHCTRLB_CMD_SHIFT) +# define DMAC_CHCTRLB_CMD_NOACTION (0 << DMAC_CHCTRLB_CMD_SHIFT) /* No action */ +# define DMAC_CHCTRLB_CMD_SUSPEND (1 << DMAC_CHCTRLB_CMD_SHIFT) /* Channel suspend operation */ +# define DMAC_CHCTRLB_CMD_RESUME (2 << DMAC_CHCTRLB_CMD_SHIFT) /* Channel resume operation */ + +/* Values for use with the DMAC_CHCTRLB_TRIGSRC(n) macro: */ + +#define DMAC_TRIGSRC_DISABLE (0) /* Only software/event triggers */ +#define DMAC_TRIGSRC_SERCOM0_RX (1) /* SERCOM0 RX Trigger */ +#define DMAC_TRIGSRC_SERCOM0_TX (2) /* SERCOM0 TX Trigger */ +#define DMAC_TRIGSRC_SERCOM1_RX (3) /* SERCOM1 RX Trigger */ +#define DMAC_TRIGSRC_SERCOM1_TX (4) /* SERCOM1 TX Trigger */ +#define DMAC_TRIGSRC_SERCOM2_RX (5) /* SERCOM2 RX Trigger */ +#define DMAC_TRIGSRC_SERCOM2_TX (6) /* SERCOM2 TX Trigger */ +#define DMAC_TRIGSRC_SERCOM3_RX (7) /* SERCOM3 RX Trigger */ +#define DMAC_TRIGSRC_SERCOM3_TX (8) /* SERCOM3 TX Trigger */ +#define DMAC_TRIGSRC_SERCOM4_RX (9) /* SERCOM4 RX Trigger */ +#define DMAC_TRIGSRC_SERCOM4_TX (10) /* SERCOM4 TX Trigger */ +#define DMAC_TRIGSRC_SERCOM5_RX (11) /* SERCOM4 RX Trigger */ +#define DMAC_TRIGSRC_SERCOM5_TX (12) /* SERCOM4 TX Trigger */ +#define DMAC_TRIGSRC_TCC0_OVF (13) /* TCC0 Overflow Trigger */ +#define DMAC_TRIGSRC_TCC0_MC0 (14) /* TCC0 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TCC0_MC1 (15) /* TCC0 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TCC0_MC2 (16) /* TCC0 Match/Compare 2 Trigger */ +#define DMAC_TRIGSRC_TCC0_MC3 (17) /* TCC0 Match/Compare 3 Trigger */ +#define DMAC_TRIGSRC_TCC1_OVF (18) /* TCC1 Overflow Trigger */ +#define DMAC_TRIGSRC_TCC1_MC0 (19) /* TCC1 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TCC1_MC1 (20) /* TCC1 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TCC2_OVF (21) /* TCC2 Overflow Trigger */ +#define DMAC_TRIGSRC_TCC2_MC0 (22) /* TCC2 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TCC2_MC1 (23) /* TCC2 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TC0_OVF (24) /* TC0 Overflow Trigger */ +#define DMAC_TRIGSRC_TC0_MC0 (25) /* TC0 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TC0 MC1 (26) /* TC0 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TC1_OVF (27) /* TC1 Overflow Trigger */ +#define DMAC_TRIGSRC_TC1_MC0 (28) /* TC1 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TC1_MC1 (29) /* TC1 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TC2_OVF (30) /* TC2 Overflow Trigger */ +#define DMAC_TRIGSRC_TC2_MC0 (31) /* TC2 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TC2_MC1 (32) /* TC2 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TC3_OVF (33) /* TC3 Overflow Trigger */ +#define DMAC_TRIGSRC_TC3_MC0 (34) /* TC3 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TC3_MC1 (35) /* TC3 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_TC4_OVF (36) /* TC4 Overflow Trigger */ +#define DMAC_TRIGSRC_TC4_MC0 (37) /* TC4 Match/Compare 0 Trigger */ +#define DMAC_TRIGSRC_TC4_MC1 (38) /* TC4 Match/Compare 1 Trigger */ +#define DMAC_TRIGSRC_ADC_RESRDY (39) /* ADC Result Ready Trigger */ +#define DMAC_TRIGSRC_DAC_EMPTY (40) /* DAC0 Empty Trigger */ +#define DMAC_TRIGSRC_I2S0_RX (41) /* I2S0 RX Trigger */ +#define DMAC_TRIGSRC_I2S1_RX (42) /* I2S1 RX Trigger */ +#define DMAC_TRIGSRC_I2S0_TX (43) /* I2S0 TX Trigger */ +#define DMAC_TRIGSRC_I2S1_TX (44) /* I2S1 TX Trigger */ + +/* Common register bit definitions: Channel Interrupt Enable Clear Register, Channel Interrupt + * Enable Set Register, and Channel Interrupt Flag Status and Clear Register + */ + +#define DMAC_INT_TERR (1 << 0) /* Bit 0: Transfer error interrupt */ +#define DMAC_INT_TCMPL (1 << 1) /* Bit 1: Channel transfer complete interrupt */ +#define DMAC_INT_SUSP (1 << 2) /* Bit 2: Channel suspend interrupt */ +#define DMAC_INT_ALL (0x07) + +/* Channel Status Register */ + +#define DMAC_CHSTATUS_PEND (1 << 0) /* Bit 0: Chennel pending */ +#define DMAC_CHSTATUS_BUSY (1 << 1) /* Bit 1: Channel busy */ +#define DMAC_CHSTATUS_FERR (1 << 2) /* Bit 2: Channel fetch error */ + +/* Block Transfer Control Register */ + +#define LPSRAM_BTCTRL_VALID (1 << 0) /* Bit 0: Descriptor valid */ +#define LPSRAM_BTCTRL_EVOSEL_SHIFT (1) /* Bits 1-2: Event output selection */ +#define LPSRAM_BTCTRL_EVOSEL_MASK (3 << LPSRAM_BTCTRL_EVOSEL_SHIFT) +# define LPSRAM_BTCTRL_EVOSEL_DISABLE (0 << LPSRAM_BTCTRL_EVOSEL_SHIFT) /* Event generation disabled */ +# define LPSRAM_BTCTRL_EVOSEL_BLOCK (1 << LPSRAM_BTCTRL_EVOSEL_SHIFT) /* Event strobe when block transfer complete */ +# define LPSRAM_BTCTRL_EVOSEL_BEAT (3 << LPSRAM_BTCTRL_EVOSEL_SHIFT) /* Event strobe when beat transfer complete */ +#define LPSRAM_BTCTRL_BLOCKACT_SHIFT (3) /* Bits 3-4: Block action */ +#define LPSRAM_BTCTRL_BLOCKACT_MASK (3 << LPSRAM_BTCTRL_BLOCKACT_SHIFT) +# define LPSRAM_BTCTRL_BLOCKACT_NOACT (0 << LPSRAM_BTCTRL_BLOCKACT_SHIFT) /* Channel disabled if last block transfer */ +# define LPSRAM_BTCTRL_BLOCKACT_INT (1 << LPSRAM_BTCTRL_BLOCKACT_SHIFT) /* Channel disabled if last block transfer + block int */ +# define LPSRAM_BTCTRL_BLOCKACT_SUSPEND (2 << LPSRAM_BTCTRL_BLOCKACT_SHIFT) /* Channel suspend operation is completed */ +# define LPSRAM_BTCTRL_BLOCKACT_BOTH (3 << LPSRAM_BTCTRL_BLOCKACT_SHIFT) /* Both channel suspend operation + block int */ +#define LPSRAM_BTCTRL_BEATSIZE_SHIFT (8) /* Bits 8-9: Beat size */ +#define LPSRAM_BTCTRL_BEATSIZE_MASK (3 << LPSRAM_BTCTRL_BEATSIZE_SHIFT) +# define LPSRAM_BTCTRL_BEATSIZE_BYTE (0 << LPSRAM_BTCTRL_BEATSIZE_SHIFT) /* 8-bit bus transfer */ +# define LPSRAM_BTCTRL_BEATSIZE_HWORD (1 << LPSRAM_BTCTRL_BEATSIZE_SHIFT) /* 16-bit bus transfer */ +# define LPSRAM_BTCTRL_BEATSIZE_WORD (2 << LPSRAM_BTCTRL_BEATSIZE_SHIFT) /* 32-bit bus transfer */ +#define LPSRAM_BTCTRL_SRCINC (1 << 10) /* Bit 10: Source address increment enable */ +#define LPSRAM_BTCTRL_DSTINC (1 << 11) /* Bit 11: Destination address increment enable */ +#define LPSRAM_BTCTRL_STEPSEL (1 << 12) /* Bit 12: Step selection */ +#define LPSRAM_BTCTRL_STEPSIZE_SHIFT (13) /* Bits 13-15: Address increment step */ +#define LPSRAM_BTCTRL_STEPSIZE_MASK (7 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) +# define LPSRAM_BTCTRL_STEPSIZE_X1 (0 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 1 */ +# define LPSRAM_BTCTRL_STEPSIZE_X2 (1 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 2 */ +# define LPSRAM_BTCTRL_STEPSIZE_X4 (2 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 4 */ +# define LPSRAM_BTCTRL_STEPSIZE_X8 (3 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 8 */ +# define LPSRAM_BTCTRL_STEPSIZE_X16 (4 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 16 */ +# define LPSRAM_BTCTRL_STEPSIZE_X32 (5 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 32 */ +# define LPSRAM_BTCTRL_STEPSIZE_X64 (6 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 64 */ +# define LPSRAM_BTCTRL_STEPSIZE_X128 (7 << LPSRAM_BTCTRL_STEPSIZE_SHIFT) /* Next ADDR = ADDR + (BEATSIZE+1) * 128 */ + +/* Block Transfer Count Register (16-bit count) */ +/* Block Transfer Source Address Register (32-bit address) */ +/* Block Transfer Destination Address Register (32-bit address) */ +/* Next Address Descriptor Register (32-bit address) */ + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ +/* DMA descriptor */ + +struct dma_desc_s +{ + uint16_t btctrl; /* Block Transfer Control Register */ + uint16_t btcnt; /* Block Transfer Count Register */ + uint32_t srcaddr; /* Block Transfer Source Address Register */ + uint32_t dstaddr; /* Block Transfer Destination Address Register */ + uint32_t descaddr; /* Next Address Descriptor Register */ +}; + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_DMAC_H */ diff --git a/arch/arm/src/samdl/chip/samd_eic.h b/arch/arm/src/samdl/chip/samd_eic.h new file mode 100644 index 0000000000000000000000000000000000000000..adc898212446e94557199fd26bbcc984556d3058 --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_eic.h @@ -0,0 +1,190 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/samd_eic.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * Matt Thompson + * + * References: + * "Microchip SAMD21 datasheet" + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_EIC_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_EIC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAMD21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* EIC register offsets *********************************************************************/ + +#define SAM_EIC_CTRLA_OFFSET 0x0000 /* Control A register */ +#define SAM_EIC_STATUS_OFFSET 0x0001 /* Status register */ +#define SAM_EIC_NMICTRL_OFFSET 0x0002 /* Non-maskable interrupt control register */ +#define SAM_EIC_NMIFLAG_OFFSET 0x0003 /* Non-maskable interrupt flag register */ +#define SAM_EIC_EVCTRL_OFFSET 0x0004 /* Event control register */ +#define SAM_EIC_INTENCLR_OFFSET 0x0008 /* Interrupt enable clear register */ +#define SAM_EIC_INTENSET_OFFSET 0x000c /* Interrupt enable set register */ +#define SAM_EIC_INTFLAG_OFFSET 0x0010 /* Interrupt flag and status clear register */ +#define SAM_EIC_WAKEUP_OFFSET 0x0014 /* Wakeup register */ +#define SAM_EIC_CONFIG0_OFFSET 0x0018 /* Configuration 0 register */ +#define SAM_EIC_CONFIG1_OFFSET 0x001c /* Configuration 1 register */ +#define SAM_EIC_CONFIG2_OFFSET 0x0020 /* Configuration 2 register */ + +/* EIC register addresses *******************************************************************/ + +#define SAM_EIC_CTRLA (SAM_EIC_BASE+SAM_EIC_CTRLA_OFFSET) +#define SAM_EIC_STATUS (SAM_EIC_BASE+SAM_EIC_STATUS_OFFSET) +#define SAM_EIC_NMICTRL (SAM_EIC_BASE+SAM_EIC_NMICTRL_OFFSET) +#define SAM_EIC_NMIFLAG (SAM_EIC_BASE+SAM_EIC_NMIFLAG_OFFSET) +#define SAM_EIC_EVCTRL (SAM_EIC_BASE+SAM_EIC_EVCTRL_OFFSET) +#define SAM_EIC_INTENCLR (SAM_EIC_BASE+SAM_EIC_INTENCLR_OFFSET) +#define SAM_EIC_INTENSET (SAM_EIC_BASE+SAM_EIC_INTENSET_OFFSET) +#define SAM_EIC_INTFLAG (SAM_EIC_BASE+SAM_EIC_INTFLAG_OFFSET) +#define SAM_EIC_WAKEUP (SAM_EIC_BASE+SAM_EIC_WAKEUP_OFFSET) +#define SAM_EIC_CONFIG0 (SAM_EIC_BASE+SAM_EIC_CONFIG0_OFFSET) +#define SAM_EIC_CONFIG1 (SAM_EIC_BASE+SAM_EIC_CONFIG1_OFFSET) +#define SAM_EIC_CONFIG2 (SAM_EIC_BASE+SAM_EIC_CONFIG2_OFFSET) + +/* EIC register bit definitions *************************************************************/ + +/* Control A register */ + +#define EIC_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */ +#define EIC_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */ + +/* Status register */ + +#define EIC_STATUS_SYNCBUSY (1 << 7) /* Bit 7: Syncronization busy */ + +/* Non-maskable interrupt control register */ + +#define EIC_NMICTRL_NMISENSE_SHIFT (0) /* Bits 0-2: Non-maskable interrupt sense */ +#define EIC_NMICTRL_NMISENSE_MASK (7 << EIC_NVMICTRL_NMISENSE_SHIFT) +# define EIC_NMICTRL_NMISENSE_NONE (0 << EIC_NVMICTRL_NMISENSE_SHIFT) /* No detection */ +# define EIC_NMICTRL_NMISENSE_RISE (1 << EIC_NVMICTRL_NMISENSE_SHIFT) /* Rising edge detection */ +# define EIC_NMICTRL_NMISENSE_FALL (2 << EIC_NVMICTRL_NMISENSE_SHIFT) /* Falling edge detection */ +# define EIC_NMICTRL_NMISENSE_BOTH (3 << EIC_NVMICTRL_NMISENSE_SHIFT) /* Both edge detection */ +# define EIC_NMICTRL_NMISENSE_HIGH (4 << EIC_NVMICTRL_NMISENSE_SHIFT) /* High level detection */ +# define EIC_NMICTRL_NMISENSE_LOW (5 << EIC_NVMICTRL_NMISENSE_SHIFT) /* Low level detection */ +#define EIC_NMICTRL_NMIFLTEN (1 << 3) /* Bit 3: Non-maskable interrupt filter enable */ + +/* Non-maskable interrupt flas status and clear register */ + +#define EIC_NMIFLAG_NMI (1 << 0) /* Non-maskable interrupt */ + +/* Event control, Interrupt enable clear, interrupt enable set register, interrupt flag + * status and clear, and external interrupt wakeup registers. + */ + +#define EIC_EXTINT_SHIFT (0) /* Bits 0-15: External interrupt n */ +#define EIC_EXTINT_MASK (0x3ffff << EIC_EXTINT_SHIFT) +# define EIC_EXTINT(n) (1 << (n)) +# define EIC_EXTINT_0 (1 << 0) /* Bit 0: External interrupt 0 */ +# define EIC_EXTINT_1 (1 << 1) /* Bit 1: External interrupt 1 */ +# define EIC_EXTINT_2 (1 << 2) /* Bit 2: External interrupt 2 */ +# define EIC_EXTINT_3 (1 << 3) /* Bit 3: External interrupt 3 */ +# define EIC_EXTINT_4 (1 << 4) /* Bit 4: External interrupt 4 */ +# define EIC_EXTINT_5 (1 << 5) /* Bit 5: External interrupt 5 */ +# define EIC_EXTINT_6 (1 << 6) /* Bit 6: External interrupt 6 */ +# define EIC_EXTINT_7 (1 << 7) /* Bit 7: External interrupt 7 */ +# define EIC_EXTINT_8 (1 << 8) /* Bit 8: External interrupt 8 */ +# define EIC_EXTINT_9 (1 << 9) /* Bit 9: External interrupt 9 */ +# define EIC_EXTINT_10 (1 << 10) /* Bit 10: External interrupt 10 */ +# define EIC_EXTINT_11 (1 << 11) /* Bit 11: External interrupt 11 */ +# define EIC_EXTINT_12 (1 << 12) /* Bit 12: External interrupt 12 */ +# define EIC_EXTINT_13 (1 << 13) /* Bit 13: External interrupt 13 */ +# define EIC_EXTINT_14 (1 << 14) /* Bit 14: External interrupt 14 */ +# define EIC_EXTINT_15 (1 << 15) /* Bit 15: External interrupt 15 */ +# define EIC_EXTINT_16 (1 << 16) /* Bit 16: External interrupt 16 */ +# define EIC_EXTINT_17 (1 << 17) /* Bit 17: External interrupt 17 */ + +#define EIC_EXTINT_ALL EIC_EXTINT_MASK + +/* Configuration 0 register */ + +#define EIC_CONFIG0_FILTEN(n) (0x8 << ((n) << 2)) /* Filter n enable, n=0-7 */ +#define EIC_CONFIG0_SENSE_SHIFT(n) ((n) << 2) /* Filter n input sense, n=0-7 */ +#define EIC_CONFIG0_SENSE_MASK(n) (7 << EIC_CONFIG0_SENSE_SHIFT(n)) +# define EIC_CONFIG0_SENSE_NONE(n) (0 << EIC_CONFIG0_SENSE_SHIFT(n)) /* No detection */ +# define EIC_CONFIG0_SENSE_RISE(n) (1 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Rising edge detection */ +# define EIC_CONFIG0_SENSE_FALL(n) (2 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Falling edge detection */ +# define EIC_CONFIG0_SENSE_BOTH(n) (3 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Both edge detection */ +# define EIC_CONFIG0_SENSE_HIGH(n) (4 << EIC_CONFIG0_SENSE_SHIFT(n)) /* High level detection */ +# define EIC_CONFIG0_SENSE_LOW(n) (5 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Low level detection */ + +/* Configuration 1 register */ + +#define EIC_CONFIG1_FILTEN(n) (0x8 << (((n) - 8) << 2)) /* Filter n enable, n=8-15 */ +#define EIC_CONFIG1_SENSE_SHIFT(n) (((n) - 8) << 2) /* Filter n input sense, n=8-17 */ +#define EIC_CONFIG1_SENSE_MASK(n) (7 << EIC_CONFIG1_SENSE_SHIFT(n)) +# define EIC_CONFIG1_SENSE_NONE(n) (0 << EIC_CONFIG1_SENSE_SHIFT(n)) /* No detection */ +# define EIC_CONFIG1_SENSE_RISE(n) (1 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Rising edge detection */ +# define EIC_CONFIG1_SENSE_FALL(n) (2 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Falling edge detection */ +# define EIC_CONFIG1_SENSE_BOTH(n) (3 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Both edge detection */ +# define EIC_CONFIG1_SENSE_HIGH(n) (4 << EIC_CONFIG1_SENSE_SHIFT(n)) /* High level detection */ +# define EIC_CONFIG1_SENSE_LOW(n) (5 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Low level detection */ + +/* Configuration 2 register */ + +#define EIC_CONFIG2_FILTEN(n) (0x8 << (((n) - 16) << 2)) /* Filter n enable, n=16-23 */ +#define EIC_CONFIG2_SENSE_SHIFT(n) (((n) - 16) << 2) /* Filter n input sense, n=16-23 */ +#define EIC_CONFIG2_SENSE_MASK(n) (7 << EIC_CONFIG2_SENSE_SHIFT(n)) +# define EIC_CONFIG2_SENSE_NONE(n) (0 << EIC_CONFIG2_SENSE_SHIFT(n)) /* No detection */ +# define EIC_CONFIG2_SENSE_RISE(n) (1 << EIC_CONFIG2_SENSE_SHIFT(n)) /* Rising edge detection */ +# define EIC_CONFIG2_SENSE_FALL(n) (2 << EIC_CONFIG2_SENSE_SHIFT(n)) /* Falling edge detection */ +# define EIC_CONFIG2_SENSE_BOTH(n) (3 << EIC_CONFIG2_SENSE_SHIFT(n)) /* Both edge detection */ +# define EIC_CONFIG2_SENSE_HIGH(n) (4 << EIC_CONFIG2_SENSE_SHIFT(n)) /* High level detection */ +# define EIC_CONFIG2_SENSE_LOW(n) (5 << EIC_CONFIG2_SENSE_SHIFT(n)) /* Low level detection */ + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAMD21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_EIC_H */ diff --git a/arch/arm/src/samdl/chip/samd_evsys.h b/arch/arm/src/samdl/chip/samd_evsys.h index e1489a2622b62554fcc9f5b13ba6c446c0702f3e..84ea384f09294516cf1147c5237829a8da347697 100644 --- a/arch/arm/src/samdl/chip/samd_evsys.h +++ b/arch/arm/src/samdl/chip/samd_evsys.h @@ -68,9 +68,9 @@ #define SAM_EVSYS_CTRL (SAM_EVSYS_BASE+SAM_EVSYS_CTRL_OFFSET) #define SAM_EVSYS_CHANNEL (SAM_EVSYS_BASE+SAM_EVSYS_CHANNEL_OFFSET) #define SAM_EVSYS_USER (SAM_EVSYS_BASE+SAM_EVSYS_USER_OFFSET) -#define SAM_EVSYS_CHSTATUS (SAM_EVSYS_BASE+SAM_EVSYS_CHSTATUS_OFFSET -#define SAM_EVSYS_INTENCLR (SAM_EVSYS_BASE+SAM_EVSYS_INTENCLR_OFFSET -#define SAM_EVSYS_INTENSET (SAM_EVSYS_BASE+SAM_EVSYS_INTENSET_OFFSET +#define SAM_EVSYS_CHSTATUS (SAM_EVSYS_BASE+SAM_EVSYS_CHSTATUS_OFFSET) +#define SAM_EVSYS_INTENCLR (SAM_EVSYS_BASE+SAM_EVSYS_INTENCLR_OFFSET) +#define SAM_EVSYS_INTENSET (SAM_EVSYS_BASE+SAM_EVSYS_INTENSET_OFFSET) #define SAM_EVSYS_INTFLAG (SAM_EVSYS_BASE+SAM_EVSYS_INTFLAG_OFFSET) /* EVSYS register bit definitions ***********************************************************/ @@ -302,12 +302,14 @@ /* Channel status register */ -#define EVSYS_CHSTATUS_USRRDY_SHIFT (0) /* Bits 0-7: User Ready for Channel n, n=0-7 */ -#define EVSYS_CHSTATUS_USRRDY_MASK (0xff << EVSYS_CHSTATUS_USRRDY_SHIFT) -# define EVSYS_CHSTATUS_USRRDY(n) (1 << (n)) -#define EVSYS_CHSTATUS_CHBUSY_SHIFT (8) /* Bits 8-15: Channel Busy n, n=0-7 */ -#define EVSYS_CHSTATUS_CHBUSY_MASK (0xff << EVSYS_CHSTATUS_CHBUSY_SHIFT) -# define EVSYS_CHSTATUS_CHBUSY(n) (1 << ((n) + 8)) +#ifdef CONFIG_ARCH_FAMILY_SAMD20 +# define EVSYS_CHSTATUS_USRRDY_SHIFT (0) /* Bits 0-7: User Ready for Channel n, n=0-7 */ +# define EVSYS_CHSTATUS_USRRDY_MASK (0xff << EVSYS_CHSTATUS_USRRDY_SHIFT) +# define EVSYS_CHSTATUS_USRRDY(n) (1 << (n)) +# define EVSYS_CHSTATUS_CHBUSY_SHIFT (8) /* Bits 8-15: Channel Busy n, n=0-7 */ +# define EVSYS_CHSTATUS_CHBUSY_MASK (0xff << EVSYS_CHSTATUS_CHBUSY_SHIFT) +# define EVSYS_CHSTATUS_CHBUSY(n) (1 << ((n) + 8)) +#endif #ifdef CONFIG_ARCH_FAMILY_SAMD21 # define EVSYS_CHSTATUS_USRRDYH_SHIFT (16) /* Bits 16-19: User Ready for Channel n, n=8-11 */ @@ -320,12 +322,14 @@ /* Interrupt enable clear, interrupt enable set, and interrupt flag status and clear registers */ -#define EVSYS_INT_OVR_SHIFT (0) /* Bits 0-7: Overrun channel n interrupt, n=0-7 */ -#define EVSYS_INT_OVR_MASK (0xff << EVSYS_INT_OVR_SHIFT) -# define EVSYS_INT_OVR(n) (1 << (n)) -#define EVSYS_INT_EVD_SHIFT (8) /* Bits 8-15: Event detected channel n interrupt, n=0-7 */ -#define EVSYS_INT_EVD_MASK (0xff << EVSYS_INT_EVD_SHIFT) -# define EVSYS_INT_EVD(n) (1 << ((n) + 8)) +#ifdef CONFIG_ARCH_FAMILY_SAMD20 +# define EVSYS_INT_OVR_SHIFT (0) /* Bits 0-7: Overrun channel n interrupt, n=0-7 */ +# define EVSYS_INT_OVR_MASK (0xff << EVSYS_INT_OVR_SHIFT) +# define EVSYS_INT_OVR(n) (1 << (n)) +# define EVSYS_INT_EVD_SHIFT (8) /* Bits 8-15: Event detected channel n interrupt, n=0-7 */ +# define EVSYS_INT_EVD_MASK (0xff << EVSYS_INT_EVD_SHIFT) +# define EVSYS_INT_EVD(n) (1 << ((n) + 8)) +#endif #ifdef CONFIG_ARCH_FAMILY_SAMD21 # define EVSYS_INT_OVR_SHIFT (16) /* Bits 16-19: Overrun channel n interrupt, n=8-11 */ diff --git a/arch/arm/src/samdl/chip/samd_gclk.h b/arch/arm/src/samdl/chip/samd_gclk.h index 5426dc394d3bed1f4e0398f9dde2830393a7d58b..56ec14f2f6e471d191851d99a170fec05c1bc8dd 100644 --- a/arch/arm/src/samdl/chip/samd_gclk.h +++ b/arch/arm/src/samdl/chip/samd_gclk.h @@ -158,8 +158,8 @@ # define GCLK_CLKCTRL_ID_ACANA (32 << GCLK_CLKCTRL_ID_SHIFT) /* AC_ANA */ # define GCLK_CLKCTRL_ID_DAC (33 << GCLK_CLKCTRL_ID_SHIFT) /* DAC */ # define GCLK_CLKCTRL_ID_PTC (34 << GCLK_CLKCTRL_ID_SHIFT) /* PTC */ -# define GCLK_CLKCTRL_I2S0_PTC (35 << GCLK_CLKCTRL_ID_SHIFT) /* I2S0 */ -# define GCLK_CLKCTRL_I2S1_PTC (36 << GCLK_CLKCTRL_ID_SHIFT) /* I2S1 */ +# define GCLK_CLKCTRL_ID_I2S0 (35 << GCLK_CLKCTRL_ID_SHIFT) /* I2S0 */ +# define GCLK_CLKCTRL_ID_I2S1 (36 << GCLK_CLKCTRL_ID_SHIFT) /* I2S1 */ #endif #define GCLK_CLKCTRL_GEN_SHIFT (8) /* Bits 8-11: Generic Clock Generator */ diff --git a/arch/arm/src/samdl/chip/samd_i2s.h b/arch/arm/src/samdl/chip/samd_i2s.h new file mode 100644 index 0000000000000000000000000000000000000000..87a4cf7daf380c59d8348837268b10add35b6dd9 --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_i2s.h @@ -0,0 +1,203 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/samd_i2s.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * References: + * "Microchip SAMD21 datasheet" + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_I2S_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_I2S_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAMD21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* I2S register offsets *********************************************************************/ + +#define SAM_I2S_CTRLA_OFFSET 0x0000 /* Control A register */ +#define SAM_I2S_CLKCTRL0_OFFSET 0x0004 /* Clock Control 0 register */ +#define SAM_I2S_CLKCTRL1_OFFSET 0x0008 /* Clock Control 1 register */ +#define SAM_I2S_INTENCLR_OFFSET 0x000C /* Interrupt enable clear register */ +#define SAM_I2S_INTENSET_OFFSET 0x0010 /* Interrupt enable set register */ +#define SAM_I2S_INTFLAG_OFFSET 0x0014 /* Interrupt flag register */ +#define SAM_I2S_SYNCBUSY_OFFSET 0x0018 /* Sync Busy register */ +#define SAM_I2S_SERCTRL0_OFFSET 0x0020 /* Serializer 0 Control register */ +#define SAM_I2S_SERCTRL1_OFFSET 0x0024 /* Serializer 1 Control register */ +#define SAM_I2S_DATA0_OFFSET 0x0030 /* Data 0 register */ +#define SAM_I2S_DATA1_OFFSET 0x0034 /* Data 1 register */ + +/* I2S register addresses ******************************************************************/ + +#define SAM_I2S_CTRLA (SAM_I2S_BASE+SAM_I2S_CTRLA_OFFSET) +#define SAM_I2S_CLKCTRL0 (SAM_I2S_BASE+SAM_I2S_CLKCTRL0_OFFSET) +#define SAM_I2S_CLKCTRL1 (SAM_I2S_BASE+SAM_I2S_CLKCTRL1_OFFSET) +#define SAM_I2S_INTENCLR (SAM_I2S_BASE+SAM_I2S_INTENCLR_OFFSET) +#define SAM_I2S_INTENSET (SAM_I2S_BASE+SAM_I2S_INTENSET_OFFSET) +#define SAM_I2S_INTFLAG (SAM_I2S_BASE+SAM_I2S_INTFLAG_OFFSET) +#define SAM_I2S_SYNCBUSY (SAM_I2S_BASE+SAM_I2S_SYNCBUSY_OFFSET) +#define SAM_I2S_SERCTRL0 (SAM_I2S_BASE+SAM_I2S_SERCTRL0_OFFSET) +#define SAM_I2S_SERCTRL1 (SAM_I2S_BASE+SAM_I2S_SERCTRL1_OFFSET) +#define SAM_I2S_DATA0 (SAM_I2S_BASE+SAM_I2S_DATA0_OFFSET) +#define SAM_I2S_DATA1 (SAM_I2S_BASE+SAM_I2S_DATA1_OFFSET) + +/* I2S register bit definitions ************************************************************/ + +/* Control A register */ + +#define I2S_CTRLA_SWRST (1 << 0) /* Bit 0: Software Reset */ +#define I2S_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */ +#define I2S_CTRLA_CKEN0 (1 << 2) /* Bit 2: Clock Unit 0 Enable */ +#define I2S_CTRLA_CKEN1 (1 << 3) /* Bit 3: Clock Unit 1 Enable */ +#define I2S_CTRLA_SEREN0 (1 << 4) /* Bit 4: Serializer 0 Enable */ +#define I2S_CTRLA_SEREN1 (1 << 5) /* Bit 5: Seriailier 1 Enable */ + +/* Clock Unit Control Register */ + +#define I2S_CLKCTRL_SLOTSIZE_SHIFT (0) /* Bits [1:0]: Slot Size */ +#define I2S_CLKCTRL_SLOTSIZE_MASK (3 << I2S_CLKCTRL_SLOTSIZE_SHIFT) +# define I2S_CLKCTRL_SLOTSIZE_8 (0 << I2S_CLKCTRL_SLOTSIZE_SHIFT) +# define I2S_CLKCTRL_SLOTSIZE_16 (1 << I2S_CLKCTRL_SLOTSIZE_SHIFT) +# define I2S_CLKCTRL_SLOTSIZE_24 (2 << I2S_CLKCTRL_SLOTSIZE_SHIFT) +# define I2S_CLKCTRL_SLOTSIZE_32 (3 << I2S_CLKCTRL_SLOTSIZE_SHIFT) +#define I2S_CLKCTRL_NBSLOTS_SHIFT (2) /* Bit 2: Number of Slots in Frame */ +#define I2S_CLKCTRL_NBSLOTS_MASK (7 << I2S_CLKCTRL_NBSLOTS_SHIFT) +#define I2S_CLKCTRL_NBSLOTS(n) (((n) & 0x7) << I2S_CLKCTRL_NBSLOTS_SHIFT) +#define I2S_CLKCTRL_FSWIDTH_SHIFT (5) /* Bits [6:5]: Frame Sync Width */ +#define I2S_CLKCTRL_FSWIDTH_MASK (3 << I2S_CLKCTRL_FSWIDTH_SHIFT) +# define I2S_CLKCTRL_FSWIDTH_SLOT (0 << I2S_CLKCTRL_FSWIDTH_SHIFT) +# define I2S_CLKCTRL_FSWIDTH_HALF (1 << I2S_CLKCTRL_FSWIDTH_SHIFT) +# define I2S_CLKCTRL_FSWIDTH_BIT (2 << I2S_CLKCTRL_FSWIDTH_SHIFT) +# define I2S_CLKCTRL_FSWIDTH_BURST (3 << I2S_CLKCTRL_FSWIDTH_SHIFT) +#define I2S_CLKCTRL_BITDELAY (1 << 7) /* Bit 7: Data Delay from Frame Sync */ +#define I2S_CLKCTRL_FSSEL (1 << 8) /* Bit 8: Frame Sync Select */ +#define I2S_CLKCTRL_FSINV (1 << 11) /* Bit 11: Frame Sync Invert */ +#define I2S_CLKCTRL_SCKSEL (1 << 12) /* Bit 12: Serial Clock Select. 0: Divided Master clock, 1: SCKn input pin */ +#define I2S_CLKCTRL_MCKSEL (1 << 16) /* Bit 16: Master Clock Select. 0: GCLK, 1: MCKn input pin */ +#define I2S_CLKCTRL_MCKEN (1 << 18) /* Bit 18: Master Clock Enable */ +#define I2S_CLKCTRL_MCKDIV_SHIFT (19) /* Bits [23:19]: Master Clock Division Factor */ +#define I2S_CLKCTRL_MCKDIV_MASK (0x1f << I2S_CLKCTRL_MCKDIV_SHIFT) +#define I2S_CLKCTRL_MCKDIV(n) (((n) & 0x1f) << I2S_CLKCTRL_MCKDIV_SHIFT) +#define I2S_CLKCTRL_MCKOUTDIV_SHIFT (24) /* Bits [28:24]: Master Clock Output Division Factor */ +#define I2S_CLKCTRL_MCKOUTDIV_MASK (0x1f << I2S_CLKCTRL_MCKOUTDIV_SHIFT) +#define I2S_CLKCTRL_MCKOUTDIV(n) (((n) & 0x1f) << I2S_CLKCTRL_MCKOUTDIV_SHIFT) +#define I2S_CLKCTRL_FSOUTINV (1 << 29) /* Bit 29: Frame Sync Output Invert */ +#define I2S_CLKCTRL_SCKOUTINV (1 << 30) /* Bit 30: Serial Clock Output Invert */ +#define I2S_CLKCTRL_MCKOUTINV (1 << 31) /* Bit 31: Master Clock Output Invert */ + +/* Interrupt register bits */ + +#define I2S_INT_RXRDY0 (1 << 0) /* Bit 0: Receive Ready 0 */ +#define I2S_INT_RXRDY1 (1 << 1) /* Bit 1: Receive Ready 1 */ +#define I2S_INT_RXOR0 (1 << 4) /* Bit 4: Receive Overrun 0 */ +#define I2S_INT_RXOR1 (1 << 5) /* Bit 5: Receive Overrun 1 */ +#define I2S_INT_TXRDY0 (1 << 8) /* Bit 8: Transmit Ready 0 */ +#define I2S_INT_TXRDY1 (1 << 9) /* Bit 9: Transmit Ready 1 */ +#define I2S_INT_TXUR0 (1 << 12) /* Bit 12: Transmit Underrun 0 */ +#define I2S_INT_TXUR1 (1 << 13) /* Bit 13: Transmit Underrun 1 */ +#define I2S_INT_ALL (0x3333) + +/* Sync Busy register bits */ + +#define I2S_SYNCBUSY_SWRST (1 << 0) /* Bit 0: Software Reset Sync Status */ +#define I2S_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: Enable Sync Status */ +#define I2S_SYNCBUSY_CKEN0 (1 << 2) /* Bit 2: Clock Unit 0 Sync Status */ +#define I2S_SYNCBUSY_CKEN1 (1 << 3) /* Bit 3: Clock Unit 1 Sync Status */ +#define I2S_SYNCBUSY_SEREN0 (1 << 4) /* Bit 4: Serializer 0 Enable Sync Status */ +#define I2S_SYNCBUSY_SEREN1 (1 << 5) /* Bit 5: Seriaiizer 1 Enable Sync Status */ +#define I2S_SYNCBUSY_DATA0 (1 << 8) /* Bit 8: Data 0 Sync Status */ +#define I2S_SYNCBUSY_DATA1 (1 << 9) /* Bit 9: Data 1 Sync Status */ + +/* Serializer Control register bits */ + +#define I2S_SERCTRL_SERMODE_SHIFT (0) /* Bits [1:0]: Seriailizer Mode */ +#define I2S_SERCTRL_SERMODE_MASK (3 << I2S_SERCTRL_SERMODE_SHIFT) +# define I2S_SERCTRL_SERMODE_RX (0 << I2S_SERCTRL_SERMODE_SHIFT) +# define I2S_SERCTRL_SERMODE_TX (1 << I2S_SERCTRL_SERMODE_SHIFT) +# define I2S_SERCTRL_SERMODE_PDM2 (2 << I2S_SERCTRL_SERMODE_SHIFT) +#define I2S_SERCTRL_TXDEFAULT_SHIFT (2) /* Bits [3:2]: Line Default when Slot Disabled */ +#define I2S_SERCTRL_TXDEFAULT_MASK (3 << I2S_SERCTRL_TXDEFAULT_SHIFT) +# define I2S_SERCTRL_TXDEFAULT_ZERO (0 << I2S_SERCTRL_TXDEFAULT_SHIFT) +# define I2S_SERCTRL_TXDEFAULT_ONE (1 << I2S_SERCTRL_TXDEFAULT_SHIFT) +# define I2S_SERCTRL_TXDEFAULT_HIZ (3 << I2S_SERCTRL_TXDEFAULT_SHIFT) +#define I2S_SERCTRL_TXSAME (1 << 4) /* Bit 4: Transmit last data when Underrun */ +#define I2S_SERCTRL_CLKSEL (1 << 5) /* Bit 5: Clock Unit Selection. 0: Use Clock 0, 1: Use Clock 1 */ +#define I2S_SERCTRL_SLOTADJ (1 << 7) /* Bit 7: Data slot formatting. 0: Right justified, 1: Left justified */ +#define I2S_SERCTRL_DATASIZE_SHIFT (8) /* Bits [10:8]: Data Word Size */ +#define I2S_SERCTRL_DATASIZE_MASK (7 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_32 (0 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_24 (1 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_20 (2 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_18 (3 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_16 (4 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_16C (5 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_8 (6 << I2S_SERCTRL_DATASIZE_SHIFT) +# define I2S_SERCTRL_DATASIZE_8C (7 << I2S_SERCTRL_DATASIZE_SHIFT) +#define I2S_SERCTRL_WORDADJ (1 << 12) /* Bit 12: Data word formatting. 0: Right justified, 1: Left justified */ +#define I2S_SERCTRL_EXTEND_SHIFT (13) /* Bits [14:13]: Data formatting bit extension */ +#define I2S_SERCTRL_EXTEND_MASK (3 << I2S_SERCTRL_EXTEND_SHIFT) +# define I2S_SERCTRL_EXTEND_ZERO (0 << I2S_SERCTRL_EXTEND_SHIFT) +# define I2S_SERCTRL_EXTEND_ONE (1 << I2S_SERCTRL_EXTEND_SHIFT) +# define I2S_SERCTRL_EXTEND_MSBIT (2 << I2S_SERCTRL_EXTEND_SHIFT) +# define I2S_SERCTRL_EXTEND_LSBIT (3 << I2S_SERCTRL_EXTEND_SHIFT) +#define I2S_SERCTRL_BITREV (1 << 15) /* Bit 15: Data formatting bit reverse */ +#define I2S_SERCTRL_SLOTDIS_SHIFT (16) /* Bits [23:16]: Slot x Disabled */ +#define I2S_SERCTRL_SLOTDIS_MASK (0xff << I2S_SERCTRL_SLOTDIS_SHIFT) +#define I2S_SERCTRL_SLOTDIS(n) (((n) & 0xff) << I2C_SERCTRL_SLOTDIS_SHIFT) +#define I2S_SERCTRL_MONO (1 << 24) /* Bit 24: Mono Mode */ +#define I2S_SERCTRL_DMA (1 << 25) /* Bit 25: Single or Multiple DMA channels */ +#define I2S_SERCTRL_RXLOOP (1 << 26) /* Bit 26: RX Loopback Test Mode */ + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAMD21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_I2S_H */ diff --git a/arch/arm/src/samdl/chip/samd_pm.h b/arch/arm/src/samdl/chip/samd_pm.h index 7c3e7f08724ef7fbf8e6ac956e052ecbd7704308..50f8551d31b64159b5caf6e745f4e22aaeb7af98 100644 --- a/arch/arm/src/samdl/chip/samd_pm.h +++ b/arch/arm/src/samdl/chip/samd_pm.h @@ -228,7 +228,7 @@ #define PM_APBCMASK_PTC (1 << 19) /* Bit 19: PTC */ #ifdef CONFIG_ARCH_FAMILY_SAMD21 -# define PM_APBBMASK_I2S (1 << 20) /* Bit 20: Inter IC Sound */ +# define PM_APBCMASK_I2S (1 << 20) /* Bit 20: Inter IC Sound */ #endif /* Interrupt enable clear, Interrupt enable set, and Interrupt flag status and clear registers */ diff --git a/arch/arm/src/samdl/chip/samd_spi.h b/arch/arm/src/samdl/chip/samd_spi.h index 8bdcc9e21ee2400db743dea1733e997c8ea32c66..b045c32c4077ae6085c605f9b00c1de44046a7dd 100644 --- a/arch/arm/src/samdl/chip/samd_spi.h +++ b/arch/arm/src/samdl/chip/samd_spi.h @@ -247,8 +247,8 @@ #endif #ifdef CONFIG_ARCH_FAMILY_SAMD21 -# define SPI_INT_ SSL (1 << 3) /* Bit 3: Slave select low interrupt */ -# define SPI_INT_ ERROR (1 << 7) /* Bit 7: Error interrupt */ +# define SPI_INT_SSL (1 << 3) /* Bit 3: Slave select low interrupt */ +# define SPI_INT_ERROR (1 << 7) /* Bit 7: Error interrupt */ # define SPI_INT_ALL (0x8f) #endif diff --git a/arch/arm/src/samdl/chip/samd_tc.h b/arch/arm/src/samdl/chip/samd_tc.h new file mode 100644 index 0000000000000000000000000000000000000000..fe3d2c40592fc6a51cefff4d7672fba6c1113774 --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_tc.h @@ -0,0 +1,254 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/samd_tc.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * References: + * "Microchip SAMD21 datasheet" + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_TC_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_TC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAMD21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* TC register offsets *********************************************************************/ + +#define SAM_TC_CTRLA_OFFSET 0x0000 /* Control A register */ +#define SAM_TC_READREQ_OFFSET 0x0002 /* Read request register */ +#define SAM_TC_CTRLBCLR_OFFSET 0x0004 /* Control B clear register */ +#define SAM_TC_CTRLBSET_OFFSET 0x0005 /* Control B clear register */ +#define SAM_TC_CTRLC_OFFSET 0x0006 /* Control C register */ +#define SAM_TC_DBGCTRL_OFFSET 0x0008 /* Debug control register */ +#define SAM_TC_EVCTRL_OFFSET 0x000A /* Event control register */ +#define SAM_TC_INTENCLR_OFFSET 0x000C /* Interrupt enable clear register */ +#define SAM_TC_INTENSET_OFFSET 0x000D /* Interrupt enable set register */ +#define SAM_TC_INTFLAG_OFFSET 0x000E /* Interrupt flag register */ +#define SAM_TC_STATUS_OFFSET 0x000F /* Status register */ +#define SAM_TC_COUNT_OFFSET 0x0010 /* Count register */ +#define SAM_TC_CC0_OFFSET 0x0018 /* Capture Compare 0 register */ +#define SAM_TC_CC1_OFFSET 0x001C /* Capture Compare 1 register */ + +/* TC register addresses *******************************************************************/ + +#define SAM_TC3_CTRLA (SAM_TC3_BASE+SAM_TC_CTRLA_OFFSET) +#define SAM_TC3_READREQ (SAM_TC3_BASE+SAM_TC_READREQ_OFFSET) +#define SAM_TC3_CTRLBCLR (SAM_TC3_BASE+SAM_TC_CTRLBCLR_OFFSET) +#define SAM_TC3_CTRLBSET (SAM_TC3_BASE+SAM_TC_CTRLBSET_OFFSET) +#define SAM_TC3_CTRLC (SAM_TC3_BASE+SAM_TC_CTRLC_OFFSET) +#define SAM_TC3_DBGCTRL (SAM_TC3_BASE+SAM_TC_DBGCTRL_OFFSET) +#define SAM_TC3_EVCTRL (SAM_TC3_BASE+SAM_TC_EVCTRL_OFFSET) +#define SAM_TC3_INTENCLR (SAM_TC3_BASE+SAM_TC_INTENCLR_OFFSET) +#define SAM_TC3_INTENSET (SAM_TC3_BASE+SAM_TC_INTENSET_OFFSET) +#define SAM_TC3_INTFLAG (SAM_TC3_BASE+SAM_TC_INTFLAG_OFFSET) +#define SAM_TC3_STATUS (SAM_TC3_BASE+SAM_TC_STATUS_OFFSET) +#define SAM_TC3_COUNT (SAM_TC3_BASE+SAM_TC_COUNT_OFFSET) +#define SAM_TC3_CC0 (SAM_TC3_BASE+SAM_TC_CC0_OFFSET) +#define SAM_TC3_CC1 (SAM_TC3_BASE+SAM_TC_CC1_OFFSET) + +#define SAM_TC4_CTRLA (SAM_TC4_BASE+SAM_TC_CTRLA_OFFSET) +#define SAM_TC4_READREQ (SAM_TC4_BASE+SAM_TC_READREQ_OFFSET) +#define SAM_TC4_CTRLBCLR (SAM_TC4_BASE+SAM_TC_CTRLBCLR_OFFSET) +#define SAM_TC4_CTRLBSET (SAM_TC4_BASE+SAM_TC_CTRLBSET_OFFSET) +#define SAM_TC4_CTRLC (SAM_TC4_BASE+SAM_TC_CTRLC_OFFSET) +#define SAM_TC4_DBGCTRL (SAM_TC4_BASE+SAM_TC_DBGCTRL_OFFSET) +#define SAM_TC4_EVCTRL (SAM_TC4_BASE+SAM_TC_EVCTRL_OFFSET) +#define SAM_TC4_INTENCLR (SAM_TC4_BASE+SAM_TC_INTENCLR_OFFSET) +#define SAM_TC4_INTENSET (SAM_TC4_BASE+SAM_TC_INTENSET_OFFSET) +#define SAM_TC4_INTFLAG (SAM_TC4_BASE+SAM_TC_INTFLAG_OFFSET) +#define SAM_TC4_STATUS (SAM_TC4_BASE+SAM_TC_STATUS_OFFSET) +#define SAM_TC4_COUNT (SAM_TC4_BASE+SAM_TC_COUNT_OFFSET) +#define SAM_TC4_CC0 (SAM_TC4_BASE+SAM_TC_CC0_OFFSET) +#define SAM_TC4_CC1 (SAM_TC4_BASE+SAM_TC_CC1_OFFSET) + +#define SAM_TC5_CTRLA (SAM_TC5_BASE+SAM_TC_CTRLA_OFFSET) +#define SAM_TC5_READREQ (SAM_TC5_BASE+SAM_TC_READREQ_OFFSET) +#define SAM_TC5_CTRLBCLR (SAM_TC5_BASE+SAM_TC_CTRLBCLR_OFFSET) +#define SAM_TC5_CTRLBSET (SAM_TC5_BASE+SAM_TC_CTRLBSET_OFFSET) +#define SAM_TC5_CTRLC (SAM_TC5_BASE+SAM_TC_CTRLC_OFFSET) +#define SAM_TC5_DBGCTRL (SAM_TC5_BASE+SAM_TC_DBGCTRL_OFFSET) +#define SAM_TC5_EVCTRL (SAM_TC5_BASE+SAM_TC_EVCTRL_OFFSET) +#define SAM_TC5_INTENCLR (SAM_TC5_BASE+SAM_TC_INTENCLR_OFFSET) +#define SAM_TC5_INTENSET (SAM_TC5_BASE+SAM_TC_INTENSET_OFFSET) +#define SAM_TC5_INTFLAG (SAM_TC5_BASE+SAM_TC_INTFLAG_OFFSET) +#define SAM_TC5_STATUS (SAM_TC5_BASE+SAM_TC_STATUS_OFFSET) +#define SAM_TC5_COUNT (SAM_TC5_BASE+SAM_TC_COUNT_OFFSET) +#define SAM_TC5_CC0 (SAM_TC5_BASE+SAM_TC_CC0_OFFSET) +#define SAM_TC5_CC1 (SAM_TC5_BASE+SAM_TC_CC1_OFFSET) + +#define SAM_TC6_CTRLA (SAM_TC6_BASE+SAM_TC_CTRLA_OFFSET) +#define SAM_TC6_READREQ (SAM_TC6_BASE+SAM_TC_READREQ_OFFSET) +#define SAM_TC6_CTRLBCLR (SAM_TC6_BASE+SAM_TC_CTRLBCLR_OFFSET) +#define SAM_TC6_CTRLBSET (SAM_TC6_BASE+SAM_TC_CTRLBSET_OFFSET) +#define SAM_TC6_CTRLC (SAM_TC6_BASE+SAM_TC_CTRLC_OFFSET) +#define SAM_TC6_DBGCTRL (SAM_TC6_BASE+SAM_TC_DBGCTRL_OFFSET) +#define SAM_TC6_EVCTRL (SAM_TC6_BASE+SAM_TC_EVCTRL_OFFSET) +#define SAM_TC6_INTENCLR (SAM_TC6_BASE+SAM_TC_INTENCLR_OFFSET) +#define SAM_TC6_INTENSET (SAM_TC6_BASE+SAM_TC_INTENSET_OFFSET) +#define SAM_TC6_INTFLAG (SAM_TC6_BASE+SAM_TC_INTFLAG_OFFSET) +#define SAM_TC6_STATUS (SAM_TC6_BASE+SAM_TC_STATUS_OFFSET) +#define SAM_TC6_COUNT (SAM_TC6_BASE+SAM_TC_COUNT_OFFSET) +#define SAM_TC6_CC0 (SAM_TC6_BASE+SAM_TC_CC0_OFFSET) +#define SAM_TC6_CC1 (SAM_TC6_BASE+SAM_TC_CC1_OFFSET) + +#define SAM_TC7_CTRLA (SAM_TC7_BASE+SAM_TC_CTRLA_OFFSET) +#define SAM_TC7_READREQ (SAM_TC7_BASE+SAM_TC_READREQ_OFFSET) +#define SAM_TC7_CTRLBCLR (SAM_TC7_BASE+SAM_TC_CTRLBCLR_OFFSET) +#define SAM_TC7_CTRLBSET (SAM_TC7_BASE+SAM_TC_CTRLBSET_OFFSET) +#define SAM_TC7_CTRLC (SAM_TC7_BASE+SAM_TC_CTRLC_OFFSET) +#define SAM_TC7_DBGCTRL (SAM_TC7_BASE+SAM_TC_DBGCTRL_OFFSET) +#define SAM_TC7_EVCTRL (SAM_TC7_BASE+SAM_TC_EVCTRL_OFFSET) +#define SAM_TC7_INTENCLR (SAM_TC7_BASE+SAM_TC_INTENCLR_OFFSET) +#define SAM_TC7_INTENSET (SAM_TC7_BASE+SAM_TC_INTENSET_OFFSET) +#define SAM_TC7_INTFLAG (SAM_TC7_BASE+SAM_TC_INTFLAG_OFFSET) +#define SAM_TC7_STATUS (SAM_TC7_BASE+SAM_TC_STATUS_OFFSET) +#define SAM_TC7_COUNT (SAM_TC7_BASE+SAM_TC_COUNT_OFFSET) +#define SAM_TC7_CC0 (SAM_TC7_BASE+SAM_TC_CC0_OFFSET) +#define SAM_TC7_CC1 (SAM_TC7_BASE+SAM_TC_CC1_OFFSET) + +/* TC register bit definitions *************************************************************/ + +/* Control A register */ + +#define TC_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */ +#define TC_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */ +#define TC_CTRLA_MODE_SHIFT (2) +#define TC_CTRLA_MODE_MASK (3 << TC_CTRLA_MODE_SHIFT) +# define TC_CTRLA_MODE_COUNT16 (0 << TC_CTRLA_MODE_SHIFT) +# define TC_CTRLA_MODE_COUNT8 (1 << TC_CTRLA_MODE_SHIFT) +# define TC_CTRLA_MODE_COUNT32 (2 << TC_CTRLA_MODE_SHIFT) +#define TC_CTRLA_WAVEGEN_SHIFT (5) +#define TC_CTRLA_WAVEGEN_MASK (3 << TC_CTRLA_WAVEGEN_SHIFT) +# define TC_CTRLA_WAVEGEN_NFRQ (0 << TC_CTRLA_WAVEGEN_SHIFT) +# define TC_CTRLA_WAVEGEN_MFRQ (1 << TC_CTRLA_WAVEGEN_SHIFT) +# define TC_CTRLA_WAVEGEN_NPWM (2 << TC_CTRLA_WAVEGEN_SHIFT) +# define TC_CTRLA_WAVEGEN_MPWM (3 << TC_CTRLA_WAVEGEN_SHIFT) +#define TC_CTRLA_PRESCALER_SHIFT (8) +#define TC_CTRLA_PRESCALER_MASK (7 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV1 (0 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV2 (1 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV4 (2 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV8 (3 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV16 (4 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV64 (5 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV256 (6 << TC_CTRLA_PRESCALER_SHIFT) +# define TC_CTRLA_PRESCALER_DIV1024 (7 << TC_CTRLA_PRESCALER_SHIFT) +#define TC_CTRLA_RUNSTDBY (1 << 11) +#define TC_CTRLA_PRESCSYNC_SHIFT (12) +#define TC_CTRLA_PRESCSYNC_MASK (3 << TC_CTRLA_PRESCSYNC_SHIFT) +# define TC_CTRLA_PRESCSYNC_GCLK (0 << TC_CTRLA_PRESCSYNC_SHIFT) +# define TC_CTRLA_PRESCSYNC_PRESC (1 << TC_CTRLA_PRESCSYNC_SHIFT) +# define TC_CTRLA_PRESCSYNC_RESYNC (2 << TC_CTRLA_PRESCSYNC_SHIFT) + +/* Read Request register */ + +#define TC_READREQ_ADDR_SHIFT (0) +#define TC_READREQ_ADDR_MASK (0x1F << TC_READREQ_ADDR_SHIFT) +#define TC_READREQ_RCONT (1 << 14) +#define TC_READREQ_RREQ (1 << 15) + +/* Control B Set/Clear register */ + +#define TC_CTRLB_DIR (1 << 0) +#define TC_CTRLB_ONESHOT (1 << 2) +#define TC_CTRLB_CMD_SHIFT (6) +#define TC_CTRLB_CMD_MASK (3 << TC_CTRLBCLR_CMD_SHIFT) +# define TC_CTRLB_CMD_NONE (0 << TC_CTRLBCLR_CMD_SHIFT) +# define TC_CTRLB_CMD_RETRIGGER (1 << TC_CTRLBCLR_CMD_SHIFT) +# define TC_CTRLB_CMD_STOP (2 << TC_CTRLBCLR_CMD_SHIFT) + +/* Control C register */ + +#define TC_CTRLC_INVEN0 (1 << 0) +#define TC_CTRLC_INVEN1 (1 << 1) +#define TC_CTRLC_CPTEN0 (1 << 4) +#define TC_CTRLC_CPTEN1 (1 << 5) + +/* Debug control register */ + +#define TC_DBGCTRL_DBGRUN (1 << 0) + +/* Event control register */ + +#define TC_EVCTRL_EVACT_SHIFT (0) +#define TC_EVCTRL_EVACT_MASK (7 << TC_EVCTRL_EVACT_SHIFT) +# define TC_EVCTRL_EVACT_OFF (0 << TC_EVCTRL_EVACT_SHIFT) +# define TC_EVCTRL_EVACT_RETRIGGER (1 << TC_EVCTRL_EVACT_SHIFT) +# define TC_EVCTRL_EVACT_COUNT (2 << TC_EVCTRL_EVACT_SHIFT) +# define TC_EVCTRL_EVACT_START (3 << TC_EVCTRL_EVACT_SHIFT) +# define TC_EVCTRL_EVACT_PPW (5 << TC_EVCTRL_EVACT_SHIFT) +# define TC_EVCTRL_EVACT_PWP (6 << TC_EVCTRL_EVACT_SHIFT) +#define TC_EVCTRL_TCINV (1 << 4) +#define TC_EVCTRL_TCEI (1 << 5) +#define TC_EVCTRL_OVFEO (1 << 8) +#define TC_EVCTRL_MCEO0 (1 << 12) +#define TC_EVCTRL_MCEO1 (1 << 13) + +/* Interrupt register bits */ + +#define TC_INT_OVF (1 << 0) +#define TC_INT_ERR (1 << 1) +#define TC_INT_SYNCRDY (1 << 3) +#define TC_INT_MC0 (1 << 4) +#define TC_INT_MC1 (1 << 5) + +/* Status register */ + +#define TC_STATUS_STOP (1 << 3) +#define TC_STATUS_SLAVE (1 << 4) +#define TC_STATUS_SYNCBUSY (1 << 7) + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAMD21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_TC_H */ diff --git a/arch/arm/src/samdl/chip/samd_tcc.h b/arch/arm/src/samdl/chip/samd_tcc.h new file mode 100644 index 0000000000000000000000000000000000000000..f7274f992e60c13ffb686993fc35cc8b96bcfbc8 --- /dev/null +++ b/arch/arm/src/samdl/chip/samd_tcc.h @@ -0,0 +1,463 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/samd_tcc.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * References: + * "Microchip SAMD21 datasheet" + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_TCC_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_TCC_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAMD21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* TCC register offsets *********************************************************************/ + +#define SAM_TCC_CTRLA_OFFSET 0x0000 /* Control A register */ +#define SAM_TCC_CTRLBCLR_OFFSET 0x0004 /* Control B clear register */ +#define SAM_TCC_CTRLBSET_OFFSET 0x0005 /* Control B clear register */ +#define SAM_TCC_SYNCBUSY_OFFSET 0x0008 /* Sync Busy register */ +#define SAM_TCC_FCTRLA_OFFSET 0x000C /* Fault control A register */ +#define SAM_TCC_FCTRLB_OFFSET 0x0010 /* Fault control B register */ +#define SAM_TCC_WEXCTRL_OFFSET 0x0014 /* Waveform extension control register */ +#define SAM_TCC_DRVCTRL_OFFSET 0x0018 /* Event control register */ +#define SAM_TCC_DBGCTRL_OFFSET 0x001E /* Debug control register */ +#define SAM_TCC_EVCTRL_OFFSET 0x0020 /* Event control register */ +#define SAM_TCC_INTENCLR_OFFSET 0x0024 /* Interrupt enable clear register */ +#define SAM_TCC_INTENSET_OFFSET 0x0028 /* Interrupt enable set register */ +#define SAM_TCC_INTFLAG_OFFSET 0x002C /* Interrupt flag register */ +#define SAM_TCC_STATUS_OFFSET 0x0030 /* Status register */ +#define SAM_TCC_COUNT_OFFSET 0x0034 /* Count register */ +#define SAM_TCC_PATT_OFFSET 0x0038 /* Pattern register */ +#define SAM_TCC_WAVE_OFFSET 0x003C /* Waveform register */ +#define SAM_TCC_PER_OFFSET 0x0040 /* Period register */ +#define SAM_TCC_CC0_OFFSET 0x0044 /* Capture Compare 0 register */ +#define SAM_TCC_CC1_OFFSET 0x0048 /* Capture Compare 1 register */ +#define SAM_TCC_CC2_OFFSET 0x004C /* Capture Compare 2 register */ +#define SAM_TCC_CC3_OFFSET 0x0050 /* Capture Compare 3 register */ +#define SAM_TCC_PATTB_OFFSET 0x0064 /* Capture Compare 3 register */ +#define SAM_TCC_WAVEB_OFFSET 0x0068 /* Capture Compare 3 register */ +#define SAM_TCC_PERB_OFFSET 0x006C /* Capture Compare 3 register */ +#define SAM_TCC_CCB0_OFFSET 0x0070 /* Capture Compare B0 register */ +#define SAM_TCC_CCB1_OFFSET 0x0074 /* Capture Compare B0 register */ +#define SAM_TCC_CCB2_OFFSET 0x0078 /* Capture Compare B0 register */ +#define SAM_TCC_CCB3_OFFSET 0x007C /* Capture Compare B0 register */ + +/* TC register addresses *******************************************************************/ + +#define SAM_TCC0_CTRLA (SAM_TCC0_BASE+SAM_TCC_CTRLA_OFFSET) +#define SAM_TCC0_CTRLBCLR (SAM_TCC0_BASE+SAM_TCC_CTRLBCLR_OFFSET) +#define SAM_TCC0_CTRLBSET (SAM_TCC0_BASE+SAM_TCC_CTRLBSET_OFFSET) +#define SAM_TCC0_SYNCBUSY (SAM_TCC0_BASE+SAM_TCC_SYNCBUSY_OFFSET) +#define SAM_TCC0_FCTRLA (SAM_TCC0_BASE+SAM_TCC_FCTRLA_OFFSET) +#define SAM_TCC0_FCTRLB (SAM_TCC0_BASE+SAM_TCC_FCTRLB_OFFSET) +#define SAM_TCC0_WEXCTRL (SAM_TCC0_BASE+SAM_TCC_WEXCTRL_OFFSET) +#define SAM_TCC0_DRVCTRL (SAM_TCC0_BASE+SAM_TCC_DRVCTRL_OFFSET) +#define SAM_TCC0_DBGCTRL (SAM_TCC0_BASE+SAM_TCC_DBGCTRL_OFFSET) +#define SAM_TCC0_EVCTRL (SAM_TCC0_BASE+SAM_TCC_EVCTRL_OFFSET) +#define SAM_TCC0_INTENCLR (SAM_TCC0_BASE+SAM_TCC_INTENCLR_OFFSET) +#define SAM_TCC0_INTENSET (SAM_TCC0_BASE+SAM_TCC_INTENSET_OFFSET) +#define SAM_TCC0_INTFLAG (SAM_TCC0_BASE+SAM_TCC_INTFLAG_OFFSET) +#define SAM_TCC0_STATUS (SAM_TCC0_BASE+SAM_TCC_STATUS_OFFSET) +#define SAM_TCC0_COUNT (SAM_TCC0_BASE+SAM_TCC_COUNT_OFFSET) +#define SAM_TCC0_PATT (SAM_TCC0_BASE+SAM_TCC_PATT_OFFSET) +#define SAM_TCC0_WAVE (SAM_TCC0_BASE+SAM_TCC_WAVE_OFFSET) +#define SAM_TCC0_PER (SAM_TCC0_BASE+SAM_TCC_PER_OFFSET) +#define SAM_TCC0_CC0 (SAM_TCC0_BASE+SAM_TCC_CC0_OFFSET) +#define SAM_TCC0_CC1 (SAM_TCC0_BASE+SAM_TCC_CC1_OFFSET) +#define SAM_TCC0_CC2 (SAM_TCC0_BASE+SAM_TCC_CC2_OFFSET) +#define SAM_TCC0_CC3 (SAM_TCC0_BASE+SAM_TCC_CC3_OFFSET) +#define SAM_TCC0_PATTB (SAM_TCC0_BASE+SAM_TCC_PATTB_OFFSET) +#define SAM_TCC0_WAVEB (SAM_TCC0_BASE+SAM_TCC_WAVEB_OFFSET) +#define SAM_TCC0_PERB (SAM_TCC0_BASE+SAM_TCC_PERB_OFFSET) +#define SAM_TCC0_CCB0 (SAM_TCC0_BASE+SAM_TCC_CCB0_OFFSET) +#define SAM_TCC0_CCB1 (SAM_TCC0_BASE+SAM_TCC_CCB1_OFFSET) +#define SAM_TCC0_CCB2 (SAM_TCC0_BASE+SAM_TCC_CCB2_OFFSET) +#define SAM_TCC0_CCB3 (SAM_TCC0_BASE+SAM_TCC_CCB3_OFFSET) + +#define SAM_TCC1_CTRLA (SAM_TCC1_BASE+SAM_TCC_CTRLA_OFFSET) +#define SAM_TCC1_CTRLBCLR (SAM_TCC1_BASE+SAM_TCC_CTRLBCLR_OFFSET) +#define SAM_TCC1_CTRLBSET (SAM_TCC1_BASE+SAM_TCC_CTRLBSET_OFFSET) +#define SAM_TCC1_SYNCBUSY (SAM_TCC1_BASE+SAM_TCC_SYNCBUSY_OFFSET) +#define SAM_TCC1_FCTRLA (SAM_TCC1_BASE+SAM_TCC_FCTRLA_OFFSET) +#define SAM_TCC1_FCTRLB (SAM_TCC1_BASE+SAM_TCC_FCTRLB_OFFSET) +#define SAM_TCC1_WEXCTRL (SAM_TCC1_BASE+SAM_TCC_WEXCTRL_OFFSET) +#define SAM_TCC1_DRVCTRL (SAM_TCC1_BASE+SAM_TCC_DRVCTRL_OFFSET) +#define SAM_TCC1_DBGCTRL (SAM_TCC1_BASE+SAM_TCC_DBGCTRL_OFFSET) +#define SAM_TCC1_EVCTRL (SAM_TCC1_BASE+SAM_TCC_EVCTRL_OFFSET) +#define SAM_TCC1_INTENCLR (SAM_TCC1_BASE+SAM_TCC_INTENCLR_OFFSET) +#define SAM_TCC1_INTENSET (SAM_TCC1_BASE+SAM_TCC_INTENSET_OFFSET) +#define SAM_TCC1_INTFLAG (SAM_TCC1_BASE+SAM_TCC_INTFLAG_OFFSET) +#define SAM_TCC1_STATUS (SAM_TCC1_BASE+SAM_TCC_STATUS_OFFSET) +#define SAM_TCC1_COUNT (SAM_TCC1_BASE+SAM_TCC_COUNT_OFFSET) +#define SAM_TCC1_PATT (SAM_TCC1_BASE+SAM_TCC_PATT_OFFSET) +#define SAM_TCC1_WAVE (SAM_TCC1_BASE+SAM_TCC_WAVE_OFFSET) +#define SAM_TCC1_PER (SAM_TCC1_BASE+SAM_TCC_PER_OFFSET) +#define SAM_TCC1_CC0 (SAM_TCC1_BASE+SAM_TCC_CC0_OFFSET) +#define SAM_TCC1_CC1 (SAM_TCC1_BASE+SAM_TCC_CC1_OFFSET) +#define SAM_TCC1_CC2 (SAM_TCC1_BASE+SAM_TCC_CC2_OFFSET) +#define SAM_TCC1_CC3 (SAM_TCC1_BASE+SAM_TCC_CC3_OFFSET) +#define SAM_TCC1_PATTB (SAM_TCC1_BASE+SAM_TCC_PATTB_OFFSET) +#define SAM_TCC1_WAVEB (SAM_TCC1_BASE+SAM_TCC_WAVEB_OFFSET) +#define SAM_TCC1_PERB (SAM_TCC1_BASE+SAM_TCC_PERB_OFFSET) +#define SAM_TCC1_CCB0 (SAM_TCC1_BASE+SAM_TCC_CCB0_OFFSET) +#define SAM_TCC1_CCB1 (SAM_TCC1_BASE+SAM_TCC_CCB1_OFFSET) +#define SAM_TCC1_CCB2 (SAM_TCC1_BASE+SAM_TCC_CCB2_OFFSET) +#define SAM_TCC1_CCB3 (SAM_TCC1_BASE+SAM_TCC_CCB3_OFFSET) + +#define SAM_TCC2_CTRLA (SAM_TCC2_BASE+SAM_TCC_CTRLA_OFFSET) +#define SAM_TCC2_CTRLBCLR (SAM_TCC2_BASE+SAM_TCC_CTRLBCLR_OFFSET) +#define SAM_TCC2_CTRLBSET (SAM_TCC2_BASE+SAM_TCC_CTRLBSET_OFFSET) +#define SAM_TCC2_SYNCBUSY (SAM_TCC2_BASE+SAM_TCC_SYNCBUSY_OFFSET) +#define SAM_TCC2_FCTRLA (SAM_TCC2_BASE+SAM_TCC_FCTRLA_OFFSET) +#define SAM_TCC2_FCTRLB (SAM_TCC2_BASE+SAM_TCC_FCTRLB_OFFSET) +#define SAM_TCC2_WEXCTRL (SAM_TCC2_BASE+SAM_TCC_WEXCTRL_OFFSET) +#define SAM_TCC2_DRVCTRL (SAM_TCC2_BASE+SAM_TCC_DRVCTRL_OFFSET) +#define SAM_TCC2_DBGCTRL (SAM_TCC2_BASE+SAM_TCC_DBGCTRL_OFFSET) +#define SAM_TCC2_EVCTRL (SAM_TCC2_BASE+SAM_TCC_EVCTRL_OFFSET) +#define SAM_TCC2_INTENCLR (SAM_TCC2_BASE+SAM_TCC_INTENCLR_OFFSET) +#define SAM_TCC2_INTENSET (SAM_TCC2_BASE+SAM_TCC_INTENSET_OFFSET) +#define SAM_TCC2_INTFLAG (SAM_TCC2_BASE+SAM_TCC_INTFLAG_OFFSET) +#define SAM_TCC2_STATUS (SAM_TCC2_BASE+SAM_TCC_STATUS_OFFSET) +#define SAM_TCC2_COUNT (SAM_TCC2_BASE+SAM_TCC_COUNT_OFFSET) +#define SAM_TCC2_PATT (SAM_TCC2_BASE+SAM_TCC_PATT_OFFSET) +#define SAM_TCC2_WAVE (SAM_TCC2_BASE+SAM_TCC_WAVE_OFFSET) +#define SAM_TCC2_PER (SAM_TCC2_BASE+SAM_TCC_PER_OFFSET) +#define SAM_TCC2_CC0 (SAM_TCC2_BASE+SAM_TCC_CC0_OFFSET) +#define SAM_TCC2_CC1 (SAM_TCC2_BASE+SAM_TCC_CC1_OFFSET) +#define SAM_TCC2_CC2 (SAM_TCC2_BASE+SAM_TCC_CC2_OFFSET) +#define SAM_TCC2_CC3 (SAM_TCC2_BASE+SAM_TCC_CC3_OFFSET) +#define SAM_TCC2_PATTB (SAM_TCC2_BASE+SAM_TCC_PATTB_OFFSET) +#define SAM_TCC2_WAVEB (SAM_TCC2_BASE+SAM_TCC_WAVEB_OFFSET) +#define SAM_TCC2_PERB (SAM_TCC2_BASE+SAM_TCC_PERB_OFFSET) +#define SAM_TCC2_CCB0 (SAM_TCC2_BASE+SAM_TCC_CCB0_OFFSET) +#define SAM_TCC2_CCB1 (SAM_TCC2_BASE+SAM_TCC_CCB1_OFFSET) +#define SAM_TCC2_CCB2 (SAM_TCC2_BASE+SAM_TCC_CCB2_OFFSET) +#define SAM_TCC2_CCB3 (SAM_TCC2_BASE+SAM_TCC_CCB3_OFFSET) + +/* TC register bit definitions *************************************************************/ + +/* Control A register */ + +#define TCC_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */ +#define TCC_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */ +#define TCC_CTRLA_RES_SHIFT (5) +#define TCC_CTRLA_RES_MASK (3 << TCC_CTRLA_RES_SHIFT) +# define TCC_CTRLA_RES_NONE (0 << TCC_CTRLA_RES_SHIFT) +# define TCC_CTRLA_RES_DITH4 (1 << TCC_CTRLA_RES_SHIFT) +# define TCC_CTRLA_RES_DITH5 (2 << TCC_CTRLA_RES_SHIFT) +# define TCC_CTRLA_RES_DITH6 (3 << TCC_CTRLA_RES_SHIFT) +#define TCC_CTRLA_PRESCALER_SHIFT (8) +#define TCC_CTRLA_PRESCALER_MASK (7 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV1 (0 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV2 (1 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV4 (2 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV8 (3 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV16 (4 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV64 (5 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV256 (6 << TCC_CTRLA_PRESCALER_SHIFT) +# define TCC_CTRLA_PRESCALER_DIV1024 (7 << TCC_CTRLA_PRESCALER_SHIFT) +#define TCC_CTRLA_RUNSTDBY (1 << 11) +#define TCC_CTRLA_PRESCSYNC_SHIFT (12) +#define TCC_CTRLA_PRESCSYNC_MASK (3 << TCC_CTRLA_PRESCSYNC_SHIFT) +# define TCC_CTRLA_PRESCSYNC_GCLK (0 << TCC_CTRLA_PRESCSYNC_SHIFT) +# define TCC_CTRLA_PRESCSYNC_PRESC (1 << TCC_CTRLA_PRESCSYNC_SHIFT) +# define TCC_CTRLA_PRESCSYNC_RESYNC (2 << TCC_CTRLA_PRESCSYNC_SHIFT) +#define TCC_CTRLA_ALOCK (1 << 14) +#define TCC_CTRLA_CPTEN0 (1 << 24) +#define TCC_CTRLA_CPTEN1 (1 << 25) +#define TCC_CTRLA_CPTEN2 (1 << 26) +#define TCC_CTRLA_CPTEN3 (1 << 27) + +/* Control B Set/Clear register */ + +#define TCC_CTRLB_DIR (1 << 0) +#define TCC_CTRLB_LUPD (1 << 1) +#define TCC_CTRLB_ONESHOT (1 << 2) +#define TCC_CTRLB_IDXCMD_SHIFT (3) +#define TCC_CTRLB_IDXCMD_MASK (3 << TCC_CTRLB_IDXCMD_SHIFT) +# define TCC_CTRLB_IDXCMD_DISABLE (0 << TCC_CTRLB_IDXCMD_SHIFT) +# define TCC_CTRLB_IDXCMD_SET (1 << TCC_CTRLB_IDXCMD_SHIFT) +# define TCC_CTRLB_IDXCMD_CLEAR (2 << TCC_CTRLB_IDXCMD_SHIFT) +# define TCC_CTRLB_IDXCMD_HOLD (3 << TCC_CTRLB_IDXCMD_SHIFT) +#define TCC_CTRLB_CMD_SHIFT (6) +#define TCC_CTRLB_CMD_MASK (7 << TCC_CTRLB_CMD_SHIFT) +# define TCC_CTRLB_CMD_NONE (0 << TCC_CTRLB_CMD_SHIFT) +# define TCC_CTRLB_CMD_RETRIGGER (1 << TCC_CTRLB_CMD_SHIFT) +# define TCC_CTRLB_CMD_STOP (2 << TCC_CTRLB_CMD_SHIFT) +# define TCC_CTRLB_CMD_UPDATE (3 << TCC_CTRLB_CMD_SHIFT) +# define TCC_CTRLB_CMD_READSYNC (4 << TCC_CTRLB_CMD_SHIFT) + +/* Sync Busy register */ + +#define TCC_SYNCBUSY_SWRST (1 << 0) +#define TCC_SYNCBUSY_ENABLE (1 << 1) +#define TCC_SYNCBUSY_CTRLB (1 << 2) +#define TCC_SYNCBUSY_STATUS (1 << 3) +#define TCC_SYNCBUSY_COUNT (1 << 4) +#define TCC_SYNCBUSY_PATT (1 << 5) +#define TCC_SYNCBUSY_WAVE (1 << 6) +#define TCC_SYNCBUSY_PER (1 << 7) +#define TCC_SYNCBUSY_CC0 (1 << 8) +#define TCC_SYNCBUSY_CC1 (1 << 9) +#define TCC_SYNCBUSY_CC2 (1 << 10) +#define TCC_SYNCBUSY_CC3 (1 << 11) +#define TCC_SYNCBUSY_PATTB (1 << 16) +#define TCC_SYNCBUSY_WAVEB (1 << 17) +#define TCC_SYNCBUSY_PERB (1 << 18) +#define TCC_SYNCBUSY_CCB0 (1 << 19) +#define TCC_SYNCBUSY_CCB1 (1 << 20) +#define TCC_SYNCBUSY_CCB2 (1 << 21) +#define TCC_SYNCBUSY_CCB3 (1 << 22) + +/* Fault Control A and B */ + +#define TCC_FCTRL_SRC_SHIFT (0) +#define TCC_FCTRL_SRC_MASK (3 << TCC_FCTRL_SRC_SHIFT) +# define TCC_FCTRL_SRC_DISABLE (0 << TCC_FCTRL_SRC_SHIFT) +# define TCC_FCTRL_SRC_ENABLE (1 << TCC_FCTRL_SRC_SHIFT) +# define TCC_FCTRL_SRC_INVERT (2 << TCC_FCTRL_SRC_SHIFT) +# define TCC_FCTRL_SRC_ALTFAULT (3 << TCC_FCTRL_SRC_SHIFT) +#define TCC_FCTRL_KEEP (1 << 3) +#define TCC_FCTRL_QUAL (1 << 4) +#define TCC_FCTRL_BLANK_SHIFT (5) +#define TCC_FCTRL_BLANK_MASK (3 << TCC_FCTRL_BLANK_SHIFT) +# define TCC_FCTRL_BLANK_START (0 << TCC_FCTRL_BLANK_SHIFT) +# define TCC_FCTRL_BLANK_RISE (1 << TCC_FCTRL_BLANK_SHIFT) +# define TCC_FCTRL_BLANK_FALL (2 << TCC_FCTRL_BLANK_SHIFT) +# define TCC_FCTRL_BLANK_BOTH (3 << TCC_FCTRL_BLANK_SHIFT) +#define TCC_FCTRL_RESTART (1 << 7) +#define TCC_FCTRL_HALT_SHIFT (8) +#define TCC_FCTRL_HALT_MASK (3 << TCC_FCTRL_HALT_SHIFT) +# define TCC_FCTRL_HALT_DISABLE (0 << TCC_FCTRL_HALT_SHIFT) +# define TCC_FCTRL_HALT_HW (1 << TCC_FCTRL_HALT_SHIFT) +# define TCC_FCTRL_HALT_SW (2 << TCC_FCTRL_HALT_SHIFT) +# define TCC_FCTRL_HALT_NR (3 << TCC_FCTRL_HALT_SHIFT) +#define TCC_FCTRL_CHSEL_SHIFT (10) +#define TCC_FCTRL_CHSEL_MASK (3 << TCC_FCTRL_CHSEL_SHIFT) +# define TCC_FCTRL_CHSEL_CC0 (0 << TCC_FCTRL_CHSEL_SHIFT) +# define TCC_FCTRL_CHSEL_CC1 (1 << TCC_FCTRL_CHSEL_SHIFT) +# define TCC_FCTRL_CHSEL_CC2 (2 << TCC_FCTRL_CHSEL_SHIFT) +# define TCC_FCTRL_CHSEL_CC3 (3 << TCC_FCTRL_CHSEL_SHIFT) +#define TCC_FCTRL_CAPTURE_SHIFT (12) +#define TCC_FCTRL_CAPTURE_MASK (7 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_DISABLE (0 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_CAPT (1 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_CAPTMIN (2 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_CAPTMAX (3 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_LOCMIN (4 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_LOCMAX (5 << TCC_FCTRL_CAPTURE_SHIFT) +# define TCC_FCTRL_CAPTURE_DERIV0 (6 << TCC_FCTRL_CAPTURE_SHIFT) +#define TCC_FCTRL_BLANKVAL_SHIFT (16) +#define TCC_FCTRL_BLANKVAL_MASK (0xff << TCC_FCTRL_BLANKVAL_SHIFT) +#define TCC_FCTRL_FILTERVAL_SHIFT (24) +#define TCC_FCTRL_FILTERVAL_MASK (0xf << TCC_FCTRL_FILTERVAL_SHIFT) + +/* Waveform Extension Control register */ + +#define TCC_WEXCTRL_OTMX_SHIFT (0) +#define TCC_WEXCTRL_OTMX_MASK (3 << TCC_WEXCTRL_OTMX_SHIFT) +#define TCC_WEXCTRL_DTIEN0 (1 << 8) +#define TCC_WEXCTRL_DTIEN1 (1 << 9) +#define TCC_WEXCTRL_DTIEN2 (1 << 10) +#define TCC_WEXCTRL_DTIEN3 (1 << 11) +#define TCC_WEXCTRL_DTLS_SHIFT (16) +#define TCC_WEXCTRL_DTLS_MASK (0xff << TCC_WEXCTRL_DTLS_SHIFT) +#define TCC_WEXCTRL_DTHS_SHIFT (24) +#define TCC_WEXCTRL_DTHS_MASK (0xff << TCC_WEXCTRL_DTHS_SHIFT) + +/* Driver Control register */ + +#define TCC_DRVCTRL_NRE(n) (1 << n) +#define TCC_DRVCTRL_NRV(n) (1 << (8+n)) +#define TCC_DRVCTRL_INVEN(n) (1 << (16+n)) +#define TCC_DRVCTRL_FILTERVAL0_SHIFT (24) +#define TCC_DRVCTRL_FILTERVAL0_MASK (0xf << TCC_DRVCTRL_FILTERVAL0_SHIFT) +#define TCC_DRVCTRL_FILTERVAL1_SHIFT (28) +#define TCC_DRVCTRL_FILTERVAL1_MASK (0xf << TCC_DRVCTRL_FILTERVAL1_SHIFT) + +/* Debug control register */ + +#define TCC_DBGCTRL_DBGRUN (1 << 0) +#define TCC_DBGCTRL_FDDBD (1 << 2) + +/* Event control register */ + +#define TCC_EVCTRL_EVACT0_SHIFT (0) +#define TCC_EVCTRL_EVACT0_MASK (7 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_OFF (0 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_RETRIGGER (1 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_COUNTEV (2 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_START (3 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_INC (4 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_COUNT (5 << TCC_EVCTRL_EVACT0_SHIFT) +# define TCC_EVCTRL_EVACT0_FAULT (7 << TCC_EVCTRL_EVACT0_SHIFT) +#define TCC_EVCTRL_EVACT1_SHIFT (3) +#define TCC_EVCTRL_EVACT1_MASK (7 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_OFF (0 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_RETRIGGER (1 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_DIR (2 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_STOP (3 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_DEC (4 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_PPW (5 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_PWP (6 << TCC_EVCTRL_EVACT1_SHIFT) +# define TCC_EVCTRL_EVACT1_FAULT (7 << TCC_EVCTRL_EVACT1_SHIFT) +#define TCC_EVCTRL_CNTSEL_SHIFT (6) +#define TCC_EVCTRL_CNTSEL_MASK (3 << TCC_EVCTRL_CNTSEL_SHIFT) +# define TCC_EVCTRL_CNTSEL_BEGIN (0 << TCC_EVCTRL_CNTSEL_SHIFT) +# define TCC_EVCTRL_CNTSEL_END (1 << TCC_EVCTRL_CNTSEL_SHIFT) +# define TCC_EVCTRL_CNTSEL_BETWEEN (2 << TCC_EVCTRL_CNTSEL_SHIFT) +# define TCC_EVCTRL_CNTSEL_BOUNDARY (3 << TCC_EVCTRL_CNTSEL_SHIFT) +#define TCC_EVCTRL_OVFEO (1 << 8) +#define TCC_EVCTRL_TRGEO (1 << 9) +#define TCC_EVCTRL_CNTEO (1 << 10) +#define TCC_EVCTRL_TCINV0 (1 << 12) +#define TCC_EVCTRL_TCINV1 (1 << 13) +#define TCC_EVCTRL_TCEI0 (1 << 14) +#define TCC_EVCTRL_TCEI1 (1 << 15) +#define TCC_EVCTRL_MCEI0 (1 << 16) +#define TCC_EVCTRL_MCEI1 (1 << 17) +#define TCC_EVCTRL_MCEI2 (1 << 18) +#define TCC_EVCTRL_MCEI3 (1 << 19) +#define TCC_EVCTRL_MCEO0 (1 << 24) +#define TCC_EVCTRL_MCEO1 (1 << 25) +#define TCC_EVCTRL_MCEO2 (1 << 26) +#define TCC_EVCTRL_MCEO3 (1 << 27) + +/* Interrupt register bits */ + +#define TCC_INT_OVF (1 << 0) +#define TCC_INT_TRG (1 << 1) +#define TCC_INT_CNT (1 << 2) +#define TCC_INT_ERR (1 << 3) +#define TCC_INT_DFS (1 << 11) +#define TCC_INT_FAULTA (1 << 12) +#define TCC_INT_FAULTB (1 << 13) +#define TCC_INT_FAULT0 (1 << 14) +#define TCC_INT_FAULT1 (1 << 15) +#define TCC_INT_MC0 (1 << 16) +#define TCC_INT_MC1 (1 << 17) +#define TCC_INT_MC2 (1 << 18) +#define TCC_INT_MC3 (1 << 19) + +/* Status register */ + +#define TCC_STATUS_STOP (1 << 0) +#define TCC_STATUS_IDX (1 << 1) +#define TCC_STATUS_DFS (1 << 3) +#define TCC_STATUS_PATTBV (1 << 5) +#define TCC_STATUS_WAVEBV (1 << 6) +#define TCC_STATUS_PERBV (1 << 7) +#define TCC_STATUS_FAULTAIN (1 << 8) +#define TCC_STATUS_FAULTBIN (1 << 9) +#define TCC_STATUS_FAULT0IN (1 << 10) +#define TCC_STATUS_FAULT1IN (1 << 11) +#define TCC_STATUS_FAULTA (1 << 12) +#define TCC_STATUS_FAULTB (1 << 13) +#define TCC_STATUS_FAULT0 (1 << 14) +#define TCC_STATUS_FAULT1 (1 << 15) +#define TCC_STATUS_CCBV0 (1 << 16) +#define TCC_STATUS_CCBV1 (1 << 17) +#define TCC_STATUS_CCBV2 (1 << 18) +#define TCC_STATUS_CCBV3 (1 << 19) +#define TCC_STATUS_CMP0 (1 << 24) +#define TCC_STATUS_CMP1 (1 << 25) +#define TCC_STATUS_CMP2 (1 << 26) +#define TCC_STATUS_CMP3 (1 << 27) + +/* Waveform register */ + +#define TCC_WAVE_WAVEGEN_SHIFT (0) +#define TCC_WAVE_WAVEGEN_MASK (7 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_NFRQ (0 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_MFRQ (1 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_NPWM (2 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_DSCRITICAL (4 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_DSBOTTOM (5 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_DSBOTH (6 << TCC_WAVE_WAVEGEN_SHIFT) +# define TCC_WAVE_WAVEGEN_DSTOP (7 << TCC_WAVE_WAVEGEN_SHIFT) +#define TCC_WAVE_RAMP_SHIFT (4) +#define TCC_WAVE_RAMP_MASK (3 << TCC_WAVE_RAMP_SHIFT) +# define TCC_WAVE_RAMP_RAMP1 (0 << TCC_WAVE_RAMP_SHIFT) +# define TCC_WAVE_RAMP_RAMP2A (1 << TCC_WAVE_RAMP_SHIFT) +# define TCC_WAVE_RAMP_RAMP2 (2 << TCC_WAVE_RAMP_SHIFT) +#define TCC_WAVE_CIPEREN (1 << 7) +#define TCC_WAVE_CICCEN0 (1 << 8) +#define TCC_WAVE_CICCEN1 (1 << 9) +#define TCC_WAVE_CICCEN2 (1 << 10) +#define TCC_WAVE_CICCEN3 (1 << 11) +#define TCC_WAVE_POL0 (1 << 16) +#define TCC_WAVE_POL1 (1 << 17) +#define TCC_WAVE_POL2 (1 << 18) +#define TCC_WAVE_POL3 (1 << 19) +#define TCC_WAVE_SWAP0 (1 << 24) +#define TCC_WAVE_SWAP1 (1 << 25) +#define TCC_WAVE_SWAP2 (1 << 26) +#define TCC_WAVE_SWAP3 (1 << 27) + +/* Period, CCx, PERB, CCBx register */ + +#define TCC_DITHER_SHIFT (0) +#define TCC_DITHER_MASK (0x3f << TCC_PER_DITHER_SHIFT) +# define TCC_DITHER_NONE (0 << TCC_DITHER_SHIFT) +# define TCC_DITHER_DITH4 (1 << TCC_DITHER_SHIFT) +# define TCC_DITHER_DITH5 (2 << TCC_DITHER_SHIFT) +# define TCC_DITHER_DITH6 (3 << TCC_DITHER_SHIFT) +#define TCC_VALUE_SHIFT (6) +#define TCC_VALUE_MASK (0x3ff << TCC_VALUE_SHIFT) + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAMD21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_TCC_H */ diff --git a/arch/arm/src/samdl/chip/saml_eic.h b/arch/arm/src/samdl/chip/saml_eic.h index e6bb167e2ebd022381815e5a4d44edd597f57f4e..56d91824ec401b5629bd99ddf158b644984f3249 100644 --- a/arch/arm/src/samdl/chip/saml_eic.h +++ b/arch/arm/src/samdl/chip/saml_eic.h @@ -123,7 +123,7 @@ #define EIC_EXTINT_SHIFT (0) /* Bits 0-15: External interrupt n */ #define EIC_EXTINT_MASK (0xffff << EIC_EXTINT_SHIFT) -# define EIC_EXTINT(n) ((uint32_t)(n) << EIC_EXTINT_SHIFT) +# define EIC_EXTINT(n) (1 << (n)) # define EIC_EXTINT_0 (1 << 0) /* Bit 0: External interrupt 0 */ # define EIC_EXTINT_1 (1 << 1) /* Bit 1: External interrupt 1 */ # define EIC_EXTINT_2 (1 << 2) /* Bit 2: External interrupt 2 */ diff --git a/arch/arm/src/samdl/sam_ac.c b/arch/arm/src/samdl/sam_ac.c new file mode 100644 index 0000000000000000000000000000000000000000..62872da31d94d669328f3a84b17cc945e0636762 --- /dev/null +++ b/arch/arm/src/samdl/sam_ac.c @@ -0,0 +1,177 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_ac.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * References: + * 1. "Microchip SAM D21E / SAM D21G / SAM D21J Datasheet" + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include "up_arch.h" + +#include "sam_config.h" + +#include "sam_pm.h" +#include "sam_gclk.h" +#include "sam_periphclks.h" +#include "sam_ac.h" +#include "sam_port.h" + +#include +#include +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int sam_ac_isr(int irq, FAR void *context, FAR void *arg) +{ + return OK; +} + +static void sam_ac_syncwait(void) +{ + while ((getreg8(SAM_AC_STATUSB) & AC_STATUSB_SYNCBUSY) != 0); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_ac_initialize + * + * Description: + * Initialize the Analog Comparator (AC). + * + * Input Parameters: + * gclkgen - GCLK Generator + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_ac_initialize(uint8_t gclkgen) +{ + uint16_t regval; + + sam_ac_enableperiph(); + + /* The Analog Comparators use two GCLKs */ + + /* Enable comparator digital GCLK which provides the sampling rate */ + + regval = GCLK_CLKCTRL_ID_ACDIG | GCLK_CLKCTRL_GEN(gclkgen) | GCLK_CLKCTRL_CLKEN; + putreg16(regval, SAM_GCLK_CLKCTRL); + + /* Enable comparator analog GCLK */ + + regval = GCLK_CLKCTRL_ID_ACANA | GCLK_CLKCTRL_GEN(gclkgen) | GCLK_CLKCTRL_CLKEN; + putreg16(regval, SAM_GCLK_CLKCTRL); + + putreg8(AC_CTRLA_ENABLE, SAM_AC_CTRLA); + sam_ac_syncwait(); + + irq_attach(SAM_IRQ_AC, sam_ac_isr, NULL); + + up_enable_irq(SAM_IRQ_AC); + + return OK; +} + +int sam_ac_config(uint8_t channel, uint32_t compctrl) +{ + switch(channel) + { + case 0: + putreg32(compctrl, SAM_AC_COMPCTRL0); + break; + case 1: + putreg32(compctrl, SAM_AC_COMPCTRL1); + break; + default: + return -ENODEV; + } + + sam_ac_syncwait(); + + return OK; +} + +int sam_ac_enable(uint8_t channel, bool enable) +{ + uint32_t regval; + switch(channel) + { + case 0: + regval = getreg32(SAM_AC_COMPCTRL0); + if(enable == true) + regval |= AC_COMPCTRL_ENABLE; + else + regval &= ~AC_COMPCTRL_ENABLE; + putreg32(regval, SAM_AC_COMPCTRL0); + break; + case 1: + regval = getreg32(SAM_AC_COMPCTRL1); + if(enable == true) + regval |= AC_COMPCTRL_ENABLE; + else + regval &= ~AC_COMPCTRL_ENABLE; + putreg32(regval, SAM_AC_COMPCTRL1); + break; + default: + return -ENODEV; + } + + sam_ac_syncwait(); + + return OK; +} diff --git a/arch/arm/src/samdl/sam_ac.h b/arch/arm/src/samdl/sam_ac.h new file mode 100644 index 0000000000000000000000000000000000000000..bdf4b5928dd1897fe08927b5146b62720d568070 --- /dev/null +++ b/arch/arm/src/samdl/sam_ac.h @@ -0,0 +1,81 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_ac.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_SAM_AC_H +#define __ARCH_ARM_SRC_SAMDL_SAM_AC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "sam_config.h" +#include "sam_port.h" + +#if defined(CONFIG_ARCH_FAMILY_SAMD20) || defined(CONFIG_ARCH_FAMILY_SAMD21) +# include "chip/samd_ac.h" +#elif defined(CONFIG_ARCH_FAMILY_SAML21) +# include "chip/saml_ac.h" +#else +# error Unrecognized SAMD/L architecture +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int sam_ac_initialize(uint8_t gclkgen); +int sam_ac_config(uint8_t channel, uint32_t compctrl); +int sam_ac_enable(uint8_t channel, bool enable); + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ARCH_ARM_SRC_SAMDL_SAM_AC_H */ diff --git a/arch/arm/src/samdl/sam_dac.h b/arch/arm/src/samdl/sam_dac.h new file mode 100644 index 0000000000000000000000000000000000000000..b78afd36c1d222b6ed3d8a34a81f8d9fca730e69 --- /dev/null +++ b/arch/arm/src/samdl/sam_dac.h @@ -0,0 +1,77 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_dac.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_SAM_DAC_H +#define __ARCH_ARM_SRC_SAMDL_SAM_DAC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "sam_config.h" +#include "sam_port.h" + +#if defined(CONFIG_ARCH_FAMILY_SAMD20) || defined(CONFIG_ARCH_FAMILY_SAMD21) +# include "chip/samd_dac.h" +#elif defined(CONFIG_ARCH_FAMILY_SAML21) +# include "chip/saml_dac.h" +#else +# error Unrecognized SAMD/L architecture +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ARCH_ARM_SRC_SAMDL_SAM_DAC_H */ diff --git a/arch/arm/src/samdl/sam_dmac.c b/arch/arm/src/samdl/sam_dmac.c index 5ca812ea4f8ddb36281bbab272917915dc86116e..0b354a03906d8f6b1609927e905dd913447dbed4 100644 --- a/arch/arm/src/samdl/sam_dmac.c +++ b/arch/arm/src/samdl/sam_dmac.c @@ -145,15 +145,18 @@ static sem_t g_dsem; static struct sam_dmach_s g_dmach[SAMDL_NDMACHAN]; -/* DMA descriptor tables positioned in LPRAM. In this use case, it is - * acceptable for the writeback descriptors to overlap the base - * descriptors since the base descriptors are always initialized prior - * to starting each DMA transaction. +/* NOTE: Using the same address as the base descriptors for writeback descriptors + * causes TERR and FERR interrupts to be raised immediately after starting DMA. + * This was tested on SAMD21G18A, and it would appear that the writeback + * buffer must be located at a different memory address. + * + * - Matt Thompson */ static struct dma_desc_s g_base_desc[SAMDL_NDMACHAN] __attribute__ ((section(".lpram"), aligned(16))); -#define g_writeback_desc g_base_desc +static struct dma_desc_s g_writeback_desc[SAMDL_NDMACHAN] + __attribute__ ((section(".lpram"), aligned(16))); #if CONFIG_SAMDL_DMAC_NDESC > 0 /* Additional DMA descriptors for (optional) multi-block transfer support. @@ -293,7 +296,7 @@ static int sam_dmainterrupt(int irq, void *context, FAR void *arg) /* Process all pending channel interrupts */ - while (((intpend = getreg16(SAM_DMAC_INTPEND)) & DMAC_INTPEND_PEND) != 0) + while ((intpend = getreg16(SAM_DMAC_INTPEND)) != 0) { /* Get the channel that generated the interrupt */ @@ -322,10 +325,17 @@ static int sam_dmainterrupt(int irq, void *context, FAR void *arg) sam_dmaterminate(dmach, OK); } + else if ((intpend & DMAC_INTPEND_TERR) != 0) + { + dmaerr("Invalid descriptor. Channel %d\n", chndx); + sam_dmaterminate(dmach, -EIO); + } + /* Check for channel suspend interrupt */ else if ((intpend & DMAC_INTPEND_SUSP) != 0) { + dmaerr("Channel suspended. Channel %d\n", chndx); /* REVISIT: Do we want to do anything here? */ } } @@ -472,7 +482,7 @@ static struct dma_desc_s *sam_append_desc(struct sam_dmach_s *dmach, /* Allocate a DMA descriptor */ desc = sam_alloc_desc(dmach); - if (desc == NULL) + if (desc != NULL) { /* We have it. Initialize the new descriptor list entry */ @@ -500,7 +510,7 @@ static struct dma_desc_s *sam_append_desc(struct sam_dmach_s *dmach, { /* There is no previous link. This is the new head of the list */ - DEBUGASSERT(desc == g_base_desc[dmach->dc_chan]); + DEBUGASSERT(desc == &g_base_desc[dmach->dc_chan]); } #if CONFIG_SAMDL_DMAC_NDESC > 0 @@ -509,6 +519,10 @@ static struct dma_desc_s *sam_append_desc(struct sam_dmach_s *dmach, dmach->dc_tail = desc; #endif } + else + { + dmaerr("Failed to allocate descriptor\n"); + } return desc; } @@ -604,7 +618,7 @@ static uint16_t sam_bytes2beats(struct sam_dmach_s *dmach, size_t nbytes) /* The number of beats is then the ceiling of the division */ - mask = (1 < beatsize) - 1; + mask = (1 << beatsize) - 1; nbeats = (nbytes + mask) >> beatsize; DEBUGASSERT(nbeats <= UINT16_MAX); return (uint16_t)nbeats; @@ -627,7 +641,7 @@ static int sam_txbuffer(struct sam_dmach_s *dmach, uint32_t paddr, uint16_t btcnt; uint16_t tmp; - DEBUGASSERT(dmac->dc_dir == DMADIR_UNKOWN || dmac->dc_dir == DMADIR_TX); + DEBUGASSERT(dmach->dc_dir == DMADIR_UNKOWN || dmach->dc_dir == DMADIR_TX); /* Set up the Block Transfer Control Register configuration: * @@ -653,14 +667,25 @@ static int sam_txbuffer(struct sam_dmach_s *dmach, uint32_t paddr, tmp = (dmach->dc_flags & DMACH_FLAG_BEATSIZE_MASK) >> DMACH_FLAG_BEATSIZE_SHIFT; btctrl |= tmp << LPSRAM_BTCTRL_BEATSIZE_SHIFT; + /* See Addressing on page 264 of the datasheet. + * When increment is used, we have to adjust the address in the descriptor + * based on the beat count remaining in the block + */ + + /* Set up the Block Transfer Count Register configuration */ + + btcnt = sam_bytes2beats(dmach, nbytes); + if ((dmach->dc_flags & DMACH_FLAG_MEM_INCREMENT) != 0) { btctrl |= LPSRAM_BTCTRL_SRCINC; + maddr += nbytes; } if ((dmach->dc_flags & DMACH_FLAG_PERIPH_INCREMENT) != 0) { btctrl |= LPSRAM_BTCTRL_DSTINC; + paddr += nbytes; } if ((dmach->dc_flags & DMACH_FLAG_STEPSEL) == DMACH_FLAG_STEPSEL_PERIPH) @@ -671,10 +696,6 @@ static int sam_txbuffer(struct sam_dmach_s *dmach, uint32_t paddr, tmp = (dmach->dc_flags & DMACH_FLAG_STEPSIZE_MASK) >> LPSRAM_BTCTRL_STEPSIZE_SHIFT; btctrl |= tmp << LPSRAM_BTCTRL_STEPSIZE_SHIFT; - /* Set up the Block Transfer Count Register configuration */ - - btcnt = sam_bytes2beats(dmach, nbytes); - /* Add the new descriptor list entry */ if (!sam_append_desc(dmach, btctrl, btcnt, maddr, paddr)) @@ -703,7 +724,7 @@ static int sam_rxbuffer(struct sam_dmach_s *dmach, uint32_t paddr, uint16_t btcnt; uint16_t tmp; - DEBUGASSERT(dmac->dc_dir == DMADIR_UNKOWN || dmac->dc_dir == DMADIR_RX); + DEBUGASSERT(dmach->dc_dir == DMADIR_UNKOWN || dmach->dc_dir == DMADIR_RX); /* Set up the Block Transfer Control Register configuration: * @@ -729,14 +750,20 @@ static int sam_rxbuffer(struct sam_dmach_s *dmach, uint32_t paddr, tmp = (dmach->dc_flags & DMACH_FLAG_BEATSIZE_MASK) >> DMACH_FLAG_BEATSIZE_SHIFT; btctrl |= tmp << LPSRAM_BTCTRL_BEATSIZE_SHIFT; + /* Set up the Block Transfer Count Register configuration */ + + btcnt = sam_bytes2beats(dmach, nbytes); + if ((dmach->dc_flags & DMACH_FLAG_PERIPH_INCREMENT) != 0) { btctrl |= LPSRAM_BTCTRL_SRCINC; + paddr += nbytes; } if ((dmach->dc_flags & DMACH_FLAG_MEM_INCREMENT) != 0) { btctrl |= LPSRAM_BTCTRL_DSTINC; + maddr += nbytes; } if ((dmach->dc_flags & DMACH_FLAG_STEPSEL) == DMACH_FLAG_STEPSEL_MEM) @@ -747,10 +774,6 @@ static int sam_rxbuffer(struct sam_dmach_s *dmach, uint32_t paddr, tmp = (dmach->dc_flags & DMACH_FLAG_STEPSIZE_MASK) >> LPSRAM_BTCTRL_STEPSIZE_SHIFT; btctrl |= tmp << LPSRAM_BTCTRL_STEPSIZE_SHIFT; - /* Set up the Block Transfer Count Register configuration */ - - btcnt = sam_bytes2beats(dmach, nbytes); - /* Add the new descriptor list entry */ if (!sam_append_desc(dmach, btctrl, btcnt, paddr, maddr)) @@ -1183,7 +1206,7 @@ int sam_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg) } chctrlb |= tmp << DMAC_CHCTRLB_TRIGSRC_SHIFT; - putreg8(chctrlb, SAM_DMAC_CHCTRLB); + putreg32(chctrlb, SAM_DMAC_CHCTRLB); /* Setup the Quality of Service Control Register * @@ -1218,10 +1241,13 @@ int sam_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg) /* Enable the channel */ ctrla = DMAC_CHCTRLA_ENABLE; + +#ifdef CONFIG_ARCH_FAMILY_SAML21 if (dmach->dc_flags & DMACH_FLAG_RUNINSTDBY) { ctrla |= DMAC_CHCTRLA_RUNSTDBY; } +#endif putreg8(ctrla, SAM_DMAC_CHCTRLA); @@ -1272,19 +1298,18 @@ void sam_dmastop(DMA_HANDLE handle) #ifdef CONFIG_DEBUG_DMA_INFO void sam_dmasample(DMA_HANDLE handle, struct sam_dmaregs_s *regs) { - struct sam_dmach_s *dmach = (struct sam_dmach_s *)handle; - uintptr_t base; irqstate_t flags; /* Sample DMAC registers. */ flags = enter_critical_section(); + regs->ctrl = getreg16(SAM_DMAC_CTRL); /* Control Register */ regs->crcctrl = getreg16(SAM_DMAC_CRCCTRL); /* CRC Control Register */ regs->crcdatain = getreg32(SAM_DMAC_CRCDATAIN); /* CRC Data Input Register */ regs->crcchksum = getreg32(SAM_DMAC_CRCCHKSUM); /* CRC Checksum Register */ regs->crcstatus = getreg8(SAM_DMAC_CRCSTATUS); /* CRC Status Register */ - regs->errctrl = getreg8(SAM_DMAC_DBGCTRL); /* Debug Control Register */ + regs->dbgctrl = getreg8(SAM_DMAC_DBGCTRL); /* Debug Control Register */ regs->qosctrl = getreg8(SAM_DMAC_QOSCTRL); /* Quality of Service Control Register */ regs->swtrigctrl = getreg32(SAM_DMAC_SWTRIGCTRL); /* Software Trigger Control Register */ regs->prictrl0 = getreg32(SAM_DMAC_PRICTRL0); /* Priority Control 0 Register */ @@ -1300,6 +1325,8 @@ void sam_dmasample(DMA_HANDLE handle, struct sam_dmaregs_s *regs) regs->chctrlb = getreg32(SAM_DMAC_CHCTRLB); /* Channel Control B Register */ regs->chintflag = getreg8(SAM_DMAC_CHINTFLAG); /* Channel Interrupt Flag Status and Clear Register */ regs->chstatus = getreg8(SAM_DMAC_CHSTATUS); /* Channel Status Register */ + + leave_critical_section(flags); } #endif /* CONFIG_DEBUG_DMA_INFO */ @@ -1325,13 +1352,13 @@ void sam_dmadump(DMA_HANDLE handle, const struct sam_dmaregs_s *regs, dmainfo(" CTRL: %04x CRCCTRL: %04x CRCDATAIN: %08x CRCCHKSUM: %08x\n", regs->ctrl, regs->crcctrl, regs->crcdatain, regs->crcchksum); dmainfo(" CRCSTATUS: %02x DBGCTRL: %02x QOSCTRL: %02x SWTRIGCTRL: %08x\n", - regs->crcstatus, regs->errctrl, regs->qosctrl, regs->swtrigctrl); - dmainfo(" PRICTRL0: %08x INTPEND: %04x INSTSTATUS: %08x BUSYCH: %08x\n", + regs->crcstatus, regs->dbgctrl, regs->qosctrl, regs->swtrigctrl); + dmainfo(" PRICTRL0: %08x INTPEND: %04x INTSTATUS: %08x BUSYCH: %08x\n", regs->prictrl0, regs->intpend, regs->intstatus, regs->busych); dmainfo(" PENDCH: %08x ACTIVE: %08x BASEADDR: %08x WRBADDR: %08x\n", regs->pendch, regs->active, regs->baseaddr, regs->wrbaddr); dmainfo(" CHID: %02x CHCRTRLA: %02x CHCRTRLB: %08x CHINFLAG: %02x\n", - regs->chid, regs->chctrla, regs->chctrlb, regs->chintflag, + regs->chid, regs->chctrla, regs->chctrlb, regs->chintflag); dmainfo(" CHSTATUS: %02x\n", regs->chstatus); } diff --git a/arch/arm/src/samdl/sam_dmac.h b/arch/arm/src/samdl/sam_dmac.h index 2a6937dd6820014c626c3a88d8c86b2655b26471..f7b7a18b7bb67a32fd3053a5f10468e182d35b15 100644 --- a/arch/arm/src/samdl/sam_dmac.h +++ b/arch/arm/src/samdl/sam_dmac.h @@ -50,8 +50,8 @@ #ifdef CONFIG_SAMDL_DMAC -#if defined(CONFIG_ARCH_FAMILY_SAMD20) -# error Missing support for the SAMD20 architecture +#if defined(CONFIG_ARCH_FAMILY_SAMD20) || defined(CONFIG_ARCH_FAMILY_SAMD21) +# include "chip/samd_dmac.h" #elif defined(CONFIG_ARCH_FAMILY_SAML21) # include "chip/saml_dmac.h" #else diff --git a/arch/arm/src/samdl/sam_eic.c b/arch/arm/src/samdl/sam_eic.c new file mode 100644 index 0000000000000000000000000000000000000000..95a20504cb9ff0b60cce44925111de1a4ac324fb --- /dev/null +++ b/arch/arm/src/samdl/sam_eic.c @@ -0,0 +1,275 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_eic.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * References: + * 1. "Microchip SAM D21E / SAM D21G / SAM D21J Datasheet" + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "up_arch.h" + +#include "sam_config.h" + +#include "sam_pm.h" +#include "sam_gclk.h" +#include "sam_periphclks.h" +#include "sam_eic.h" +#include "sam_port.h" + +#include +#include +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int sam_eic_isr(int irq, FAR void *context, FAR void *arg) +{ + uint32_t intflag; + int bit; + + /* Get the pending interrupt flag register */ + + intflag = getreg32(SAM_EIC_INTFLAG); + + /* Dispatch the IRQ to the SAM_IRQ_EXTINTn handlers */ + + for(bit=0;bit> bit & 0x1) + { + irq_dispatch(SAM_IRQ_EXTINT0 + bit, context); + } + } + + /* Clear the pending interrupt flags */ + + putreg32(EIC_EXTINT_ALL, SAM_EIC_INTFLAG); + + return 0; +} + +static void sam_eic_syncwait(void) +{ + while ((getreg8(SAM_EIC_STATUS) & EIC_STATUS_SYNCBUSY) != 0); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void sam_eic_dumpregs(void) +{ + irqinfo("EIC:\n"); + irqinfo(" CTRLA: %02x\n", getreg8(SAM_EIC_CTRLA)); + irqinfo(" STATUS: %02x\n", getreg8(SAM_EIC_STATUS)); + irqinfo(" NMICTRL: %02x\n", getreg8(SAM_EIC_NMICTRL)); + irqinfo(" NMIFLAG: %02x\n", getreg8(SAM_EIC_NMIFLAG)); + irqinfo(" EVCTRL: %08x\n", getreg32(SAM_EIC_EVCTRL)); + irqinfo(" INTENCLR: %08x\n", getreg32(SAM_EIC_INTENCLR)); + irqinfo(" INTENSET: %08x\n", getreg32(SAM_EIC_INTENSET)); + irqinfo(" INTFLAG: %08x\n", getreg32(SAM_EIC_INTFLAG)); + irqinfo(" WAKEUP: %08x\n", getreg32(SAM_EIC_WAKEUP)); + irqinfo(" CONFIG0: %08x\n", getreg32(SAM_EIC_CONFIG0)); + irqinfo(" CONFIG1: %08x\n", getreg32(SAM_EIC_CONFIG1)); + irqinfo(" CONFIG2: %08x\n", getreg32(SAM_EIC_CONFIG2)); +} + +/**************************************************************************** + * Name: sam_eic_initialize + * + * Description: + * Initialize the external interrupt controller (EIC). + * + * Input Parameters: + * gclkgen - GCLK Generator + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_initialize(uint8_t gclkgen) +{ + uint16_t regval; + + sam_eic_enableperiph(); + + regval = GCLK_CLKCTRL_ID_EIC | GCLK_CLKCTRL_GEN(gclkgen) | GCLK_CLKCTRL_CLKEN; + putreg16(regval, SAM_GCLK_CLKCTRL); + + putreg8(EIC_CTRLA_ENABLE, SAM_EIC_CTRLA); + sam_eic_syncwait(); + + irq_attach(SAM_IRQ_EIC, sam_eic_isr, NULL); + + sam_eic_dumpregs(); + + up_enable_irq(SAM_IRQ_EIC); + + return OK; +} + +/**************************************************************************** + * Name: sam_eic_initialize + * + * Description: + * Enable a external interrupt. + * + * Input Parameters: + * irq - SAM_IRQ_EXTINTn IRQ to be enabled + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_irq_enable(int irq) +{ + uint32_t config; + int eirq = irq - SAM_IRQ_EXTINT0; + + config = getreg32(SAM_EIC_CONFIG0); + config |= EIC_CONFIG0_FILTEN(eirq) | EIC_CONFIG0_SENSE_FALL(eirq); + putreg32(config, SAM_EIC_CONFIG0); + + putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET); + sam_eic_dumpregs(); + return OK; +} + +/**************************************************************************** + * Name: sam_eic_config + * + * Description: + * Configure the interrupt edge sensitivity in CONFIGn register of the EIC + * + * Input Parameters: + * eirq - Pin to be configured + * pinset - Configuration of the pin + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_config(uint8_t eirq, port_pinset_t pinset) +{ + uint32_t reg; + uint32_t val; + uint32_t config; + + /* Determine which of the CONFIG[0:2] registers to write to */ + + if (eirq < 8) + { + reg = SAM_EIC_CONFIG0; + + val = EIC_CONFIG0_SENSE_BOTH(eirq); + if (pinset & PORT_INT_RISING) + { + val = EIC_CONFIG0_SENSE_RISE(eirq); + } + + if (pinset & PORT_INT_FALLING) + { + val = EIC_CONFIG0_SENSE_FALL(eirq); + } + + val |= EIC_CONFIG0_FILTEN(eirq); + } + else if (eirq < 16) + { + reg = SAM_EIC_CONFIG1; + + val = EIC_CONFIG1_SENSE_BOTH(eirq); + if (pinset & PORT_INT_RISING) + { + val = EIC_CONFIG1_SENSE_RISE(eirq); + } + + if (pinset & PORT_INT_FALLING) + { + val = EIC_CONFIG1_SENSE_FALL(eirq); + } + + val |= EIC_CONFIG1_FILTEN(eirq); + } + else + { + reg = SAM_EIC_CONFIG2; + + val = EIC_CONFIG2_SENSE_BOTH(eirq); + if (pinset & PORT_INT_RISING) + { + val = EIC_CONFIG2_SENSE_RISE(eirq); + } + + if (pinset & PORT_INT_FALLING) + { + val = EIC_CONFIG2_SENSE_FALL(eirq); + } + + val |= EIC_CONFIG2_FILTEN(eirq); + } + + /* Write the new config to the CONFIGn register */ + + config = getreg32(reg); + config |= val; + putreg32(config, reg); + + /* Enable interrupt generation for this pin */ + + putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET); + + sam_eic_dumpregs(); + return OK; +} diff --git a/arch/arm/src/samdl/sam_eic.h b/arch/arm/src/samdl/sam_eic.h new file mode 100644 index 0000000000000000000000000000000000000000..d60c936cef5193f7531b570fc07d96b6da478ae4 --- /dev/null +++ b/arch/arm/src/samdl/sam_eic.h @@ -0,0 +1,125 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_eic.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_SAM_EIC_H +#define __ARCH_ARM_SRC_SAMDL_SAM_EIC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "sam_config.h" +#include "sam_port.h" + +#if defined(CONFIG_ARCH_FAMILY_SAMD20) || defined(CONFIG_ARCH_FAMILY_SAMD21) +# include "chip/samd_eic.h" +#elif defined(CONFIG_ARCH_FAMILY_SAML21) +# include "chip/saml_eic.h" +#else +# error Unrecognized SAMD/L architecture +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: sam_eic_initialize + * + * Description: + * Initialize the EIC + * + * Input Parameters: + * gclkgen - GCLK Generator + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_initialize(uint8_t gclkgen); + +/**************************************************************************** + * Name: sam_eic_initialize + * + * Description: + * Enable a external interrupt. + * + * Input Parameters: + * irq - SAM_IRQ_EXTINTn IRQ to be enabled + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_irq_enable(int irq); + +/**************************************************************************** + * Name: sam_eic_config + * + * Description: + * Configure the interrupt edge sensitivity in CONFIGn register of the EIC + * + * Input Parameters: + * eirq - Pin to be configured + * pinset - Configuration of the pin + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_config(uint8_t eirq, port_pinset_t pinset); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ARCH_ARM_SRC_SAMDL_SAM_EIC_H */ diff --git a/arch/arm/src/samdl/sam_evsys.h b/arch/arm/src/samdl/sam_evsys.h new file mode 100644 index 0000000000000000000000000000000000000000..13b41fa3e5563f0a1f2b78f4178333f7f945e464 --- /dev/null +++ b/arch/arm/src/samdl/sam_evsys.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_evsys.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Matt Thompson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_SAM_EVSYS_H +#define __ARCH_ARM_SRC_SAMDL_SAM_EVSYS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "sam_config.h" +#include "sam_port.h" + +#if defined(CONFIG_ARCH_FAMILY_SAMD20) || defined(CONFIG_ARCH_FAMILY_SAMD21) +# include "chip/samd_evsys.h" +#elif defined(CONFIG_ARCH_FAMILY_SAML21) +# include "chip/saml_evsys.h" +#else +# error Unrecognized SAMD/L architecture +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ARCH_ARM_SRC_SAMDL_SAM_EVSYS_H */ diff --git a/arch/arm/src/samdl/sam_port.c b/arch/arm/src/samdl/sam_port.c index b757de5c581bd63193f19574b43fcf0970e6e209..df35aae65a7aa3e59c4993b4cd1907dbf94b83dc 100644 --- a/arch/arm/src/samdl/sam_port.c +++ b/arch/arm/src/samdl/sam_port.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/samdl/sam_port.c * - * Copyright (C) 2014-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -57,6 +57,7 @@ #include "chip.h" #include "sam_port.h" +#include "sam_eic.h" /**************************************************************************** * Private Data @@ -189,7 +190,30 @@ static inline void sam_configinput(uintptr_t base, port_pinset_t pinset) static inline void sam_configinterrupt(uintptr_t base, port_pinset_t pinset) { -#warning Missing logic +#ifdef CONFIG_SAMDL_EIC + uint32_t func; + uint32_t regval; + int pin; + + pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT; + + regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | + PORT_WRCONFIG_PMUXEN | PORT_WRCONFIG_INEN); + regval |= PORT_WRCONFIG_PINMASK(pin); + + func = (pinset & PORT_FUNC_MASK) >> PORT_FUNC_SHIFT; + regval |= (func << PORT_WRCONFIG_PMUX_SHIFT); + + putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET); + + /* Configure the interrupt edge sensitivity in CONFIGn register of the EIC */ + + sam_eic_config(pin, pinset); + +#ifdef CONFIG_DEBUG_GPIO_INFO + sam_dumpport(pinset, "extint"); +#endif +#endif /* CONFIG_SAMDL_EIC */ } /**************************************************************************** @@ -531,7 +555,7 @@ int sam_dumpport(uint32_t pinset, const char *msg) /* Get the base address associated with the PIO port */ - pin = sam_portpin(pinset); + pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT; port = (pinset & PORT_MASK) >> PORT_SHIFT; base = SAM_PORTN_BASE(port); diff --git a/arch/arm/src/samdl/sam_port.h b/arch/arm/src/samdl/sam_port.h index c03edcbcb5d38494b4be3e9beb3c2a622a9043fa..3227c5480381eaed2efab21bbe291d6366a97396 100644 --- a/arch/arm/src/samdl/sam_port.h +++ b/arch/arm/src/samdl/sam_port.h @@ -343,7 +343,7 @@ extern "C" * Description: * Configure a PORT pin based on bit-encoded description of the pin. * - * Returns: + * Returned Value: * OK (always) * ****************************************************************************/ diff --git a/arch/arm/src/samdl/sam_serial.c b/arch/arm/src/samdl/sam_serial.c index aab2d81d23d3d86712257b7377c1cc5b3df17c10..6f00639df84c17feb26e621d7f9877920f6ea9c1 100644 --- a/arch/arm/src/samdl/sam_serial.c +++ b/arch/arm/src/samdl/sam_serial.c @@ -524,7 +524,7 @@ static void sam_disableallints(struct sam_dev_s *priv) * interrupt received on the 'irq' It should call uart_transmitchars or * uart_receivechar to perform the appropriate data transfers. The * interrupt handling logic must be able to map the 'irq' number into the - * approprite uart_dev_s structure in order to call these functions. + * appropriate uart_dev_s structure in order to call these functions. * ****************************************************************************/ @@ -1010,4 +1010,3 @@ int up_putc(int ch) #endif /* USE_SERIALDRIVER */ #endif /* SAMDL_HAVE_USART */ - diff --git a/arch/arm/src/samdl/sam_spi.c b/arch/arm/src/samdl/sam_spi.c index 1f945b765932d5839d6d9337ad4b39e976d01af1..ab75f1f4b349665c11233850da9e9d8e0f61080a 100644 --- a/arch/arm/src/samdl/sam_spi.c +++ b/arch/arm/src/samdl/sam_spi.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/samdl/sam_spi.c * - * Copyright (C) 2014-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2018 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * * References: @@ -69,6 +69,10 @@ #include "sam_sercom.h" #include "sam_spi.h" +#ifdef CONFIG_SAMDL_SPI_DMA +# include "sam_dmac.h" +#endif + #include #ifdef SAMDL_HAVE_SPI @@ -118,6 +122,16 @@ struct sam_spidev_s uint8_t mode; /* Mode 0,1,2,3 */ uint8_t nbits; /* Width of word in bits (8 to 16) */ +#ifdef CONFIG_SAMDL_SPI_DMA + /* DMA */ + + uint8_t dma_tx_trig; /* DMA TX trigger source to use */ + uint8_t dma_rx_trig; /* DMA RX trigger source to use */ + DMA_HANDLE dma_tx; /* DMA TX channel handle */ + DMA_HANDLE dma_rx; /* DMA RX channel handle */ + sem_t dmasem; /* Transfer wait semaphore */ +#endif + /* Debug stuff */ #ifdef CONFIG_SAMDL_SPI_REGDEBUG @@ -154,6 +168,10 @@ static uint32_t spi_getreg32(struct sam_spidev_s *priv, static void spi_putreg32(struct sam_spidev_s *priv, uint32_t regval, unsigned int offset); +#ifdef CONFIG_SAMDL_SPI_DMA +static void spi_dma_setup(struct sam_spidev_s *priv); +#endif + #ifdef CONFIG_DEBUG_SPI_INFO static void spi_dumpregs(struct sam_spidev_s *priv, const char *msg); #else @@ -163,7 +181,7 @@ static void spi_dumpregs(struct sam_spidev_s *priv, const char *msg); /* Interrupt handling */ #if 0 /* Not used */ -static int spi_interrupt(int irq, void *context, FAR void *arg); +static int spi_interrupt(int irq, void *context, FAR void *arg); #endif /* SPI methods */ @@ -222,21 +240,25 @@ static const struct spi_ops_s g_spi0ops = static struct sam_spidev_s g_spi0dev = { - .ops = &g_spi0ops, - .sercom = 0, + .ops = &g_spi0ops, + .sercom = 0, #if 0 /* Not used */ - .irq = SAM_IRQ_SERCOM0, -#endif - .gclkgen = BOARD_SERCOM0_GCLKGEN, - .slowgen = BOARD_SERCOM0_SLOW_GCLKGEN, - .pad0 = BOARD_SERCOM0_PINMAP_PAD0, - .pad1 = BOARD_SERCOM0_PINMAP_PAD1, - .pad2 = BOARD_SERCOM0_PINMAP_PAD2, - .pad3 = BOARD_SERCOM0_PINMAP_PAD3, - .muxconfig = BOARD_SERCOM0_MUXCONFIG, - .srcfreq = BOARD_SERCOM0_FREQUENCY, - .base = SAM_SERCOM0_BASE, - .spilock = SEM_INITIALIZER(1), + .irq = SAM_IRQ_SERCOM0, +#endif + .gclkgen = BOARD_SERCOM0_GCLKGEN, + .slowgen = BOARD_SERCOM0_SLOW_GCLKGEN, + .pad0 = BOARD_SERCOM0_PINMAP_PAD0, + .pad1 = BOARD_SERCOM0_PINMAP_PAD1, + .pad2 = BOARD_SERCOM0_PINMAP_PAD2, + .pad3 = BOARD_SERCOM0_PINMAP_PAD3, + .muxconfig = BOARD_SERCOM0_MUXCONFIG, + .srcfreq = BOARD_SERCOM0_FREQUENCY, + .base = SAM_SERCOM0_BASE, + .spilock = SEM_INITIALIZER(1), +#ifdef CONFIG_SAMDL_SPI_DMA + .dma_tx_trig = DMAC_TRIGSRC_SERCOM0_TX, + .dma_rx_trig = DMAC_TRIGSRC_SERCOM0_RX, +#endif }; #endif @@ -268,21 +290,25 @@ static const struct spi_ops_s g_spi1ops = static struct sam_spidev_s g_spi1dev = { - .ops = &g_spi1ops, - .sercom = 1, + .ops = &g_spi1ops, + .sercom = 1, #if 0 /* Not used */ - .irq = SAM_IRQ_SERCOM1, -#endif - .gclkgen = BOARD_SERCOM1_GCLKGEN, - .slowgen = BOARD_SERCOM1_SLOW_GCLKGEN, - .pad0 = BOARD_SERCOM1_PINMAP_PAD0, - .pad1 = BOARD_SERCOM1_PINMAP_PAD1, - .pad2 = BOARD_SERCOM1_PINMAP_PAD2, - .pad3 = BOARD_SERCOM1_PINMAP_PAD3, - .muxconfig = BOARD_SERCOM1_MUXCONFIG, - .srcfreq = BOARD_SERCOM1_FREQUENCY, - .base = SAM_SERCOM1_BASE, - .spilock = SEM_INITIALIZER(1), + .irq = SAM_IRQ_SERCOM1, +#endif + .gclkgen = BOARD_SERCOM1_GCLKGEN, + .slowgen = BOARD_SERCOM1_SLOW_GCLKGEN, + .pad0 = BOARD_SERCOM1_PINMAP_PAD0, + .pad1 = BOARD_SERCOM1_PINMAP_PAD1, + .pad2 = BOARD_SERCOM1_PINMAP_PAD2, + .pad3 = BOARD_SERCOM1_PINMAP_PAD3, + .muxconfig = BOARD_SERCOM1_MUXCONFIG, + .srcfreq = BOARD_SERCOM1_FREQUENCY, + .base = SAM_SERCOM1_BASE, + .spilock = SEM_INITIALIZER(1), +#ifdef CONFIG_SAMDL_SPI_DMA + .dma_tx_trig = DMAC_TRIGSRC_SERCOM1_TX, + .dma_rx_trig = DMAC_TRIGSRC_SERCOM1_RX, +#endif }; #endif @@ -292,13 +318,13 @@ static struct sam_spidev_s g_spi1dev = static const struct spi_ops_s g_spi2ops = { .lock = spi_lock, - .select = sam_spi0select, + .select = sam_spi2select, .setfrequency = spi_setfrequency, .setmode = spi_setmode, .setbits = spi_setbits, - .status = sam_spi0status, + .status = sam_spi2status, #ifdef CONFIG_SPI_CMDDATA - .cmddata = sam_spi0cmddata, + .cmddata = sam_spi2cmddata, #endif .send = spi_send, #ifdef CONFIG_SPI_EXCHANGE @@ -314,21 +340,25 @@ static const struct spi_ops_s g_spi2ops = static struct sam_spidev_s g_spi2dev = { - .ops = &g_spi1ops, - .sercom = 2, + .ops = &g_spi2ops, + .sercom = 2, #if 0 /* Not used */ - .irq = SAM_IRQ_SERCOM2, -#endif - .gclkgen = BOARD_SERCOM2_GCLKGEN, - .slowgen = BOARD_SERCOM2_SLOW_GCLKGEN, - .pad0 = BOARD_SERCOM2_PINMAP_PAD0, - .pad1 = BOARD_SERCOM2_PINMAP_PAD1, - .pad2 = BOARD_SERCOM2_PINMAP_PAD2, - .pad3 = BOARD_SERCOM2_PINMAP_PAD3, - .muxconfig = BOARD_SERCOM2_MUXCONFIG, - .srcfreq = BOARD_SERCOM2_FREQUENCY, - .base = SAM_SERCOM2_BASE, - .spilock = SEM_INITIALIZER(1), + .irq = SAM_IRQ_SERCOM2, +#endif + .gclkgen = BOARD_SERCOM2_GCLKGEN, + .slowgen = BOARD_SERCOM2_SLOW_GCLKGEN, + .pad0 = BOARD_SERCOM2_PINMAP_PAD0, + .pad1 = BOARD_SERCOM2_PINMAP_PAD1, + .pad2 = BOARD_SERCOM2_PINMAP_PAD2, + .pad3 = BOARD_SERCOM2_PINMAP_PAD3, + .muxconfig = BOARD_SERCOM2_MUXCONFIG, + .srcfreq = BOARD_SERCOM2_FREQUENCY, + .base = SAM_SERCOM2_BASE, + .spilock = SEM_INITIALIZER(1), +#ifdef CONFIG_SAMDL_SPI_DMA + .dma_tx_trig = DMAC_TRIGSRC_SERCOM2_TX, + .dma_rx_trig = DMAC_TRIGSRC_SERCOM2_RX, +#endif }; #endif @@ -360,21 +390,25 @@ static const struct spi_ops_s g_spi3ops = static struct sam_spidev_s g_spi3dev = { - .ops = &g_spi3ops, - .sercom = 3, + .ops = &g_spi3ops, + .sercom = 3, #if 0 /* Not used */ - .irq = SAM_IRQ_SERCOM3, -#endif - .gclkgen = BOARD_SERCOM3_GCLKGEN, - .slowgen = BOARD_SERCOM3_SLOW_GCLKGEN, - .pad0 = BOARD_SERCOM3_PINMAP_PAD0, - .pad1 = BOARD_SERCOM3_PINMAP_PAD1, - .pad2 = BOARD_SERCOM3_PINMAP_PAD2, - .pad3 = BOARD_SERCOM3_PINMAP_PAD3, - .muxconfig = BOARD_SERCOM3_MUXCONFIG, - .srcfreq = BOARD_SERCOM3_FREQUENCY, - .base = SAM_SERCOM3_BASE, - .spilock = SEM_INITIALIZER(1), + .irq = SAM_IRQ_SERCOM3, +#endif + .gclkgen = BOARD_SERCOM3_GCLKGEN, + .slowgen = BOARD_SERCOM3_SLOW_GCLKGEN, + .pad0 = BOARD_SERCOM3_PINMAP_PAD0, + .pad1 = BOARD_SERCOM3_PINMAP_PAD1, + .pad2 = BOARD_SERCOM3_PINMAP_PAD2, + .pad3 = BOARD_SERCOM3_PINMAP_PAD3, + .muxconfig = BOARD_SERCOM3_MUXCONFIG, + .srcfreq = BOARD_SERCOM3_FREQUENCY, + .base = SAM_SERCOM3_BASE, + .spilock = SEM_INITIALIZER(1), +#ifdef CONFIG_SAMDL_SPI_DMA + .dma_tx_trig = DMAC_TRIGSRC_SERCOM3_TX, + .dma_rx_trig = DMAC_TRIGSRC_SERCOM3_RX, +#endif }; #endif @@ -406,21 +440,25 @@ static const struct spi_ops_s g_spi4ops = static struct sam_spidev_s g_spi4dev = { - .ops = &g_spi4ops, - .sercom = 4, + .ops = &g_spi4ops, + .sercom = 4, #if 0 /* Not used */ - .irq = SAM_IRQ_SERCOM4, -#endif - .gclkgen = BOARD_SERCOM4_GCLKGEN, - .slowgen = BOARD_SERCOM4_SLOW_GCLKGEN, - .pad0 = BOARD_SERCOM4_PINMAP_PAD0, - .pad1 = BOARD_SERCOM4_PINMAP_PAD1, - .pad2 = BOARD_SERCOM4_PINMAP_PAD2, - .pad3 = BOARD_SERCOM4_PINMAP_PAD3, - .muxconfig = BOARD_SERCOM4_MUXCONFIG, - .srcfreq = BOARD_SERCOM4_FREQUENCY, - .base = SAM_SERCOM4_BASE, - .spilock = SEM_INITIALIZER(1), + .irq = SAM_IRQ_SERCOM4, +#endif + .gclkgen = BOARD_SERCOM4_GCLKGEN, + .slowgen = BOARD_SERCOM4_SLOW_GCLKGEN, + .pad0 = BOARD_SERCOM4_PINMAP_PAD0, + .pad1 = BOARD_SERCOM4_PINMAP_PAD1, + .pad2 = BOARD_SERCOM4_PINMAP_PAD2, + .pad3 = BOARD_SERCOM4_PINMAP_PAD3, + .muxconfig = BOARD_SERCOM4_MUXCONFIG, + .srcfreq = BOARD_SERCOM4_FREQUENCY, + .base = SAM_SERCOM4_BASE, + .spilock = SEM_INITIALIZER(1), +#ifdef CONFIG_SAMDL_SPI_DMA + .dma_tx_trig = DMAC_TRIGSRC_SERCOM4_TX, + .dma_rx_trig = DMAC_TRIGSRC_SERCOM4_RX, +#endif }; #endif @@ -452,21 +490,25 @@ static const struct spi_ops_s g_spi5ops = static struct sam_spidev_s g_spi5dev = { - .ops = &g_spi5ops, - .sercom = 5, + .ops = &g_spi5ops, + .sercom = 5, #if 0 /* Not used */ - .irq = SAM_IRQ_SERCOM5, -#endif - .gclkgen = BOARD_SERCOM5_GCLKGEN, - .slowgen = BOARD_SERCOM5_SLOW_GCLKGEN, - .pad0 = BOARD_SERCOM5_PINMAP_PAD0, - .pad1 = BOARD_SERCOM5_PINMAP_PAD1, - .pad2 = BOARD_SERCOM5_PINMAP_PAD2, - .pad3 = BOARD_SERCOM5_PINMAP_PAD3, - .muxconfig = BOARD_SERCOM5_MUXCONFIG, - .srcfreq = BOARD_SERCOM5_FREQUENCY, - .base = SAM_SERCOM5_BASE, - .spilock = SEM_INITIALIZER(1), + .irq = SAM_IRQ_SERCOM5, +#endif + .gclkgen = BOARD_SERCOM5_GCLKGEN, + .slowgen = BOARD_SERCOM5_SLOW_GCLKGEN, + .pad0 = BOARD_SERCOM5_PINMAP_PAD0, + .pad1 = BOARD_SERCOM5_PINMAP_PAD1, + .pad2 = BOARD_SERCOM5_PINMAP_PAD2, + .pad3 = BOARD_SERCOM5_PINMAP_PAD3, + .muxconfig = BOARD_SERCOM5_MUXCONFIG, + .srcfreq = BOARD_SERCOM5_FREQUENCY, + .base = SAM_SERCOM5_BASE, + .spilock = SEM_INITIALIZER(1), +#ifdef CONFIG_SAMDL_SPI_DMA + .dma_tx_trig = DMAC_TRIGSRC_SERCOM5_TX, + .dma_rx_trig = DMAC_TRIGSRC_SERCOM5_RX, +#endif }; #endif @@ -944,7 +986,12 @@ static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode) { /* Yes... Set the mode appropriately */ + /* First we need to disable SPI while we change the mode */ + regval = spi_getreg32(priv, SAM_SPI_CTRLA_OFFSET); + spi_putreg32(priv, regval & ~SPI_CTRLA_ENABLE, SAM_SPI_CTRLA_OFFSET); + spi_wait_synchronization(priv); + regval &= ~(SPI_CTRLA_CPOL | SPI_CTRLA_CPHA); switch (mode) @@ -969,7 +1016,7 @@ static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode) return; } - spi_putreg32(priv, regval, SAM_SPI_CTRLA_OFFSET); + spi_putreg32(priv, regval | SPI_CTRLA_ENABLE, SAM_SPI_CTRLA_OFFSET); /* Save the mode so that subsequent re-configurations will be faster */ @@ -1056,6 +1103,45 @@ static uint16_t spi_send(struct spi_dev_s *dev, uint16_t wd) return (uint16_t)rxbyte; } +/**************************************************************************** + * Name: spi_dma_callback + * + * Description: + * DMA completion callback + * + * Input Parameters: + * dma - Allocate DMA handle + * arg - User argument provided with callback + * result - The result of the DMA operation + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_SAMDL_SPI_DMA +static void spi_dma_callback(DMA_HANDLE dma, void *arg, int result) +{ + struct sam_spidev_s *priv = (struct sam_spidev_s *)arg; + + if (dma == priv->dma_rx) + { + /* Notify the blocked spi_exchange() call that the transaction + * has completed by posting to the semaphore + */ + + nxsem_post(&priv->dmasem); + } + else if (dma == priv->dma_tx) + { + if (result != OK) + { + spierr("ERROR: DMA transmission failed: %d\n", result); + } + } +} +#endif + /**************************************************************************** * Name: spi_exchange * @@ -1084,6 +1170,47 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, void *rxbuffer, size_t nwords) { struct sam_spidev_s *priv = (struct sam_spidev_s *)dev; + +#ifdef CONFIG_SAMDL_SPI_DMA + uint32_t regval; + int ret; + + spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", txbuffer, rxbuffer, nwords); + + /* Disable SPI while we configure new DMA descriptors */ + + regval = spi_getreg32(priv, SAM_SPI_CTRLA_OFFSET); + regval &= ~SPI_CTRLA_ENABLE; + spi_putreg32(priv, regval, SAM_SPI_CTRLA_OFFSET); + spi_wait_synchronization(priv); + + /* Setup RX and TX DMA channels */ + + sam_dmatxsetup(priv->dma_tx, priv->base + SAM_SPI_DATA_OFFSET, + (uint32_t)txbuffer, nwords); + sam_dmarxsetup(priv->dma_rx, priv->base + SAM_SPI_DATA_OFFSET, + (uint32_t)rxbuffer, nwords); + + /* Start RX and TX DMA channels */ + + sam_dmastart(priv->dma_tx, spi_dma_callback, (void *)priv); + sam_dmastart(priv->dma_rx, spi_dma_callback, (void *)priv); + + /* Enable SPI to trigger the TX DMA channel */ + + regval = spi_getreg32(priv, SAM_SPI_CTRLA_OFFSET); + regval |= SPI_CTRLA_ENABLE; + spi_putreg32(priv, regval, SAM_SPI_CTRLA_OFFSET); + spi_wait_synchronization(priv); + + do + { + /* Wait for the DMA callback to notify us that the transfer is complete */ + + ret = nxsem_wait(&priv->dmasem); + } + while (ret < 0 && ret == -EINTR); +#else const uint16_t *ptx16; const uint8_t *ptx8; uint16_t *prx16; @@ -1198,6 +1325,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, *prx16++ = (uint16_t)data; } } +#endif } /**************************************************************************** @@ -1307,6 +1435,34 @@ static void spi_pad_configure(struct sam_spidev_s *priv) } } +/**************************************************************************** + * Name: spi_dma_setup + * + * Description: + * Configure the SPI DMA operation. + * + ****************************************************************************/ + +#ifdef CONFIG_SAMDL_SPI_DMA +static void spi_dma_setup(struct sam_spidev_s *priv) +{ + /* Allocate a pair of DMA channels */ + + priv->dma_rx = sam_dmachannel(DMACH_FLAG_BEATSIZE_BYTE | + DMACH_FLAG_MEM_INCREMENT | + DMACH_FLAG_PERIPH_RXTRIG(priv->dma_rx_trig)); + + priv->dma_tx = sam_dmachannel(DMACH_FLAG_BEATSIZE_BYTE | + DMACH_FLAG_MEM_INCREMENT | + DMACH_FLAG_PERIPH_TXTRIG(priv->dma_tx_trig)); + + /* Initialize the semaphore used to notify when DMA is complete */ + + nxsem_init(&priv->dmasem, 0, 0); + nxsem_setprotocol(&priv->dmasem, SEM_PRIO_NONE); +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -1317,7 +1473,7 @@ static void spi_pad_configure(struct sam_spidev_s *priv) * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * port - SPI "port" number (i.e., SERCOM number) * * Returned Value: @@ -1393,6 +1549,10 @@ struct spi_dev_s *sam_spibus_initialize(int port) return NULL; } +#ifdef CONFIG_SAMDL_SPI_DMA + spi_dma_setup(priv); +#endif + /* Enable clocking to the SERCOM module in PM */ flags = enter_critical_section(); @@ -1421,7 +1581,7 @@ struct spi_dev_s *sam_spibus_initialize(int port) /* Set the SERCOM in SPI master mode (no address) */ regval = spi_getreg32(priv, SAM_SPI_CTRLA_OFFSET); - regval &= ~SPI_CTRLA_MODE_MASK; + regval &= ~(SPI_CTRLA_MODE_MASK | SPI_CTRLA_FORM_MASK); regval |= (SPI_CTRLA_MODE_MASTER | SPI_CTRLA_FORM_SPI); spi_putreg32(priv, regval, SAM_SPI_CTRLA_OFFSET); @@ -1435,11 +1595,13 @@ struct spi_dev_s *sam_spibus_initialize(int port) (void)spi_setfrequency((struct spi_dev_s *)priv, 400000); - /* Set MSB first data order and the configured pad mux setting, - * Note that SPI mode 0 is assumed initially (CPOL=0 and CPHA=0). + /* Set MSB first data order and the configured pad mux setting. + * SPI mode 0 is assumed initially (CPOL=0 and CPHA=0). */ - regval = (SPI_CTRLA_MSBFIRST | priv->muxconfig); + regval &= ~(SPI_CTRLA_DOPO_MASK | SPI_CTRLA_DIPO_MASK); + regval &= ~(SPI_CTRLA_CPHA | SPI_CTRLA_CPOL); + regval |= (SPI_CTRLA_MSBFIRST | priv->muxconfig); spi_putreg32(priv, regval, SAM_SPI_CTRLA_OFFSET); /* Enable the receiver. Note that 8-bit data width is assumed initially */ diff --git a/arch/arm/src/samdl/sam_spi.h b/arch/arm/src/samdl/sam_spi.h index 7e0cbfa9e08d53a0167294d39bd9b3230b622b65..d4044ab19cd820f282e662c23ba129c1fd9462a3 100644 --- a/arch/arm/src/samdl/sam_spi.h +++ b/arch/arm/src/samdl/sam_spi.h @@ -94,7 +94,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * port - SPI "port" number (i.e., SERCOM number) * * Returned Value: @@ -161,7 +161,7 @@ struct spi_dev_s *sam_spibus_initialize(int port); * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -206,7 +206,7 @@ void sam_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -254,7 +254,7 @@ uint8_t sam_spi5status(FAR struct spi_dev_s *dev, uint32_t devid); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/arch/arm/src/samdl/sam_usb.c b/arch/arm/src/samdl/sam_usb.c index 02521250738660b96e16f7aa4eca7ebf1fa05ce8..2132fec4b70d3397b4f8f25640682f92e169807c 100644 --- a/arch/arm/src/samdl/sam_usb.c +++ b/arch/arm/src/samdl/sam_usb.c @@ -107,17 +107,13 @@ #include "up_arch.h" #include "up_internal.h" -#if defined(CONFIG_ARCH_FAMILY_SAMD20) || defined(CONFIG_ARCH_FAMILY_SAMD21) - #include "samd_periphclks.h" -#elif defined(CONFIG_ARCH_FAMILY_SAML21) - #include "saml_periphclks.h" -#endif - #include "sam_gclk.h" #include "chip.h" #include "sam_port.h" #include "sam_pinmap.h" #include "sam_usb.h" +#include "sam_fuses.h" +#include "sam_periphclks.h" #if defined(CONFIG_USBHOST) && defined(CONFIG_SAMDL_USB) # error USBHOST mode not yet implemented! @@ -321,7 +317,6 @@ struct sam_rqhead_s struct sam_req_s *tail; /* Requests are removed from the tail of the list */ }; - /* This is the internal representation of an endpoint */ struct sam_ep_s @@ -2476,8 +2471,6 @@ static void sam_ep0_dispatch(struct sam_usbdev_s *priv) static void sam_setdevaddr(struct sam_usbdev_s *priv, uint8_t address) { - uint32_t regval; - DEBUGASSERT(address <= 0x7f); if (address) { @@ -3435,6 +3428,8 @@ static int sam_usb_interrupt(int irq, void *context, void *arg) uwarn("WARNING: Unhandled_EP:0x%X\n", pendingep); } #endif + + return OK; } void up_usbuninitialize(void) @@ -3491,7 +3486,7 @@ errout: /**************************************************************************** * Name: sam_ep_reset * - * Description + * Description: * Reset and disable one endpoints. * ****************************************************************************/ @@ -3528,7 +3523,7 @@ static void sam_ep_reset(struct sam_usbdev_s *priv, uint8_t epno) /**************************************************************************** * Name: sam_epset_reset * - * Description + * Description: * Reset and disable a set of endpoints. * ****************************************************************************/ @@ -3782,6 +3777,10 @@ static void sam_hw_setup(struct sam_usbdev_s *priv) uint16_t regval; uint32_t padcalib; + uint8_t calib_transn; + uint8_t calib_transp; + uint8_t calib_trim; + /* To use the USB, the programmer must first configure the USB clock * input, */ @@ -3792,11 +3791,21 @@ static void sam_hw_setup(struct sam_usbdev_s *priv) sam_ctrla_write(USB_CTRLA_SWRST); - /* TODO: load PAD calibration from NVM or ... - * now using default values - */ + /* Load USB factory calibration values from NVRAM */ + + calib_transn = getreg32(SYSCTRL_FUSES_USBTRANSN_ADDR) & + SYSCTRL_FUSES_USBTRANSN_MASK >> SYSCTRL_FUSES_USBTRANSN_SHIFT; + + calib_transp = getreg32(SYSCTRL_FUSES_USBTRANSP_ADDR) & + SYSCTRL_FUSES_USBTRANSP_MASK >> SYSCTRL_FUSES_USBTRANSP_SHIFT; + + calib_trim = getreg32(SYSCTRL_FUSES_USBTRIM_ADDR) & + SYSCTRL_FUSES_USBTRIM_MASK >> SYSCTRL_FUSES_USBTRIM_SHIFT; + + padcalib = USB_PADCAL_TRANSP(calib_transp) | + USB_PADCAL_TRANSN(calib_transn) | + USB_PADCAL_TRIM(calib_trim); - padcalib = USB_PADCAL_TRANSP(29) | USB_PADCAL_TRANSN(5) | USB_PADCAL_TRIM(3); sam_putreg32(padcalib, SAM_USB_PADCAL); /* set config @@ -3866,8 +3875,6 @@ static void sam_hw_setup(struct sam_usbdev_s *priv) static void sam_hw_shutdown(struct sam_usbdev_s *priv) { - uint16_t regval; - priv->usbdev.speed = USB_SPEED_UNKNOWN; /* Disable all interrupts */ diff --git a/arch/arm/src/samdl/samd_clockconfig.c b/arch/arm/src/samdl/samd_clockconfig.c index a17c30235c8b0397dd5dd8342cb2a9717fb3dfd7..87f9bfd0d99cf4f2fe9174f988859c4c7713d234 100644 --- a/arch/arm/src/samdl/samd_clockconfig.c +++ b/arch/arm/src/samdl/samd_clockconfig.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/samdl/samd_clockconfig.c * - * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -453,11 +453,10 @@ static inline void sam_osc32k_config(void) regval = getreg32(SYSCTRL_FUSES_OSC32KCAL_ADDR); calib = (regval & SYSCTRL_FUSES_OSC32KCAL_MASK) >> SYSCTRL_FUSES_OSC32KCAL_SHIFT; - regval = calib << SYSCTRL_OSC32K_CALIB_SHIFT; /* Configure OSC32K */ - regval |= BOARD_OSC32K_STARTUPTIME; + regval = BOARD_OSC32K_STARTUPTIME; #ifdef BOARD_OSC32K_EN1KHZ regval |= SYSCTRL_OSC32K_EN1K; @@ -481,6 +480,18 @@ static inline void sam_osc32k_config(void) regval |= SYSCTRL_OSC32K_ENABLE; putreg32(regval, SAM_SYSCTRL_OSC32K); + + /* From the datasheet on page 157: + * "When writing to the Calibration bits, the user must wait for the + * PCLKSR.OSC32KRDY bit to go high before the value is committed + * to the oscillator." + */ + + while ((getreg32(SAM_SYSCTRL_PCLKSR) & SYSCTRL_INT_OSC32KRDY) == 0); + + regval = getreg32(SAM_SYSCTRL_OSC32K); + regval |= calib << SYSCTRL_OSC32K_CALIB_SHIFT; + putreg32(regval, SAM_SYSCTRL_OSC32K); } #else # define sam_osc32k_config() @@ -556,6 +567,91 @@ static inline void sam_osc8m_config(void) putreg32(regval, SAM_SYSCTRL_OSC8M); } +#ifdef BOARD_DPLL_ENABLE +static inline void sam_dpll_config(void) +{ + uint8_t ctrla; + uint32_t ctrlb; + uint32_t ratio; + + ctrla = SYSCTRL_DPLLCTRLA_ENABLE; /* Enable the FDPLL */ + ctrlb = 0; + ratio = 0; + +#ifdef BOARD_DPLL_RUNINSTANDBY + ctrla |= SYSCTRL_DPLLCTRLA_RUNSTDBY; /* Run in standby */ +#endif + +#ifdef BOARD_DPLL_ONDEMAND + ctrla |= SYSCTRL_DPLLCTRLA_ONDEMAND; /* On demand mode */ +#endif + +#ifdef BOARD_DPLL_DIV + ctrlb |= SYSCTRL_DPLLCTRLB_DIV(BOARD_DPLL_DIV); +#endif + +#ifdef BOARD_DPLL_LBYPASS + ctrlb |= SYSCTRL_DPLLCTRLB_LBYPASS; +#endif + +#ifdef BOARD_DPLL_LTIME + ctrlb |= BOARD_DPLL_LTIME; +#endif + +#ifdef BOARD_DPLL_REFCLK + ctrlb |= BOARD_DPLL_REFCLK; + ratio = SYSCTRL_DPLLRATIO_LDR(BOARD_DPLL_LDR); +#ifdef BOARD_DPLL_LDRFRAC + ratio |= SYSCTRL_DPLLRATIO_LDRFRAC(BOARD_DPLL_LDRFRAC); +#endif + + /* If a GCLK reference was requested, we must initialize the GCLK first */ + + if (BOARD_DPLL_REFCLK == SYSCTRL_DPLLCTRLB_REFCLK_GCLKDPLL) + { + putreg16(GCLK_CLKCTRL_ID_DPLL | GCLK_CLKCTRL_GEN(2) | GCLK_CLKCTRL_CLKEN, SAM_GCLK_CLKCTRL); + } + + putreg32(ratio, SAM_SYSCTRL_DPLLRATIO); +#else + + /* If no reference clock was specified, default to using + * the external 32KHz crystal and output of 96MHz + */ + + ctrlb |= SYSCTRL_DPLLCTRLB_REFCLK_XOSC32; + ratio = SYSCTRL_DPLLRATIO_LDR(3000); + putreg32(ratio, SAM_SYSCTRL_DPLLRATIO); +#endif + +#ifdef BOARD_DPLL_WUF + ctrlb |= BOARD_DPLL_WUF; +#endif + +#ifdef BOARD_DPLL_LPEN + ctrlb |= BOARD_DPLL_LPEN; +#endif + +#ifdef BOARD_DPLL_FILTER + ctrlb |= BOARD_DPLL_FILTER; +#endif + + /* Write Control B register */ + + putreg32(ctrlb, SAM_SYSCTRL_DPLLCTRLB); + + /* Write Control A register */ + + putreg8(ctrla, SAM_SYSCTRL_DPLLCTRLA); + + /* Wait for the DPLL to synchronize */ + + while ((getreg8(SAM_SYSCTRL_DPLLSTATUS) & SYSCTRL_DPLLSTATUS_CLKRDY) == 0); +} +#else +# define sam_dpll_config() +#endif + /**************************************************************************** * Name: sam_dfll_config * @@ -866,10 +962,12 @@ void sam_clockconfig(void) /* Configure XOSC */ + putreg16(0, SAM_SYSCTRL_XOSC); sam_xosc_config(); /* Configure XOSC32K */ + putreg16(0, SAM_SYSCTRL_XOSC32K); sam_xosc32k_config(); /* Configure OSCK32K */ @@ -884,6 +982,10 @@ void sam_clockconfig(void) sam_osc8m_config(); + /* Configure DPLL */ + + sam_dpll_config(); + /* Configure GCLK(s) */ sam_config_gclks(); diff --git a/arch/arm/src/samdl/samd_periphclks.h b/arch/arm/src/samdl/samd_periphclks.h index 0ba3df0f879d10e4c79dc50a1e4c97bc5103dd4d..0130cb6372cf61c94d5a71314ca4c0f6c3879a6c 100644 --- a/arch/arm/src/samdl/samd_periphclks.h +++ b/arch/arm/src/samdl/samd_periphclks.h @@ -75,7 +75,7 @@ #define sam_apbc_enableperiph(s) modifyreg32(SAM_PM_APBCMASK,0,s) #define sam_pac2_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_PAC2) -#define sam_devsys_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_EVSYS) +#define sam_evsys_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_EVSYS) #define sam_sercom_enableperiph(n) sam_apbc_enableperiph(PM_APBCMASK_SERCOM(n)) #define sam_sercom0_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_SERCOM0) #define sam_sercom1_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_SERCOM1) @@ -107,7 +107,7 @@ #define sam_ptc_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_PTC) #ifdef CONFIG_ARCH_FAMILY_SAMD21 -# define sam_i2s_enableperiph() sam_apbc_enableperiph(PM_APBBMASK_I2S) +# define sam_i2s_enableperiph() sam_apbc_enableperiph(PM_APBCMASK_I2S) #endif #define sam_apba_disableperiph(s) modifyreg32(SAM_PM_APBAMASK,s,0) @@ -135,7 +135,7 @@ #define sam_apbc_disableperiph(s) modifyreg32(SAM_PM_APBCMASK,s,0) #define sam_pac2_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_PAC2) -#define sam_devsys_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_EVSYS) +#define sam_evsys_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_EVSYS) #define sam_sercom_disableperiph(n) sam_apbc_disableperiph(PM_APBCMASK_SERCOM(n)) #define sam_sercom0_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_SERCOM0) #define sam_sercom1_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_SERCOM1) @@ -167,7 +167,7 @@ #define sam_ptc_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_PTC) #ifdef CONFIG_ARCH_FAMILY_SAMD21 -# define sam_i2s_disableperiph() sam_apbc_disableperiph(PM_APBBMASK_I2S) +# define sam_i2s_disableperiph() sam_apbc_disableperiph(PM_APBCMASK_I2S) #endif #define sam_apba_isenabled(s) (getreg32(SAM_PM_APBAMASK) & (s)) != 0) @@ -195,7 +195,7 @@ #define sam_apbc_isenabled(s) (getreg32(SAM_PM_APBCMASK) & (s)) != 0) #define sam_pac2_isenabled() sam_apbc_isenabled(PM_APBCMASK_PAC2) -#define sam_devsys_isenabled() sam_apbc_isenabled(PM_APBCMASK_EVSYS) +#define sam_evsys_isenabled() sam_apbc_isenabled(PM_APBCMASK_EVSYS) #define sam_sercom_isenabled(n) sam_apbc_isenabled(PM_APBCMASK_SERCOM(n)) #define sam_sercom0_isenabled() sam_apbc_isenabled(PM_APBCMASK_SERCOM0) #define sam_sercom1_isenabled() sam_apbc_isenabled(PM_APBCMASK_SERCOM1) @@ -227,7 +227,7 @@ #define sam_ptc_isenabled() sam_apbc_isenabled(PM_APBCMASK_PTC) #ifdef CONFIG_ARCH_FAMILY_SAMD21 -# define sam_i2s_isenabled() sam_apbc_isenabled(PM_APBBMASK_I2S) +# define sam_i2s_isenabled() sam_apbc_isenabled(PM_APBCMASK_I2S) #endif /**************************************************************************** diff --git a/arch/arm/src/samdl/saml_clockconfig.c b/arch/arm/src/samdl/saml_clockconfig.c index 364933501d5a5269d1349111dabdc56352a1e9c2..f32166ee49b0b2e0b5d06afb8c21d415253aa602 100644 --- a/arch/arm/src/samdl/saml_clockconfig.c +++ b/arch/arm/src/samdl/saml_clockconfig.c @@ -74,6 +74,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* BOARD_GCLK_ENABLE looks optional, but it is not */ #ifndef BOARD_GCLK_ENABLE @@ -140,6 +141,7 @@ static inline void sam_periph_clocks(void); /**************************************************************************** * Private Data ****************************************************************************/ + /* This structure describes the configuration of every enabled GCLK */ #ifdef BOARD_GCLK_ENABLE diff --git a/arch/arm/src/samv7/Make.defs b/arch/arm/src/samv7/Make.defs index fe5ab20b2c6d69e2dbe483b61d9c7908766b7540..f7d4f3fb6b051d83e95a4df4fc2d34a9b40ac46f 100644 --- a/arch/arm/src/samv7/Make.defs +++ b/arch/arm/src/samv7/Make.defs @@ -44,7 +44,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_idle.c up_initialize.c CMN_CSRCS += up_initialstate.c up_interruptcontext.c up_memfault.c up_modifyreg8.c diff --git a/arch/arm/src/samv7/sam_config.h b/arch/arm/src/samv7/sam_config.h index 05e6db84f1182e710e090c3ab61c54543fe350da..f9e37ac3f377eaf01a97295330bc443fed69d393 100644 --- a/arch/arm/src/samv7/sam_config.h +++ b/arch/arm/src/samv7/sam_config.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/samv7/sam-config.h * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -144,7 +144,11 @@ # undef CONFIG_SAMV7_USART2 #endif -/* Are any USARTs enabled? */ +/* Are any USARTs enabled? + * + * REVISIT: Setting HAVE_UART_DEVICE only makes sense of the USART is being + * used as a UART. + */ #if defined(CONFIG_SAMV7_USART0) || defined(CONFIG_SAMV7_USART1) || \ defined(CONFIG_SAMV7_USART2) diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 3496331898c0bc293b6209cbba1edee8c5d05684..94c5956b2bd199a5be8822c012f0e5f27468fddb 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -2,7 +2,7 @@ * arch/arm/src/samv7/sam_emac.c * 10/100 Base-T Ethernet driver for the SAMV71. * - * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic derives from the SAMA5 Ethernet driver which, in turn, derived @@ -622,7 +622,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -3196,86 +3196,90 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { + { +#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_ARCH_PHY_INTERRUPT case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) - { - /* Enable PHY link up/down interrupts */ + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ - ret = sam_phyintenable(priv); + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - /* Read from the requested register */ + /* Read from the requested register */ - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; - /* Enable management port */ + /* Enable management port */ - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - /* Write to the requested register */ + /* Write to the requested register */ - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - /* Disable management port (probably) */ + /* Disable management port (probably) */ - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -5017,9 +5021,9 @@ int sam_emac_initialize(int intf) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) priv->phytype = phytype; /* Type of PHY on port */ #endif #endif diff --git a/arch/arm/src/samv7/sam_hsmci.c b/arch/arm/src/samv7/sam_hsmci.c index b6df58bc1818ca18168cfb99a6d95d3d1926c38e..213be4f878649dd8b6be4002eddfe1d5282aeea8 100644 --- a/arch/arm/src/samv7/sam_hsmci.c +++ b/arch/arm/src/samv7/sam_hsmci.c @@ -2791,7 +2791,7 @@ static sdio_eventset_t sam_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)sam_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -3234,7 +3234,7 @@ static void sam_callback(void *arg) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -3385,7 +3385,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -3438,7 +3438,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is write protected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_hsmci.h b/arch/arm/src/samv7/sam_hsmci.h index fa5992082dacfc7bc58f3334ec5d05371440a315..990ce462d5f6cf968d092fbc2f9b2d25103d13eb 100644 --- a/arch/arm/src/samv7/sam_hsmci.h +++ b/arch/arm/src/samv7/sam_hsmci.h @@ -85,7 +85,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -116,7 +116,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * bootloader that brought us into SDRAM and it is that bootloader that * has configured the clocking. * - * Input parameters: + * Input Parameters: * target - The target SD frequency * * Returned Value: @@ -141,7 +141,7 @@ uint32_t sam_hsmci_clkdiv(uint32_t target); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -159,7 +159,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_hsmci_clkdiv.c b/arch/arm/src/samv7/sam_hsmci_clkdiv.c index 83b85b6cb691eb54288cac59909168177000356b..0da38726216a29be83e057670f927bdff92d004f 100644 --- a/arch/arm/src/samv7/sam_hsmci_clkdiv.c +++ b/arch/arm/src/samv7/sam_hsmci_clkdiv.c @@ -96,7 +96,7 @@ * bootloader that brought us into SDRAM and it is that bootloader that * has configured the clocking. * - * Input parameters: + * Input Parameters: * target - The target SD frequency * * Returned Value: diff --git a/arch/arm/src/samv7/sam_lowputc.c b/arch/arm/src/samv7/sam_lowputc.c index c9d4b6e9ce5d541a3b273f85d8475437dbfe5dd6..614a9defd9ca6ec9d3cea56985b8f6eed2d6ffa5 100644 --- a/arch/arm/src/samv7/sam_lowputc.c +++ b/arch/arm/src/samv7/sam_lowputc.c @@ -172,26 +172,6 @@ #endif /* HAVE_SERIAL_CONSOLE */ -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -277,6 +257,9 @@ void sam_lowsetup(void) uint64_t divb3; uint32_t intpart; uint32_t fracpart; +#endif +#if (defined(HAVE_SERIAL_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)) || \ + defined(CONFIG_SAMV7_USART1) uint32_t regval; #endif diff --git a/arch/arm/src/samv7/sam_mcan.c b/arch/arm/src/samv7/sam_mcan.c index e72d089dc73b5bad66367532dda5a48769575ffd..5be48501d1b8d015ad744d0b1c2e8327725cff9c 100644 --- a/arch/arm/src/samv7/sam_mcan.c +++ b/arch/arm/src/samv7/sam_mcan.c @@ -1609,7 +1609,7 @@ static void mcan_buffer_release(FAR struct sam_mcan_s *priv) * standard CAN. In CAN FD mode, the values 9 to 15 are encoded to values * in the range 12 to 64. * - * Input Parameter: + * Input Parameters: * dlc - the DLC value to convert to a byte count * * Returned Value: @@ -1665,7 +1665,7 @@ static uint8_t mcan_dlc2bytes(FAR struct sam_mcan_s *priv, uint8_t dlc) * standard CAN. In CAN FD mode, the values 9 to 15 are encoded to values * in the range 12 to 64. * - * Input Parameter: + * Input Parameters: * nbytes - the byte count to convert to a DLC value * * Returned Value: @@ -3649,7 +3649,7 @@ static int mcan_interrupt(int irq, void *context, FAR void *arg) * Description: * MCAN hardware initialization * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this MCAN peripheral * * Returned Value: @@ -3924,7 +3924,7 @@ static int mcan_hw_initialize(struct sam_mcan_s *priv) * Description: * Initialize the selected MCAN port * - * Input Parameter: + * Input Parameters: * port - Port number (for hardware that has multiple MCAN interfaces), * 0=MCAN0, 1=MCAN1 * diff --git a/arch/arm/src/samv7/sam_mcan.h b/arch/arm/src/samv7/sam_mcan.h index 3672547788ac9fdfc7b7a757f38eb46f253d30eb..0c5dc6c7260093c1c99c5f26580407061f727907 100644 --- a/arch/arm/src/samv7/sam_mcan.h +++ b/arch/arm/src/samv7/sam_mcan.h @@ -88,7 +88,7 @@ extern "C" * Description: * Initialize the selected MCAN port * - * Input Parameter: + * Input Parameters: * port - Port number (for hardware that has multiple CAN interfaces), * 0=MCAN0, 1=NCAN1 * diff --git a/arch/arm/src/samv7/sam_qspi.c b/arch/arm/src/samv7/sam_qspi.c index e2ff6dea79485ba253ed420c81f24a104d7a0040..6e39c7f8e3ead114f98712705383e9a67aec2832 100644 --- a/arch/arm/src/samv7/sam_qspi.c +++ b/arch/arm/src/samv7/sam_qspi.c @@ -885,7 +885,7 @@ static int qspi_memory_dma(struct sam_qspidev_s *priv, ret = wd_start(priv->dmadog, DMA_TIMEOUT_TICKS, (wdentry_t)qspi_dma_timeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { spierr("ERROR: wd_start failed: %d\n", ret); } @@ -1714,7 +1714,7 @@ static int qspi_hw_initialize(struct sam_qspidev_s *priv) * Description: * Initialize the selected QSPI port in master mode * - * Input Parameter: + * Input Parameters: * intf - Interface number(must be zero) * * Returned Value: @@ -1737,7 +1737,7 @@ struct qspi_dev_s *sam_qspi_initialize(int intf) #ifdef CONFIG_SAMV7_QSPI if (intf == 0) { - /* If this function is called multiple times, the following operatinos + /* If this function is called multiple times, the following operations * will be performed multiple times. */ diff --git a/arch/arm/src/samv7/sam_qspi.h b/arch/arm/src/samv7/sam_qspi.h index 85d2e57d6594a7a4984d1b14b3337b2e11e659b3..9b64f0531cb454e41e1363188b49b03c365e58e0 100644 --- a/arch/arm/src/samv7/sam_qspi.h +++ b/arch/arm/src/samv7/sam_qspi.h @@ -87,7 +87,7 @@ extern "C" * Description: * Initialize the selected QSPI port in master mode * - * Input Parameter: + * Input Parameters: * intf - Interface number(must be zero) * * Returned Value: diff --git a/arch/arm/src/samv7/sam_rswdt.c b/arch/arm/src/samv7/sam_rswdt.c index 6d5add03a23ac158e16eb569deb6ed4c4e1b885b..5651e612ee4eabc69c4ba399fec537478ab991ba 100644 --- a/arch/arm/src/samv7/sam_rswdt.c +++ b/arch/arm/src/samv7/sam_rswdt.c @@ -254,7 +254,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -290,7 +290,7 @@ static int sam_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -320,7 +320,7 @@ static int sam_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -350,7 +350,7 @@ static int sam_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -378,7 +378,7 @@ static int sam_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * stawtus - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -435,7 +435,7 @@ static int sam_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in millisecnds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -554,7 +554,7 @@ static int sam_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -619,7 +619,7 @@ static xcpt_t sam_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -649,7 +649,7 @@ static int sam_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * Input Parameters: * None * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_spi.c b/arch/arm/src/samv7/sam_spi.c index e45fac7d000cdce30a345b71313e11b715dffcfb..0f4a52c90434484d9d1492fe8fb376c56d0f4e63 100644 --- a/arch/arm/src/samv7/sam_spi.c +++ b/arch/arm/src/samv7/sam_spi.c @@ -1864,7 +1864,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, ret = wd_start(spics->dmadog, DMA_TIMEOUT_TICKS, (wdentry_t)spi_dmatimeout, 1, (uint32_t)spics); - if (ret != OK) + if (ret < 0) { spierr("ERROR: wd_start failed: %d\n", ret); } @@ -1985,7 +1985,7 @@ static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords) * Description: * Initialize the selected SPI port in master mode * - * Input Parameter: + * Input Parameters: * cs - Chip select number (identifying the "logical" SPI port) * * Returned Value: diff --git a/arch/arm/src/samv7/sam_spi.h b/arch/arm/src/samv7/sam_spi.h index 6e5a76e9ef6276dee67e52080a161f03a72a5e13..e7e715fd38a04b6d902a95de141a4766d845f854 100644 --- a/arch/arm/src/samv7/sam_spi.h +++ b/arch/arm/src/samv7/sam_spi.h @@ -166,7 +166,7 @@ struct spi_sctrlr_s; /* Forward reference */ * Description: * Initialize the selected SPI port in master mode * - * Input Parameter: + * Input Parameters: * cs - Chip select number (identifying the "logical" SPI port) * * Returned Value: @@ -182,7 +182,7 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port); * Description: * Initialize the selected SPI port in slave mode. * - * Input Parameter: + * Input Parameters: * port - Chip select number identifying the "logical" SPI port. Includes * encoded port and chip select information. * @@ -248,7 +248,7 @@ FAR struct spi_sctrlr_s *sam_spi_slave_initialize(int port); * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -270,7 +270,7 @@ void sam_spi1select(uint32_t devid, bool selected); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -301,7 +301,7 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid); * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_spi_slave.c b/arch/arm/src/samv7/sam_spi_slave.c index 19473aa05c553be46c34fbf85506ef5e4dfa0bea..77a2cf67326b67533e458f1230d023a28ea7940c 100644 --- a/arch/arm/src/samv7/sam_spi_slave.c +++ b/arch/arm/src/samv7/sam_spi_slave.c @@ -1059,7 +1059,7 @@ static void spi_qflush(struct spi_sctrlr_s *sctrlr) * Description: * Initialize the selected SPI port in slave mode. * - * Input Parameter: + * Input Parameters: * port - Chip select number identifying the "logical" SPI port. Includes * encoded port and chip select information. * diff --git a/arch/arm/src/samv7/sam_ssc.c b/arch/arm/src/samv7/sam_ssc.c index bb1114c44493d94a9811017ff85659cb4930715b..8d56ff8f383b69d7df6d1f849d795bf9221679c0 100644 --- a/arch/arm/src/samv7/sam_ssc.c +++ b/arch/arm/src/samv7/sam_ssc.c @@ -2765,7 +2765,7 @@ static int ssc_tx_configure(struct sam_ssc_s *priv) * Setup the MCK/2 divider based on the currently selected data width and * the sample rate * - * Input Parameter: + * Input Parameters: * priv - I2C device structure (only the sample rate and data length is * needed at this point). * @@ -2822,7 +2822,7 @@ static uint32_t ssc_mck2divider(struct sam_ssc_s *priv) * Description: * Enable and configure clocking to the SSC * - * Input Parameter: + * Input Parameters: * priv - Partially initialized I2C device structure (only the PID is * needed at this point). * @@ -3370,7 +3370,7 @@ static void ssc1_configure(struct sam_ssc_s *priv) * Description: * Initialize the selected SSC port * - * Input Parameter: + * Input Parameters: * port - I2S "port" number (identifying the "logical" SSC port) * * Returned Value: diff --git a/arch/arm/src/samv7/sam_ssc.h b/arch/arm/src/samv7/sam_ssc.h index 567b655c3629a7bf11d8675f67abc83157d5f7af..0db57fe3615de9a14d1b7c0a902eb931f5a03d3f 100644 --- a/arch/arm/src/samv7/sam_ssc.h +++ b/arch/arm/src/samv7/sam_ssc.h @@ -82,7 +82,7 @@ extern "C" * Description: * Initialize the selected I2S port. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2S interfaces) * * Returned Value: diff --git a/arch/arm/src/samv7/sam_twihs.c b/arch/arm/src/samv7/sam_twihs.c index 261357c618df9f641c81d2ad56a77101f21bf8d9..6c2d36b291ed16fa663ee230cc52930aa5365e97 100644 --- a/arch/arm/src/samv7/sam_twihs.c +++ b/arch/arm/src/samv7/sam_twihs.c @@ -491,7 +491,8 @@ static int twi_wait(struct twi_dev_s *priv, unsigned int size) * TWIHS transfer stalls. */ - wd_start(priv->timeout, (timeout * size), twi_timeout, 1, (uint32_t)priv); + (void)wd_start(priv->timeout, (timeout * size), twi_timeout, 1, + (uint32_t)priv); /* Wait for either the TWIHS transfer or the timeout to complete */ diff --git a/arch/arm/src/samv7/sam_twihs.h b/arch/arm/src/samv7/sam_twihs.h index 79f85a70e3894e6ddfc9afe708b496d90905b493..abcaba9b7d27b22b1d36dded9ba2b4cec399d299 100644 --- a/arch/arm/src/samv7/sam_twihs.h +++ b/arch/arm/src/samv7/sam_twihs.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *sam_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the sam_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/samv7/sam_usbdevhs.c b/arch/arm/src/samv7/sam_usbdevhs.c index d27dafd5cc8b733103a5945a61a85486b281b7fd..5959cde64a0e81aae14b85e5d66dc95f440128ad 100644 --- a/arch/arm/src/samv7/sam_usbdevhs.c +++ b/arch/arm/src/samv7/sam_usbdevhs.c @@ -3319,7 +3319,7 @@ static void sam_resume(struct sam_usbdev_s *priv) /**************************************************************************** * Name: sam_ep_reset * - * Description + * Description: * Reset and disable a set of endpoints. * ****************************************************************************/ @@ -3377,7 +3377,7 @@ static void sam_ep_reset(struct sam_usbdev_s *priv, uint8_t epno) /**************************************************************************** * Name: sam_epset_reset * - * Description + * Description: * Reset and disable a set of endpoints. * ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_wdt.c b/arch/arm/src/samv7/sam_wdt.c index 4ce21303c33122abc65501edd8292d4ef1a9a528..b6990b9370a07037780cf18323aafbc5a3c13e74 100644 --- a/arch/arm/src/samv7/sam_wdt.c +++ b/arch/arm/src/samv7/sam_wdt.c @@ -254,7 +254,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -290,7 +290,7 @@ static int sam_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -320,7 +320,7 @@ static int sam_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -350,7 +350,7 @@ static int sam_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -378,7 +378,7 @@ static int sam_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * stawtus - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -435,7 +435,7 @@ static int sam_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in millisecnds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -567,7 +567,7 @@ static int sam_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -632,7 +632,7 @@ static xcpt_t sam_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -662,7 +662,7 @@ static int sam_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * Input Parameters: * None * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_wdt.h b/arch/arm/src/samv7/sam_wdt.h index f5ee97a2479e8e84457628b88864daf89818e148..3fe31686caf299ad106c0977b589a7411432b184 100644 --- a/arch/arm/src/samv7/sam_wdt.h +++ b/arch/arm/src/samv7/sam_wdt.h @@ -76,7 +76,7 @@ extern "C" * * At a minimum, this function should call watchdog_register(). * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -96,7 +96,7 @@ int sam_wdt_initialize(void); * * At a minimum, this function should call watchdog_register(). * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 141058ece8bb899c44beae7984d1467fa9ee821d..02441b567d012c564d3a01c42d46b6944d0315ec 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -2195,7 +2195,7 @@ config STM32_COMP6 config STM32_COMP7 bool "COMP7" default n - depends on STM32_HAVE_COMP6 + depends on STM32_HAVE_COMP7 config STM32_BKP bool "BKP" @@ -5864,6 +5864,11 @@ config STM32_HRTIM_DEADTIME depends on STM32_HRTIM_PWM default n +config STM32_HRTIM_PUSHPULL + bool "HRTIM push-pull mode" + depends on STM32_HRTIM_PWM + default n + config STM32_HRTIM_DMA bool "HRTIM DMA" default n @@ -6041,6 +6046,11 @@ config STM32_HRTIM_TIMA_DT default n depends on (STM32_HRTIM_DEADTIME && STM32_HRTIM_TIMA_PWM) +config STM32_HRTIM_TIMA_PSHPLL + bool "HRTIM TIMA PWM Push-pull mode" + default n + depends on (STM32_HRTIM_PUSHPULL && STM32_HRTIM_TIMA_PWM) + endmenu # "HRTIM Timer A Configuration" menu "HRTIM Timer B Configuration" @@ -6106,6 +6116,11 @@ config STM32_HRTIM_TIMB_DT default n depends on (STM32_HRTIM_DEADTIME && STM32_HRTIM_TIMB_PWM) +config STM32_HRTIM_TIMB_PSHPLL + bool "HRTIM TIMB PWM Push-pull mode" + default n + depends on (STM32_HRTIM_PUSHPULL && STM32_HRTIM_TIMB_PWM) + endmenu # "HRTIM Timer B Configuration" menu "HRTIM Timer C Configuration" @@ -6171,6 +6186,11 @@ config STM32_HRTIM_TIMC_DT default n depends on (STM32_HRTIM_DEADTIME && STM32_HRTIM_TIMC_PWM) +config STM32_HRTIM_TIMC_PSHPLL + bool "HRTIM TIMC PWM Push-pull mode" + default n + depends on (STM32_HRTIM_PUSHPULL && STM32_HRTIM_TIMC_PWM) + endmenu # "HRTIM Timer C Configuration" menu "HRTIM Timer D Configuration" @@ -6236,6 +6256,11 @@ config STM32_HRTIM_TIMD_DT default n depends on (STM32_HRTIM_DEADTIME && STM32_HRTIM_TIMD_PWM) +config STM32_HRTIM_TIMD_PSHPLL + bool "HRTIM TIMD PWM Push-pull mode" + default n + depends on (STM32_HRTIM_PUSHPULL && STM32_HRTIM_TIMD_PWM) + endmenu # "HRTIM Timer D Configuration" menu "HRTIM Timer E Configuration" @@ -6301,6 +6326,11 @@ config STM32_HRTIM_TIME_DT default n depends on (STM32_HRTIM_DEADTIME && STM32_HRTIM_TIME_PWM) +config STM32_HRTIM_TIME_PSHPLL + bool "HRTIM TIME PWM Push-pull mode" + default n + depends on (STM32_HRTIM_PUSHPULL && STM32_HRTIM_TIME_PWM) + endmenu # "HRTIM Timer E Configuration" endif # STM32_HRTIM1 diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs index e4402d0bfb1a8f061fc3e099b15db42e090915c9..898a6986b18ca2f4d7d16bf8b45285f4f46ef0f1 100644 --- a/arch/arm/src/stm32/Make.defs +++ b/arch/arm/src/stm32/Make.defs @@ -43,7 +43,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c CMN_CSRCS += up_createstack.c up_mdelay.c up_udelay.c up_exit.c diff --git a/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h index 9c64929a0b06c2114bfd14b3e4367f2c71fd8d36..b1b4f41c34be06deeb3040f2b4c6afa0a8a3ac58 100644 --- a/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f20xxx_memorymap.h @@ -129,7 +129,6 @@ #define STM32_TIM13_BASE 0x40001c00 /* 0x40001c00-0x40001fff: TIM13 timer */ #define STM32_TIM14_BASE 0x40002000 /* 0x40002000-0x400023ff: TIM14 timer */ #define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP registers */ -#define STM32_BKP_BASE 0x40002850 #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff: Window watchdog (WWDG) */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff: Independent watchdog (IWDG) */ #define STM32_I2S2EXT_BASE 0x40003400 /* 0x40003400-0x400037ff: I2S2ext */ diff --git a/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h index a7cbc46117d9e8ee258a8cd0b9cdb30dd1defd0e..30308dd93bdc7a0323ecd065d98ed3068c373661 100644 --- a/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f30xxx_memorymap.h @@ -92,8 +92,7 @@ #define STM32_TIM4_BASE 0x40000800 /* 0x40000800-0x40000bff TIM4 */ #define STM32_TIM6_BASE 0x40001000 /* 0x40001000-0x400013ff TIM6 */ #define STM32_TIM7_BASE 0x40001400 /* 0x40001400-0x400017ff TIM7 */ -#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC */ -#define STM32_BKP_BASE 0x40002850 /* 0x40002850-0x4000288c BKP */ +#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC and BKP */ #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff WWDG */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff IWDG */ #define STM32_I2S2EXT_BASE 0x40003400 /* 0x40003400-0x400037ff I2S2ext */ diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h b/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h index 0e962104f9171d22e54f37571c8fdb04314cf4b6..0e8a707e8bc1b777d9c65bd82306e62deab76e25 100644 --- a/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h +++ b/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h @@ -447,8 +447,8 @@ # define HRTIM_TIMDT_DTPRSC_110 (6 << HRTIM_TIMDT_DTPRSC_SHIFT) # define HRTIM_TIMDT_DTPRSC_111 (7 << HRTIM_TIMDT_DTPRSC_SHIFT) #define HRTIM_TIMDT_DTRSLK (1 << 14) /* Bit 14: Deadtime Rising Sign Lock */ -#define HRTIM_TIMDT_DTRLK (1 << 14) /* Bit 15: Deadtime Rising Lock */ -#define HRTIM_TIMDT_DTF_SHIFT 0 /* Bits 16-24: Deadtime Falling Value */ +#define HRTIM_TIMDT_DTRLK (1 << 15) /* Bit 15: Deadtime Rising Lock */ +#define HRTIM_TIMDT_DTF_SHIFT 16 /* Bits 16-24: Deadtime Falling Value */ #define HRTIM_TIMDT_DTF_MASK (0x1ff << HRTIM_TIMDT_DTF_SHIFT) #define HRTIM_TIMDT_SDTF (1 << 25) /* Bit 25: Sign Deadtime Falling Value */ #define HRTIM_TIMDT_DTFSLK (1 << 30) /* Bit 30: Deadtime Falling Sign Lock */ @@ -818,7 +818,7 @@ #define HRTIM_TIMARST_TIMCCMP4 (1 << 24) /* Bit 24 */ #define HRTIM_TIMARST_TIMDCMP1 (1 << 25) /* Bit 25 */ #define HRTIM_TIMARST_TIMDCMP2 (1 << 26) /* Bit 26 */ -#define HRTIM_TIMARST_TIMDCMP3 (1 << 27) /* Bit 27 */ +#define HRTIM_TIMARST_TIMDCMP4 (1 << 27) /* Bit 27 */ #define HRTIM_TIMARST_TIMECMP1 (1 << 28) /* Bit 28 */ #define HRTIM_TIMARST_TIMECMP2 (1 << 29) /* Bit 29 */ #define HRTIM_TIMARST_TIMECMP4 (1 << 30) /* Bit 30 */ @@ -849,7 +849,7 @@ #define HRTIM_TIMBRST_TIMCCMP4 (1 << 24) /* Bit 24 */ #define HRTIM_TIMBRST_TIMDCMP1 (1 << 25) /* Bit 25 */ #define HRTIM_TIMBRST_TIMDCMP2 (1 << 26) /* Bit 26 */ -#define HRTIM_TIMBRST_TIMDCMP3 (1 << 27) /* Bit 27 */ +#define HRTIM_TIMBRST_TIMDCMP4 (1 << 27) /* Bit 27 */ #define HRTIM_TIMBRST_TIMECMP1 (1 << 28) /* Bit 28 */ #define HRTIM_TIMBRST_TIMECMP2 (1 << 29) /* Bit 29 */ #define HRTIM_TIMBRST_TIMECMP4 (1 << 30) /* Bit 30 */ @@ -880,7 +880,7 @@ #define HRTIM_TIMCRST_TIMBCMP4 (1 << 24) /* Bit 24 */ #define HRTIM_TIMCRST_TIMDCMP1 (1 << 25) /* Bit 25 */ #define HRTIM_TIMCRST_TIMDCMP2 (1 << 26) /* Bit 26 */ -#define HRTIM_TIMCRST_TIMDCMP3 (1 << 27) /* Bit 27 */ +#define HRTIM_TIMCRST_TIMDCMP4 (1 << 27) /* Bit 27 */ #define HRTIM_TIMCRST_TIMECMP1 (1 << 28) /* Bit 28 */ #define HRTIM_TIMCRST_TIMECMP2 (1 << 29) /* Bit 29 */ #define HRTIM_TIMCRST_TIMECMP4 (1 << 30) /* Bit 30 */ @@ -911,7 +911,7 @@ #define HRTIM_TIMDRST_TIMBCMP4 (1 << 24) /* Bit 24 */ #define HRTIM_TIMDRST_TIMCCMP1 (1 << 25) /* Bit 25 */ #define HRTIM_TIMDRST_TIMCCMP2 (1 << 26) /* Bit 26 */ -#define HRTIM_TIMDRST_TIMCCMP3 (1 << 27) /* Bit 27 */ +#define HRTIM_TIMDRST_TIMCCMP4 (1 << 27) /* Bit 27 */ #define HRTIM_TIMDRST_TIMECMP1 (1 << 28) /* Bit 28 */ #define HRTIM_TIMDRST_TIMECMP2 (1 << 29) /* Bit 29 */ #define HRTIM_TIMDRST_TIMECMP4 (1 << 30) /* Bit 30 */ @@ -942,7 +942,7 @@ #define HRTIM_TIMERST_TIMBCMP4 (1 << 24) /* Bit 24 */ #define HRTIM_TIMERST_TIMCCMP1 (1 << 25) /* Bit 25 */ #define HRTIM_TIMERST_TIMCCMP2 (1 << 26) /* Bit 26 */ -#define HRTIM_TIMERST_TIMCCMP3 (1 << 27) /* Bit 27 */ +#define HRTIM_TIMERST_TIMCCMP4 (1 << 27) /* Bit 27 */ #define HRTIM_TIMERST_TIMDCMP1 (1 << 28) /* Bit 28 */ #define HRTIM_TIMERST_TIMDCMP2 (1 << 29) /* Bit 29 */ #define HRTIM_TIMERST_TIMDCMP4 (1 << 30) /* Bit 30 */ diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h index 85e5ce175d615d44e0c5eabc06269bf225e962ae..90af97f03681065dd450352dbd7580174f14f860 100644 --- a/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h @@ -93,8 +93,7 @@ #define STM32_TIM3_BASE 0x40000400 /* 0x40000400-0x400007ff TIM3 */ #define STM32_TIM6_BASE 0x40001000 /* 0x40001000-0x400013ff TIM6 */ #define STM32_TIM7_BASE 0x40001400 /* 0x40001400-0x400017ff TIM7 */ -#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC */ -#define STM32_BKP_BASE 0x40002850 /* 0x40002850-0x400028cc BKP */ +#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC and BKP */ #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff WWDG */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff IWDG */ #define STM32_USART2_BASE 0x40004400 /* 0x40004400-0x400047ff USART2 */ diff --git a/arch/arm/src/stm32/chip/stm32f37xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f37xxx_memorymap.h index 49bfa2ecf2ea9f9d9ecfcaa09ebc36721b343fdf..2089ad0be898a8564b763e909fca3fddec75ef29 100644 --- a/arch/arm/src/stm32/chip/stm32f37xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f37xxx_memorymap.h @@ -93,8 +93,7 @@ #define STM32_TIM12_BASE 0x40001800 /* 0x40001800-0x40001bff TIM12 */ #define STM32_TIM13_BASE 0x40001c00 /* 0x40001c00-0x40001fff TIM13 */ #define STM32_TIM14_BASE 0x40002000 /* 0x40002000-0x400023ff TIM14 */ -#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC */ -#define STM32_BKP_BASE 0x40002850 /* 0x40002850-0x400028cc BKP */ +#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC and BKP */ #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff WWDG */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff IWDG */ #define STM32_SPI2_BASE 0x40003800 /* 0x40003800-0x40003bff SPI2, or */ diff --git a/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h index 8b493e916ca806a938348a84fc0f65a650dd1b01..8bd7d5e16afeb87f4c876c9b112212a0bd43e396 100644 --- a/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32f40xxx_memorymap.h @@ -129,7 +129,6 @@ #define STM32_TIM13_BASE 0x40001c00 /* 0x40001c00-0x40001fff: TIM13 timer */ #define STM32_TIM14_BASE 0x40002000 /* 0x40002000-0x400023ff: TIM14 timer */ #define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP registers */ -#define STM32_BKP_BASE 0x40002850 #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff: Window watchdog (WWDG) */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff: Independent watchdog (IWDG) */ #define STM32_I2S2EXT_BASE 0x40003400 /* 0x40003400-0x400037ff: I2S2ext */ diff --git a/arch/arm/src/stm32/stm32.h b/arch/arm/src/stm32/stm32.h index 56225ee211d4932f59e09604b3ebc1a8ac233972..fe61cd4811d2ff8867124538798791788818e0be 100644 --- a/arch/arm/src/stm32/stm32.h +++ b/arch/arm/src/stm32/stm32.h @@ -57,7 +57,6 @@ #include "chip.h" #include "stm32_adc.h" -//#include "stm32_bkp.h" #include "stm32_can.h" #include "stm32_comp.h" #include "stm32_dbgmcu.h" diff --git a/arch/arm/src/stm32/stm32_1wire.c b/arch/arm/src/stm32/stm32_1wire.c index a4157006a62f18976383b8cccd354769c78e1dae..93ab8000eed79ebede7e6b1f0e529a2379844bb8 100644 --- a/arch/arm/src/stm32/stm32_1wire.c +++ b/arch/arm/src/stm32/stm32_1wire.c @@ -500,7 +500,7 @@ static void stm32_1wire_set_baud(struct stm32_1wire_priv_s *priv) * Description: * Enable or disable APB clock for the USART peripheral * - * Input parameters: + * Input Parameters: * priv - A reference to the 1-Wire driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -1149,7 +1149,7 @@ static int stm32_1wire_exchange(FAR struct onewire_dev_s *dev, bool reset, * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple 1-Wire interfaces) * * Returned Value: @@ -1245,7 +1245,7 @@ FAR struct onewire_dev_s *stm32_1wireinitialize(int port) * Description: * De-initialize the selected 1-Wire port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the stm32_1wireinitialize() * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_1wire.h b/arch/arm/src/stm32/stm32_1wire.h index 24cfe45592f604a2d85d4595e6ac738c49e77399..7606c8f4610bd598b456ce2ce3dee2b2948ae5eb 100644 --- a/arch/arm/src/stm32/stm32_1wire.h +++ b/arch/arm/src/stm32/stm32_1wire.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple 1-Wire interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct onewire_dev_s *stm32_1wireinitialize(int port); * Description: * De-initialize the selected 1-Wire port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the stm32_1wireinitialize() * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c index 7ec37927bd5ee01c8e8f63fa4e91715f7d14771c..a1a3d5523c669afd1a629aad217a1c3a5e6af9ad 100644 --- a/arch/arm/src/stm32/stm32_adc.c +++ b/arch/arm/src/stm32/stm32_adc.c @@ -757,7 +757,7 @@ static void tim_modifyreg(FAR struct stm32_dev_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the ADC block status * * Returned Value: @@ -1366,7 +1366,8 @@ static void adc_rccreset(FAR struct stm32_dev_s *priv, bool reset) /**************************************************************************** * Name: adc_power_down_idle * - * Description : Enables or disables power down during the idle phase. + * Description: + * Enables or disables power down during the idle phase. * * Input Parameters: * @@ -1407,7 +1408,8 @@ static void adc_power_down_idle(FAR struct stm32_dev_s *priv, bool pdi_high) /**************************************************************************** * Name: adc_power_down_delay * - * Description : Enables or disables power down during the delay phase. + * Description: + * Enables or disables power down during the delay phase. * * Input Parameters: * @@ -1448,8 +1450,9 @@ static void adc_power_down_delay(FAR struct stm32_dev_s *priv, bool pdd_high) /**************************************************************************** * Name: adc_dels_after_conversion * - * Description : Defines the length of the delay which is applied - * after a conversion or a sequence of conversions. + * Description: + * Defines the length of the delay which is applied after a conversion or + * a sequence of conversions. * * Input Parameters: * @@ -1474,7 +1477,8 @@ static void adc_dels_after_conversion(FAR struct stm32_dev_s *priv, /**************************************************************************** * Name: adc_select_ch_bank * - * Description : Selects the bank of channels to be converted + * Description: + * Selects the bank of channels to be converted * (! Must be modified only when no conversion is on going !) * * Input Parameters: @@ -1507,9 +1511,9 @@ static void adc_select_ch_bank(FAR struct stm32_dev_s *priv, /**************************************************************************** * Name: adc_enable * - * Description : Enables or disables the specified ADC peripheral. - * Also, starts a conversion when the ADC is not - * triggered by timers + * Description: + * Enables or disables the specified ADC peripheral. Also, starts a + * conversion when the ADC is not triggered by timers * * Input Parameters: * diff --git a/arch/arm/src/stm32/stm32_bkp.h b/arch/arm/src/stm32/stm32_bkp.h index 21399c38bd291a99ca6e744ccef03f51d8f161d7..4478ffd63357836059777f89f22836ca3b5169a4 100644 --- a/arch/arm/src/stm32/stm32_bkp.h +++ b/arch/arm/src/stm32/stm32_bkp.h @@ -42,8 +42,18 @@ #include +/* Only the STM32 F1 family has a dedicated address region for BKP memory. For F2, + * F3, and F4 parts, the bKP registers lie in the same address region as the RTCC + * and the definitions in chip/stm32_rtcc.h should be used to access backup + * registers. NOTE: These definitions are not interchangeable! + */ + #include "chip.h" -#include "chip/stm32_bkp.h" +#ifdef CONFIG_STM32_STM32F10XX +# include "chip/stm32_bkp.h" +#else +# include "chip/stm32_rtcc.h" +#endif /************************************************************************************ * Pre-processor Definitions diff --git a/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c index a2fc3fac1dfaf2bfae0d013248a910c7fe7a6d0c..2625c9123c51caf8750ef873ddb35dd2174d009b 100644 --- a/arch/arm/src/stm32/stm32_can.c +++ b/arch/arm/src/stm32/stm32_can.c @@ -1644,7 +1644,7 @@ static int stm32can_txinterrupt(int irq, FAR void *context, FAR void *arg) * Where: * Tpclk1 is the period of the APB1 clock (PCLK1). * - * Input Parameter: + * Input Parameters: * priv - A reference to the CAN block status * * Returned Value: @@ -1743,7 +1743,7 @@ static int stm32can_bittiming(FAR struct stm32_can_s *priv) * peripheral, no registers are changed. The initialization mode is * required to change the baud rate. * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1794,7 +1794,7 @@ static int stm32can_enterinitmode(FAR struct stm32_can_s *priv) * Description: * Put the CAN cell out of the Initialization mode (to Normal mode) * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1844,7 +1844,7 @@ static int stm32can_exitinitmode(FAR struct stm32_can_s *priv) * Description: * CAN cell initialization * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1927,7 +1927,7 @@ static int stm32can_cellinit(FAR struct stm32_can_s *priv) * are set to zero thus supressing all filtering because anything masked * with zero matches zero. * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -2014,7 +2014,7 @@ static int stm32can_filterinit(FAR struct stm32_can_s *priv) * Description: * Add a filter for extended CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - A pointer to a structure describing the filter * @@ -2039,7 +2039,7 @@ static int stm32can_addextfilter(FAR struct stm32_can_s *priv, * Description: * Remove a filter for extended CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - The filter index previously returned by the * CANIOC_ADD_EXTFILTER command @@ -2064,7 +2064,7 @@ static int stm32can_delextfilter(FAR struct stm32_can_s *priv, int arg) * Description: * Add a filter for standard CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - A pointer to a structure describing the filter * @@ -2087,7 +2087,7 @@ static int stm32can_addstdfilter(FAR struct stm32_can_s *priv, * Description: * Remove a filter for standard CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - The filter index previously returned by the * CANIOC_ADD_STDFILTER command @@ -2107,7 +2107,7 @@ static int stm32can_delstdfilter(FAR struct stm32_can_s *priv, int arg) /**************************************************************************** * Name: stm32can_txmb0empty * - * Input Parameter: + * Input Parameters: * tsr_regval - value of CAN transmit status register * * Returned Value: @@ -2124,7 +2124,7 @@ static bool stm32can_txmb0empty(uint32_t tsr_regval) /**************************************************************************** * Name: stm32can_txmb1empty * - * Input Parameter: + * Input Parameters: * tsr_regval - value of CAN transmit status register * * Returned Value: @@ -2141,7 +2141,7 @@ static bool stm32can_txmb1empty(uint32_t tsr_regval) /**************************************************************************** * Name: stm32can_txmb2empty * - * Input Parameter: + * Input Parameters: * tsr_regval - value of CAN transmit status register * * Returned Value: @@ -2165,7 +2165,7 @@ static bool stm32can_txmb2empty(uint32_t tsr_regval) * Description: * Initialize the selected CAN port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple CAN interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_can.h b/arch/arm/src/stm32/stm32_can.h index f06231ab60a49fc50e24d8dbf233b0732838cfe0..078e6b2a124d9b70345086ac307f1b27640275ee 100644 --- a/arch/arm/src/stm32/stm32_can.h +++ b/arch/arm/src/stm32/stm32_can.h @@ -125,7 +125,7 @@ extern "C" * Description: * Initialize the selected CAN port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple CAN interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_comp.c b/arch/arm/src/stm32/stm32_comp.c index ada260042107bacddd60d4a92d805a474fe660e3..b46b678f94e5fd0149ff288414bde683fef180f7 100644 --- a/arch/arm/src/stm32/stm32_comp.c +++ b/arch/arm/src/stm32/stm32_comp.c @@ -1069,7 +1069,6 @@ FAR struct comp_dev_s* stm32_compinitialize(int intf) if (ret < 0) { aerr("ERROR: Failed to initialize COMP%d: %d\n", intf, ret); - errno = -ret; return NULL; } diff --git a/arch/arm/src/stm32/stm32_dma.h b/arch/arm/src/stm32/stm32_dma.h index 965fd6f30fe865c4532d268515ba8d127c8b1342..e9878d1157224d77741d1b9689c9686ab8a79a44 100644 --- a/arch/arm/src/stm32/stm32_dma.h +++ b/arch/arm/src/stm32/stm32_dma.h @@ -175,7 +175,7 @@ extern "C" * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * chan - Identifies the stream/channel resource * For the STM32 F1, this is simply the channel number as provided by * the DMACHAN_* definitions in chip/stm32f10xxx_dma.h. @@ -281,7 +281,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle); * only applies to memory addresses, it will return false for any peripheral * address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_dma2d.c b/arch/arm/src/stm32/stm32_dma2d.c index a70ed7508580006f1e1da0552113a2ecd198c790..c9e2a0e54c4275d1c73fcb12829ce3bbaaa5ec15 100644 --- a/arch/arm/src/stm32/stm32_dma2d.c +++ b/arch/arm/src/stm32/stm32_dma2d.c @@ -486,7 +486,7 @@ static int stm32_dma2dirq(int irq, void *context, FAR void *arg) * loading or dma transfer was completed. * Note! The caller must use this function within a critical section. * - * Return: + * Returned Value: * On success OK otherwise ERROR * ****************************************************************************/ @@ -532,7 +532,7 @@ static int stm32_dma2d_waitforirq(void) * Parameter: * pfcreg - PFC control Register * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -620,7 +620,7 @@ static int stm32_dma2d_start(void) * Parameter: * layer - Reference to the common layer state structure * - * Return: + * Returned Value: * memory address * ****************************************************************************/ @@ -646,7 +646,7 @@ static uint32_t stm32_dma2d_memaddress(FAR const struct stm32_dma2d_s *layer, * Parameter: * layer - Reference to the common layer state structure * - * Return: + * Returned Value: * line offset * ****************************************************************************/ @@ -670,7 +670,7 @@ static fb_coord_t stm32_dma2d_lineoffset(FAR const struct stm32_dma2d_s *layer, * layer - Reference to the common layer state structure * fmt - Reference to the location to store the pixel format * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -729,7 +729,7 @@ static int stm32_dma2d_pixelformat(uint8_t fmt, uint8_t *fmtmap) * layer - Reference to the common layer state structure * bpp - Reference to the location to store the pixel format * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -770,7 +770,7 @@ static int stm32_dma2d_bpp(uint8_t fmt, uint8_t *bpp) * Description: * Get a free layer id * - * Return: + * Returned Value: * The number of the free layer * -1 if no free layer is available * @@ -797,7 +797,7 @@ static int stm32_dma2d_lfreelid(void) * Description: * Allocate a new layer structure * - * Return: + * Returned Value: * A new allocated layer structure or NULL on error. * ****************************************************************************/ @@ -886,7 +886,7 @@ static void stm32_dma2d_llayerscleanup(void) * Description: * Helper to validate if the layer is valid * - * Return: + * Returned Value: * true if validates otherwise false * ****************************************************************************/ @@ -908,7 +908,7 @@ static inline bool stm32_dma2d_lvalidate(FAR const struct stm32_dma2d_s *layer) * ypos - The y position inside the whole layer * area - the area inside the whole layer * - * Return: + * Returned Value: * true if area is inside the whole layer otherwise false * ****************************************************************************/ @@ -1162,7 +1162,7 @@ static void stm32_dma2d_lpfc(FAR const struct stm32_dma2d_s *layer, * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1199,7 +1199,7 @@ static int stm32_dma2dgetvideoinfo(FAR struct dma2d_layer_s *layer, * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1235,7 +1235,7 @@ static int stm32_dma2dgetplaneinfo(FAR struct dma2d_layer_s *layer, int planeno, * layer - Reference to the layer structure * lid - Reference to store the layer id * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1271,7 +1271,7 @@ static int stm32_dma2dgetlid(FAR struct dma2d_layer_s *layer, int *lid) * layer - Reference to the layer structure * cmap - color lookup table with up the 256 entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1390,7 +1390,7 @@ static int stm32_dma2dsetclut(FAR struct dma2d_layer_s *layer, * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1482,7 +1482,7 @@ static int stm32_dma2dgetclut(FAR struct dma2d_layer_s *layer, * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1517,7 +1517,7 @@ static int stm32_dma2dsetalpha(FAR struct dma2d_layer_s *layer, uint8_t alpha) * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1554,7 +1554,7 @@ static int stm32_dma2dgetalpha(FAR struct dma2d_layer_s *layer, uint8_t *alpha) * layer - Reference to the layer structure * mode - Blend mode (see DMA2D_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1603,7 +1603,7 @@ static int stm32_dma2dsetblendmode(FAR struct dma2d_layer_s *layer, * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1643,7 +1643,7 @@ static int stm32_dma2dgetblendmode(FAR struct dma2d_layer_s *layer, * src - Valid reference to the source layer * srcarea - Valid reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -1752,7 +1752,7 @@ static int stm32_dma2dblit(FAR struct dma2d_layer_s *dest, * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -1859,7 +1859,7 @@ static int stm32_dma2dblend(FAR struct dma2d_layer_s *dest, * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * area outside the visible area of the layer. @@ -1935,7 +1935,7 @@ static int stm32_dma2dfillarea(FAR struct dma2d_layer_s *layer, * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the dma2d layer control structure on success or Null if no * related exist. * @@ -1968,7 +1968,7 @@ FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid) * height - Layer height * fmt - Pixel format of the layer * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL * @@ -2090,7 +2090,7 @@ FAR struct dma2d_layer_s *up_dma2dcreatelayer(fb_coord_t width, * Parameter: * layer - Reference to the layer to remove * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2132,7 +2132,7 @@ int up_dma2dremovelayer(FAR struct dma2d_layer_s *layer) * Description: * Initialize the dma2d controller * - * Return: + * Returned Value: * OK - On success * An error if initializing failed. * @@ -2248,7 +2248,7 @@ void up_dma2duninitialize(void) * layer - a valid reference to the low level ltdc layer structure * clut - a pointer to a valid memory region to hold 256 clut colors * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL * diff --git a/arch/arm/src/stm32/stm32_dma2d.h b/arch/arm/src/stm32/stm32_dma2d.h index a62d16f7af1416b9d294cf5c03f1b11b90f9d5fb..258ae695317d4cb17ae381154f015d2791cd35d4 100644 --- a/arch/arm/src/stm32/stm32_dma2d.h +++ b/arch/arm/src/stm32/stm32_dma2d.h @@ -74,7 +74,7 @@ struct dma2d_layer_s * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -92,7 +92,7 @@ struct dma2d_layer_s * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -109,7 +109,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * lid - Reference to store the layer id * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -127,7 +127,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * cmap - color lookup table with up the 256 entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -145,7 +145,7 @@ struct dma2d_layer_s * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -167,7 +167,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -183,7 +183,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -201,7 +201,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * mode - Blend mode (see DMA2D_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -230,7 +230,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -250,7 +250,7 @@ struct dma2d_layer_s * src - Reference to the source layer * srcarea - Reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the * selected source area outside the visible area of the @@ -281,7 +281,7 @@ struct dma2d_layer_s * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the * selected source area outside the visible area of the @@ -308,7 +308,7 @@ struct dma2d_layer_s * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the * selected area outside the visible area of the layer. @@ -340,7 +340,7 @@ struct stm32_ltdc_s; /* Forward declaration */ * Parameter: * layer - a valid reference to the low level ltdc layer structure * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL and errno is set to * -EINVAL if one of the parameter is invalid @@ -358,7 +358,7 @@ FAR struct dma2d_layer_s *stm32_dma2dinitltdc(FAR struct stm32_ltdc_s *layer); * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the dma2d layer control structure on success or Null if no * related exist. * @@ -377,7 +377,7 @@ FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid); * height - Layer height * fmt - Pixel format of the layer * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL and errno is set to * -EINVAL if one of the parameter is invalid @@ -399,7 +399,7 @@ FAR struct dma2d_layer_s *up_dma2dcreatelayer(fb_coord_t width, * Parameter: * layer - Reference to the layer to remove * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -413,7 +413,7 @@ int up_dma2dremovelayer(FAR struct dma2d_layer_s *layer); * Description: * Initialize the dma2d controller * - * Return: + * Returned Value: * OK - On success * An error if initializing failed. * diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 62e44a0ff234631ded40df95d3b2ed0940624019..0c2aac13116d4d5fcf7c4864b1db9ac9c2e56c84 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -721,7 +721,7 @@ static int stm32_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int stm32_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2847,62 +2847,64 @@ static void stm32_rxdescinit(FAR struct stm32_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)dev->d_private; #endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = stm32_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = stm32_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = CONFIG_STM32_PHYADDR; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = CONFIG_STM32_PHYADDR; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out); - } - break; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in); - } - break; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: stm32_phyintenable @@ -4014,12 +4016,12 @@ int stm32_ethinitialize(int intf) priv->dev.d_addmac = stm32_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = stm32_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = stm32_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_stm32ethmac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/stm32/stm32_exti.h b/arch/arm/src/stm32/stm32_exti.h index 8e46e239da27adb3cbc056442dd10553b612eda2..376d65f774aa2dae66c54c5255f7b346fcbbda18 100644 --- a/arch/arm/src/stm32/stm32_exti.h +++ b/arch/arm/src/stm32/stm32_exti.h @@ -123,7 +123,7 @@ int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func, * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * diff --git a/arch/arm/src/stm32/stm32_exti_alarm.c b/arch/arm/src/stm32/stm32_exti_alarm.c index 414817a6b84f1ec35767c4e8d0aee3b1d4fd532c..77de848e9f7502f2767caac0e89e6447d254143c 100644 --- a/arch/arm/src/stm32/stm32_exti_alarm.c +++ b/arch/arm/src/stm32/stm32_exti_alarm.c @@ -108,7 +108,7 @@ static int stm32_exti_alarm_isr(int irq, void *context, FAR void *arg) * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * diff --git a/arch/arm/src/stm32/stm32_exti_pwr.c b/arch/arm/src/stm32/stm32_exti_pwr.c index 5ab6138ac4bb345729b20edcb879a27804266816..36d2167283bed458a8d024ede3c8ab8f3592ebfc 100644 --- a/arch/arm/src/stm32/stm32_exti_pwr.c +++ b/arch/arm/src/stm32/stm32_exti_pwr.c @@ -114,7 +114,7 @@ static int stm32_exti_pvd_isr(int irq, void *context, FAR void *arg) * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32/stm32_exti_pwr.h b/arch/arm/src/stm32/stm32_exti_pwr.h index c4841dffebe9d14c3445458e03774644a3baef27..e48ca3f2eed0adaebe3f4bfea111ed23f798c196 100644 --- a/arch/arm/src/stm32/stm32_exti_pwr.h +++ b/arch/arm/src/stm32/stm32_exti_pwr.h @@ -59,7 +59,7 @@ * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32/stm32_exti_wakeup.c b/arch/arm/src/stm32/stm32_exti_wakeup.c index 9dd9ad7d99a4f2cdfe13c49bb263f7cdce0841bb..d265361f87195073bddd52e852c7a352a3d04b14 100644 --- a/arch/arm/src/stm32/stm32_exti_wakeup.c +++ b/arch/arm/src/stm32/stm32_exti_wakeup.c @@ -107,7 +107,7 @@ static int stm32_exti_wakeup_isr(int irq, void *context, FAR void *arg) * - event: generate event when set * - func: when non-NULL, generate interrupt * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * diff --git a/arch/arm/src/stm32/stm32_flash.h b/arch/arm/src/stm32/stm32_flash.h index 6da1b0b70343096d86ca20bcf1e400ccfdf32638..4d5003b056764106dab8763096a27b6fa5831f14 100644 --- a/arch/arm/src/stm32/stm32_flash.h +++ b/arch/arm/src/stm32/stm32_flash.h @@ -56,7 +56,7 @@ * Description: * Get EEPROM data memory size * - * Returns: + * Returned Value: * Length of EEPROM memory region * ************************************************************************************/ @@ -69,7 +69,7 @@ size_t stm32_eeprom_size(void); * Description: * Get EEPROM data memory address * - * Returns: + * Returned Value: * Address of EEPROM memory region * ************************************************************************************/ @@ -82,7 +82,7 @@ size_t stm32_eeprom_getaddress(void); * Description: * Write buffer to EEPROM data memory address * - * Returns: + * Returned Value: * Number of written bytes or error code. * ************************************************************************************/ @@ -95,7 +95,7 @@ ssize_t stm32_eeprom_write(size_t addr, const void *buf, size_t buflen); * Description: * Erase memory on EEPROM data memory address * - * Returns: + * Returned Value: * Number of erased bytes or error code. * ************************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_gpio.c b/arch/arm/src/stm32/stm32_gpio.c index 727f0c943a56ac9f6f794db9c62b0a85bc4e4e87..7a1d7800c4d109698a34af7b60f7d8a0cbe9d034 100644 --- a/arch/arm/src/stm32/stm32_gpio.c +++ b/arch/arm/src/stm32/stm32_gpio.c @@ -261,7 +261,7 @@ void stm32_gpioinit(void) * function, it must be unconfigured with stm32_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * A negated errono valu on invalid port, or when pin is locked as ALT * function. @@ -667,7 +667,7 @@ int stm32_configgpio(uint32_t cfgset) * operate in PWM mode could produce excessive on-board currents and trigger * over-current/alarm function. * - * Returns: + * Returned Value: * OK on success * A negated errno value on invalid port * diff --git a/arch/arm/src/stm32/stm32_hrtim.c b/arch/arm/src/stm32/stm32_hrtim.c index d064c8e1d3b4b4a43aece55a4f696c53e040bb85..3f40ca0e8e1038105b0a856bd5cad99336d3c530 100644 --- a/arch/arm/src/stm32/stm32_hrtim.c +++ b/arch/arm/src/stm32/stm32_hrtim.c @@ -117,9 +117,10 @@ # endif #endif #if defined(CONFIG_STM32_HRTIM_INTERRUPTS) -#if !defined(CONFIG_STM32_HRTIM_TIMA_IRQ) && !defined(CONFIG_STM32_HRTIM_TIMB_IRQ) && \ - !defined(CONFIG_STM32_HRTIM_TIMC_IRQ) && !defined(CONFIG_STM32_HRTIM_TIMD_IRQ) && \ - !defined(CONFIG_STM32_HRTIM_TIME_IRQ) +#if !defined(CONFIG_STM32_HRTIM_MASTER_IRQ) && !defined(CONFIG_STM32_HRTIM_TIMA_IRQ) && \ + !defined(CONFIG_STM32_HRTIM_TIMB_IRQ) && !defined(CONFIG_STM32_HRTIM_TIMC_IRQ) && \ + !defined(CONFIG_STM32_HRTIM_TIMD_IRQ) && !defined(CONFIG_STM32_HRTIM_TIME_IRQ) && \ + !defined(CONFIG_STM32_HRTIM_COMMON_IRQ) # warning "CONFIG_STM32_HRTIM_INTERRUPTS enabled but no timer selected" # endif #endif @@ -180,6 +181,29 @@ # error "CONFIG_STM32_HRTIM_CHOPPER must be set" # endif #endif +#if defined(CONFIG_STM32_HRTIM_TIMA_PSHPLL) || defined(CONFIG_STM32_HRTIM_TIMB_PSHPLL) || \ + defined(CONFIG_STM32_HRTIM_TIMC_PSHPLL) || defined(CONFIG_STM32_HRTIM_TIMD_PSHPLL) || \ + defined(CONFIG_STM32_HRTIM_TIME_PSHPLL) +# ifndef CONFIG_STM32_HRTIM_PUSHPULL +# error "CONFIG_STM32_HRTIM_PUSHPULL must be set" +# endif +#endif + +#if defined(CONFIG_STM32_HRTIM_TIMA_DT) && defined(CONFIG_STM32_HRTIM_TIMA_PSHPLL) +# error "The deadtime cannot be used simultaneously with the push-pull mode" +#endif +#if defined(CONFIG_STM32_HRTIM_TIMB_DT) && defined(CONFIG_STM32_HRTIM_TIMB_PSHPLL) +# error "The deadtime cannot be used simultaneously with the push-pull mode" +#endif +#if defined(CONFIG_STM32_HRTIM_TIMC_DT) && defined(CONFIG_STM32_HRTIM_TIMC_PSHPLL) +# error "The deadtime cannot be used simultaneously with the push-pull mode" +#endif +#if defined(CONFIG_STM32_HRTIM_TIMD_DT) && defined(CONFIG_STM32_HRTIM_TIMD_PSHPLL) +# error "The deadtime cannot be used simultaneously with the push-pull mode" +#endif +#if defined(CONFIG_STM32_HRTIM_TIME_DT) && defined(CONFIG_STM32_HRTIM_TIME_PSHPLL) +# error "The deadtime cannot be used simultaneously with the push-pull mode" +#endif #if defined(CONFIG_STM32_HRTIM_ADC1_TRG1) || defined(CONFIG_STM32_HRTIM_ADC1_TRG2) || \ defined(CONFIG_STM32_HRTIM_ADC1_TRG3) || defined(CONFIG_STM32_HRTIM_ADC1_TRG4) || \ @@ -201,17 +225,13 @@ # define HRTIM_HAVE_ADC_TRG4 #endif -#ifdef CONFIG_STM32_HRTIM_INTERRUPTS -# error HRTIM Interrupts not supported yet -#endif - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* HRTIM default configuration **********************************************/ -#ifndef HRTIM_TIMER_MASTER +#ifndef HRTIM_MASTER_PRESCALER # warning "HRTIM_MASTER_PRESCALER is not set. Set the default value HRTIM_PRESCALER_2" # define HRTIM_MASTER_PRESCALER HRTIM_PRESCALER_2 #endif @@ -305,7 +325,7 @@ struct stm32_hrtim_timout_s #ifdef CONFIG_STM32_HRTIM_CHOPPER struct stm32_hrtim_chopper_s { - uint16_t start:4; /* Chopper start pulsewidth */ + uint16_t start_pulse:4; /* Chopper start pulsewidth */ uint16_t freq:4; /* Chopper carrier frequency value */ uint16_t duty:3; /* Chopper duty cycle */ uint16_t _res:5; /* Reserved */ @@ -317,10 +337,11 @@ struct stm32_hrtim_chopper_s #ifdef CONFIG_STM32_HRTIM_DEADTIME struct stm32_hrtim_deadtime_s { + uint8_t en:1; /* Enable deadtime for timer */ uint8_t fsign_lock:1; /* Deadtime falling sing lock */ uint8_t rsign_lock:1; /* Deadtime rising sing lock */ - uint8_t rising_lock:1; /* Deadtime rising value lock */ uint8_t falling_lock:1; /* Deadtime falling value lock */ + uint8_t rising_lock:1; /* Deadtime rising value lock */ uint8_t fsign:1; /* Deadtime falling sign */ uint8_t rsign:1; /* Deadtime rising sign */ uint8_t prescaler:3; /* Deadtime prescaler */ @@ -344,6 +365,8 @@ struct stm32_hrtim_tim_burst_s struct stm32_hrtim_pwm_s { + uint8_t pushpull:1; + uint8_t res:7; struct stm32_hrtim_timout_s ch1; /* Channel 1 Set/Reset configuration*/ struct stm32_hrtim_timout_s ch2; /* Channel 2 Set/Reset configuration */ @@ -374,12 +397,13 @@ struct stm32_hrtim_capture_s struct stm32_hrtim_timcmn_s { uint32_t base; /* The base adress of the timer */ - uint32_t pclk; /* The frequency of the peripheral clock + uint64_t fclk; /* The frequency of the peripheral clock * that drives the timer module. */ + uint8_t prescaler:3; /* Prescaler */ uint8_t mode; /* Timer mode */ uint8_t dac:2; /* DAC triggering */ - uint8_t reserved:6; + uint8_t reserved:3; #ifdef CONFIG_STM32_HRTIM_INTERRUPTS uint16_t irq; /* interrupts configuration */ #endif @@ -420,7 +444,7 @@ struct stm32_hrtim_slave_priv_s #endif #endif uint16_t update; /* Update configuration */ - uint32_t reset; /* Timer reset events */ + uint64_t reset; /* Timer reset events */ #ifdef CONFIG_STM32_HRTIM_PWM struct stm32_hrtim_pwm_s pwm; /* PWM configuration */ #endif @@ -609,7 +633,7 @@ static void hrtim_tim_putreg(FAR struct stm32_hrtim_s *priv, uint8_t timer, static void hrtim_tim_modifyreg(FAR struct stm32_hrtim_s *priv, uint8_t timer, uint32_t offset, uint32_t clrbits, uint32_t setbits); -#ifdef CONFIG_DEBUG_POWER_INFO +#ifdef CONFIG_DEBUG_TIMER_INFO static void hrtim_dumpregs(FAR struct stm32_hrtim_s *priv, uint8_t timer, FAR const char *msg); #else @@ -622,6 +646,8 @@ static uint32_t hrtim_tim_getreg(FAR struct stm32_hrtim_s *priv, uint8_t timer, uint32_t offset); static FAR struct stm32_hrtim_tim_s *hrtim_tim_get(FAR struct stm32_hrtim_s *priv, uint8_t timer); +static FAR struct stm32_hrtim_slave_priv_s *hrtim_slave_get(FAR struct stm32_hrtim_s *priv, + uint8_t timer); static uint32_t hrtim_base_get(FAR struct stm32_hrtim_s *priv, uint8_t timer); /* Configuration */ @@ -645,6 +671,10 @@ static int hrtim_synch_config(FAR struct stm32_hrtim_s *priv); static int hrtim_outputs_config(FAR struct stm32_hrtim_s *priv); static int hrtim_outputs_enable(FAR struct hrtim_dev_s *dev, uint16_t outputs, bool state); +static int hrtim_output_set_set(FAR struct hrtim_dev_s *dev, uint16_t output, + uint32_t set); +static int hrtim_output_rst_set(FAR struct hrtim_dev_s *dev, uint16_t output, + uint32_t rst); #endif #ifdef HRTIM_HAVE_ADC static int hrtim_adc_config(FAR struct stm32_hrtim_s *priv); @@ -658,13 +688,15 @@ static int hrtim_tim_dma_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer, uint16_t dma); #endif #ifdef CONFIG_STM32_HRTIM_DEADTIME -static int hrtim_deadtime_update(FAR struct stm32_dev_s *dev, uint8_t dt, - uint16_t value) -static uint16_t hrtim_deadtime_get(FAR struct stm32_dev_s *dev, uint8_t dt); +static int hrtim_deadtime_update(FAR struct hrtim_dev_s *dev, uint8_t timer, + uint8_t dt, uint16_t value); +static uint16_t hrtim_deadtime_get(FAR struct hrtim_dev_s *dev, uint8_t timer, + uint8_t dt); +static int hrtim_tim_deadtime_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer); static int hrtim_deadtime_config(FAR struct stm32_hrtim_s *priv); #endif #ifdef CONFIG_STM32_HRTIM_CHOPPER -static int hrtim_chopper_enable(FAR struct stm32_dev_s *dev, uint8_t timer, +static int hrtim_chopper_enable(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t chan, bool state); static int hrtim_tim_chopper_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer); static int hrtim_chopper_config(FAR struct stm32_hrtim_s *priv); @@ -690,7 +722,8 @@ static int hrtim_eev_cfg(FAR struct stm32_hrtim_s *priv, uint8_t index); #endif #ifdef CONFIG_STM32_HRTIM_INTERRUPTS static int hrtim_irq_config(FAR struct stm32_hrtim_s *priv); -static void hrtim_irq_ack(FAR struct hrtim_dev_s *dev, uint8_t timer, int source); +static uint16_t hrtim_irq_get(FAR struct hrtim_dev_s *dev, uint8_t timer); +static int hrtim_irq_ack(FAR struct hrtim_dev_s *dev, uint8_t timer, int source); #endif static int hrtim_cmp_update(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t index, uint16_t cmp); @@ -699,11 +732,15 @@ static int hrtim_per_update(FAR struct hrtim_dev_s *dev, uint8_t timer, static uint16_t hrtim_per_get(FAR struct hrtim_dev_s *dev, uint8_t timer); static uint16_t hrtim_cmp_get(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t index); +static uint64_t hrtim_fclk_get(FAR struct hrtim_dev_s *dev, uint8_t timer); +static int hrtim_soft_update(FAR struct hrtim_dev_s *dev, uint8_t timer); +static int hrtim_tim_freq_set(FAR struct hrtim_dev_s *hrtim, uint8_t timer, + uint64_t freq); static int hrtim_tim_reset_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, - uint32_t reset); + uint64_t reset); static int hrtim_reset_config(FAR struct stm32_hrtim_s *priv); static int hrtim_tim_update_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, - uint32_t update); + uint16_t update); static int hrtim_update_config(FAR struct stm32_hrtim_s *priv); static void hrtim_tim_mode_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, @@ -747,20 +784,21 @@ static struct stm32_hrtim_tim_s g_master = /* If MASTER is disabled, we need only MASTER base */ #ifdef CONFIG_STM32_HRTIM_MASTER - .pclk = HRTIM_CLOCK/(HRTIM_MASTER_PRESCALER+1), - .mode = HRTIM_MASTER_MODE, + .fclk = HRTIM_CLOCK/(1<priv; + +errout: + return slave; +} + /**************************************************************************** * Name: hrtim_base_get * @@ -1873,32 +1989,32 @@ static void hrtim_tim_modifyreg(FAR struct stm32_hrtim_s *priv, uint8_t timer, (hrtim_tim_getreg(priv, timer, offset) & ~clrbits) | setbits); } -#ifdef CONFIG_DEBUG_POWER_INFO +#ifdef CONFIG_DEBUG_TIMER_INFO static void hrtim_dumpregs(FAR struct stm32_hrtim_s *priv, uint8_t timer, FAR const char *msg) { - pwrinfo("%s:\n", msg); + tmrinfo("%s:\n", msg); switch (timer) { case HRTIM_TIMER_MASTER: { - pwrinfo("\tCR:\t0x%08x\tISR:\t0x%08x\tICR:\t0x%08x\n", + tmrinfo("\tCR:\t0x%08x\tISR:\t0x%08x\tICR:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_ISR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_ICR_OFFSET)); - pwrinfo("\tDIER:\t0x%08x\tCNTR:\t0x%08x\tPER:\t0x%08x\n", + tmrinfo("\tDIER:\t0x%08x\tCNTR:\t0x%08x\tPER:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_DIER_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CNTR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_PER_OFFSET)); - pwrinfo("\tREP:\t0x%08x\tCMP1:\t0x%08x\tCMP2:\t0x%08x\n", + tmrinfo("\tREP:\t0x%08x\tCMP1:\t0x%08x\tCMP2:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_REPR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP1R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP2R_OFFSET)); - pwrinfo("\tCMP3:\t0x%08x\tCMP4:\t0x%08x\n", + tmrinfo("\tCMP3:\t0x%08x\tCMP4:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP3R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP4R_OFFSET)); break; @@ -1920,47 +2036,47 @@ static void hrtim_dumpregs(FAR struct stm32_hrtim_s *priv, uint8_t timer, case HRTIM_TIMER_TIME: #endif { - pwrinfo("\tCR:\t0x%08x\tISR:\t0x%08x\tICR:\t0x%08x\n", + tmrinfo("\tCR:\t0x%08x\tISR:\t0x%08x\tICR:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_ISR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_ICR_OFFSET)); - pwrinfo("\tDIER:\t0x%08x\tCNTR:\t0x%08x\tPER:\t0x%08x\n", + tmrinfo("\tDIER:\t0x%08x\tCNTR:\t0x%08x\tPER:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_DIER_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CNTR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_PER_OFFSET)); - pwrinfo("\tREP:\t0x%08x\tCMP1:\t0x%08x\tCMP1C:\t0x%08x\n", + tmrinfo("\tREP:\t0x%08x\tCMP1:\t0x%08x\tCMP1C:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_REPR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP1R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP1CR_OFFSET)); - pwrinfo("\tCMP2:\t0x%08x\tCMP3:\t0x%08x\tCMP4:\t0x%08x\n", + tmrinfo("\tCMP2:\t0x%08x\tCMP3:\t0x%08x\tCMP4:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP2R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP3R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CMP4R_OFFSET)); - pwrinfo("\tCPT1:\t0x%08x\tCPT2:\t0x%08x\tDTR:\t0x%08x\n", + tmrinfo("\tCPT1:\t0x%08x\tCPT2:\t0x%08x\tDTR:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CPT1R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CPT2R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_DTR_OFFSET)); - pwrinfo("\tSET1:\t0x%08x\tRST1:\t0x%08x\tSET2:\t0x%08x\n", + tmrinfo("\tSET1:\t0x%08x\tRST1:\t0x%08x\tSET2:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_SET1R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_RST1R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_SET2R_OFFSET)); - pwrinfo("\tRST2:\t0x%08x\tEEF1:\t0x%08x\tEEF2:\t0x%08x\n", + tmrinfo("\tRST2:\t0x%08x\tEEF1:\t0x%08x\tEEF2:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_RST2R_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_EEFR1_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_EEFR2_OFFSET)); - pwrinfo("\tRSTR:\t0x%08x\tCHPR:\t0x%08x\tCPT1C:\t0x%08x\n", + tmrinfo("\tRSTR:\t0x%08x\tCHPR:\t0x%08x\tCPT1C:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_RSTR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CHPR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CPT1CR_OFFSET)); - pwrinfo("\tCPT2C:\t0x%08x\tOUT:\t0x%08x\tFLT:\t0x%08x\n", + tmrinfo("\tCPT2C:\t0x%08x\tOUT:\t0x%08x\tFLT:\t0x%08x\n", hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CPT2CR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_OUTR_OFFSET), hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_FLTR_OFFSET)); @@ -1970,47 +2086,47 @@ static void hrtim_dumpregs(FAR struct stm32_hrtim_s *priv, uint8_t timer, case HRTIM_TIMER_COMMON: { - pwrinfo("\tCR1:\t0x%08x\tCR2:\t0x%08x\tISR:\t0x%08x\n", + tmrinfo("\tCR1:\t0x%08x\tCR2:\t0x%08x\tISR:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_CR1_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_CR2_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ISR_OFFSET)); - pwrinfo("\tICR:\t0x%08x\tIER:\t0x%08x\tOENR:\t0x%08x\n", + tmrinfo("\tICR:\t0x%08x\tIER:\t0x%08x\tOENR:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ICR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_IER_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_OENR_OFFSET)); - pwrinfo("\tODISR:\t0x%08x\tODSR:\t0x%08x\tBMCR:\t0x%08x\n", + tmrinfo("\tODISR:\t0x%08x\tODSR:\t0x%08x\tBMCR:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ODISR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ODSR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BMCR_OFFSET)); - pwrinfo("\tBMTRG:\t0x%08x\tBMCMPR:\t0x%08x\tBMPER:\t0x%08x\n", + tmrinfo("\tBMTRG:\t0x%08x\tBMCMPR:\t0x%08x\tBMPER:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BMTRGR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BMCMPR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BMPER_OFFSET)); - pwrinfo("\tADC1R:\t0x%08x\tADC2R:\t0x%08x\tADC3R:\t0x%08x\n", + tmrinfo("\tADC1R:\t0x%08x\tADC2R:\t0x%08x\tADC3R:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ADC1R_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ADC2R_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ADC3R_OFFSET)); - pwrinfo("\tADC4R:\t0x%08x\tDLLCR:\t0x%08x\tFLTIN1:\t0x%08x\n", + tmrinfo("\tADC4R:\t0x%08x\tDLLCR:\t0x%08x\tFLTIN1:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ADC4R_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_DLLCR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_FLTINR1_OFFSET)); - pwrinfo("\tFLTIN2:\t0x%08x\tBDMUPD:\t0x%08x\tBDTAUP:\t0x%08x\n", + tmrinfo("\tFLTIN2:\t0x%08x\tBDMUPD:\t0x%08x\tBDTAUP:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_FLTINR2_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDMUPDR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDTAUPR_OFFSET)); - pwrinfo("\tBDTBUP: 0x%08x\tBDTCUP:\t0x%08x\tBDTDUP:\t0x%08x\n", + tmrinfo("\tBDTBUP: 0x%08x\tBDTCUP:\t0x%08x\tBDTDUP:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDTBUPR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDTCUPR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDTDUPR_OFFSET)); - pwrinfo("\tBDTEUP:\t0x%08x\tBDMAD:\t0x%08x\n", + tmrinfo("\tBDTEUP:\t0x%08x\tBDMAD:\t0x%08x\n", hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDTEUPR_OFFSET), hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_BDMADR_OFFSET)); @@ -2036,7 +2152,7 @@ static void hrtim_dumpregs(FAR struct stm32_hrtim_s *priv, uint8_t timer, * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2080,7 +2196,7 @@ static int hrtim_dll_cal(FAR struct stm32_hrtim_s *priv) * timer - An HRTIM Timer index * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2151,6 +2267,10 @@ static int hrtim_tim_clock_config(FAR struct stm32_hrtim_s *priv, } } + /* Write prescaler configuration */ + + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET, regval); + errout: return ret; } @@ -2165,7 +2285,7 @@ errout: * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2247,7 +2367,7 @@ errout: * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2444,13 +2564,13 @@ static int hrtim_gpios_config(FAR struct stm32_hrtim_s *priv) * Description: * Configure HRTIM Captures * - * Input parameters: + * Input Parameters: * priv - A reference to the HRTIM block * timer - HRTIM Timer index * capture - capture trigers configuration * * Returned Value: - * None + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2461,7 +2581,9 @@ static int hrtim_tim_capture_cfg(FAR struct stm32_hrtim_s *priv, int ret = OK; uint32_t offset = 0; - if (timer == HRTIM_TIMER_MASTER) + /* Sanity checking */ + + if (timer == HRTIM_TIMER_MASTER || timer == HRTIM_TIMER_COMMON) { ret = -EINVAL; goto errout; @@ -2500,11 +2622,11 @@ errout: * Description: * Configure HRTIM Captures * - * Input parameters: + * Input Parameters: * priv - A reference to the HRTIM block * * Returned Value: - * None + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2551,13 +2673,13 @@ static int hrtim_capture_config(FAR struct stm32_hrtim_s *priv) * Description: * Get HRTIM Timer Capture register * - * Input parameters: + * Input Parameters: * priv - A reference to the HRTIM block * timer - HRTIM Timer index * index - Capture register index * * Returned Value: - * None + * Timer Capture value on success, 0 on failure * ****************************************************************************/ @@ -2606,7 +2728,7 @@ errout: * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2628,38 +2750,26 @@ static int hrtim_synch_config(FAR struct stm32_hrtim_s *priv) * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ #if defined(CONFIG_STM32_HRTIM_PWM) static int hrtim_tim_outputs_config(FAR struct stm32_hrtim_s *priv, uint8_t timer) { - FAR struct stm32_hrtim_tim_s* tim; FAR struct stm32_hrtim_slave_priv_s* slave; - - int ret = OK; uint32_t regval = 0; + int ret = OK; - /* Master Timer has no outputs */ - - if (timer == HRTIM_TIMER_MASTER) - { - ret = -EINVAL; - goto errout; - } - - /* Get Timer data strucutre */ + /* Get Slave Timer data structure */ - tim = hrtim_tim_get(priv, timer); - if (tim == NULL) + slave = hrtim_slave_get(priv, timer); + if (slave == NULL) { ret = -EINVAL; goto errout; } - slave = (struct stm32_hrtim_slave_priv_s*)tim->priv; - /* Configure CH1 SET events */ regval = slave->pwm.ch1.set; @@ -2724,6 +2834,33 @@ static int hrtim_tim_outputs_config(FAR struct stm32_hrtim_s *priv, uint8_t time } #endif +#ifdef CONFIG_STM32_HRTIM_DEADTIME + if (slave->pwm.dt.en == 1) + { + regval = 0; + + /* Set deadtime enable */ + + regval |= HRTIM_TIMOUT_DTEN; + + /* TODO: deadtime upon burst mode Idle entry */ + + /* Write register */ + + hrtim_tim_modifyreg(priv, timer, STM32_HRTIM_TIM_OUTR_OFFSET, 0, + regval); + } +#endif + +#ifdef CONFIG_STM32_HRTIM_PUSHPULL + if (slave->pwm.pushpull == 1) + { + /* Enable push-pull mode */ + + hrtim_tim_modifyreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET, 0, HRTIM_TIMCR_PSHPLL); + } +#endif + errout: return ret; } @@ -2739,7 +2876,7 @@ errout: * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2814,7 +2951,7 @@ errout: * state - Enable/disable operation * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -2841,123 +2978,354 @@ static int hrtim_outputs_enable(FAR struct hrtim_dev_s *dev, return OK; } -#endif /**************************************************************************** - * Name: hrtim_adc_config - * - * Description: - * Configure HRTIM ADC triggers - * - * Input Parameters: - * priv - A reference to the HRTIM structure - * - * Returned Value: - * 0 on success, a negated errno value on failure - * + * Name: output_tim_index_get ****************************************************************************/ -#ifdef HRTIM_HAVE_ADC -static int hrtim_adc_config(FAR struct stm32_hrtim_s *priv) +static uint8_t output_tim_index_get(uint16_t output) { - /* Configure ADC Trigger 1 */ + uint8_t timer = 0; -#ifdef HRTIM_HAVE_ADC_TRG1 - hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC1R_OFFSET, priv->adc->trg1); + switch(output) + { +#ifdef CONFIG_STM32_HRTIM_TIMA + case HRTIM_OUT_TIMA_CH1: + case HRTIM_OUT_TIMA_CH2: + { + timer = HRTIM_TIMER_TIMA; + break; + } #endif - /* Configure ADC Trigger 2 */ - -#ifdef HRTIM_HAVE_ADC_TRG2 - hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC2R_OFFSET, priv->adc->trg2); +#ifdef CONFIG_STM32_HRTIM_TIMB + case HRTIM_OUT_TIMB_CH1: + case HRTIM_OUT_TIMB_CH2: + { + timer = HRTIM_TIMER_TIMB; + break; + } #endif - /* Configure ADC Trigger 3 */ - -#ifdef HRTIM_HAVE_ADC_TRG3 - hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC3R_OFFSET, priv->adc->trg3); +#ifdef CONFIG_STM32_HRTIM_TIMC + case HRTIM_OUT_TIMC_CH1: + case HRTIM_OUT_TIMC_CH2: + { + timer = HRTIM_TIMER_TIMC; + break; + } #endif - /* Configure ADC Trigger 4 */ +#ifdef CONFIG_STM32_HRTIM_TIMD + case HRTIM_OUT_TIMD_CH1: + case HRTIM_OUT_TIMD_CH2: + { + timer = HRTIM_TIMER_TIMD; + break; + } +#endif -#ifdef HRTIM_HAVE_ADC_TRG4 - hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC4R_OFFSET, priv->adc->trg4); +#ifdef CONFIG_STM32_HRTIM_TIME + case HRTIM_OUT_TIME_CH1: + case HRTIM_OUT_TIME_CH2: + { + timer = HRTIM_TIMER_TIME; + break; + } #endif - return OK; + default: + { + timer = 0; + break; + } + } + + return timer; } -#endif -#ifdef CONFIG_STM32_HRTIM_DAC /**************************************************************************** - * Name: hrtim_tim_dac_cfg - * - * Description: - * Configure single HRTIM Timer DAC synchronization event - * - * Input Parameters: - * priv - A reference to the HRTIM structure - * timer - Timer index - * dac - DAC synchronisation event configuration - * - * Returned Value: - * 0 on success, a negated errno value on failure - * + * Name: output_tim_ch_get ****************************************************************************/ -static int hrtim_tim_dac_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer, - uint8_t dac) +static uint8_t output_tim_ch_get(uint16_t output) { - FAR struct stm32_hrtim_tim_s *tim; - uint32_t regval = 0; - - tim = hrtim_tim_get(priv, timer); + uint8_t ch = 0; - regval = hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET); + switch (output) + { +#ifdef CONFIG_STM32_HRTIM_TIMA + case HRTIM_OUT_TIMA_CH1: +#endif +#ifdef CONFIG_STM32_HRTIM_TIMB + case HRTIM_OUT_TIMB_CH1: +#endif +#ifdef CONFIG_STM32_HRTIM_TIMC + case HRTIM_OUT_TIMC_CH1: +#endif +#ifdef CONFIG_STM32_HRTIM_TIMD + case HRTIM_OUT_TIMD_CH1: +#endif +#ifdef CONFIG_STM32_HRTIM_TIME + case HRTIM_OUT_TIME_CH1: +#endif + { + ch = HRTIM_OUT_CH1; + break; + } - regval |= (dac << HRTIM_CMNCR_DACSYNC_SHIFT); +#ifdef CONFIG_STM32_HRTIM_TIMA + case HRTIM_OUT_TIMA_CH2: +#endif +#ifdef CONFIG_STM32_HRTIM_TIMB + case HRTIM_OUT_TIMB_CH2: +#endif +#ifdef CONFIG_STM32_HRTIM_TIMC + case HRTIM_OUT_TIMC_CH2: +#endif +#ifdef CONFIG_STM32_HRTIM_TIMD + case HRTIM_OUT_TIMD_CH2: +#endif +#ifdef CONFIG_STM32_HRTIM_TIME + case HRTIM_OUT_TIME_CH2: +#endif + { + ch = HRTIM_OUT_CH2; + break; + } - hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET, regval); + default: + { + ch = 0; + break; + } + } - return OK; + return ch; } /**************************************************************************** - * Name: hrtim_dac_config - * - * Description: - * Configure HRTIM DAC synchronization - * - * Input Parameters: - * priv - A reference to the HRTIM structure - * - * Returned Value: - * 0 on success, a negated errno value on failure - * + * Name: hrtim_output_set_set ****************************************************************************/ -static int hrtim_dac_config(FAR struct stm32_hrtim_s *priv) +static int hrtim_output_set_set(FAR struct hrtim_dev_s *dev, uint16_t output, + uint32_t set) { - FAR struct stm32_hrtim_timcmn_s *tim; + FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; + FAR struct stm32_hrtim_slave_priv_s* slave; + uint8_t timer = 0; + int ret = OK; - /* Configure DAC synchronization for Master Timer */ + /* Get timer index from output */ -#ifdef CONFIG_STM32_HRTIM_MASTER_DAC - tim = (struct stm32_hrtim_timcmn_s*)priv->master; - hrtim_tim_dac_cfg(priv, HRTIM_TIMER_MASTER, tim->dac); -#endif + timer = output_tim_index_get(output); - /* Configure DAC synchronization for Timer A */ + /* Get Slave Timer data strucutre */ -#ifdef CONFIG_STM32_HRTIM_TIMA_DAC - tim = (struct stm32_hrtim_timcmn_s*)priv->tima; - hrtim_tim_dac_cfg(priv, HRTIM_TIMER_TIMA, tim->dac); -#endif + slave = hrtim_slave_get(priv, timer); + if (slave == NULL) + { + ret = -EINVAL; + goto errout; + } - /* Configure DAC synchronization for Timer B */ + /* Set new SET value */ -#ifdef CONFIG_STM32_HRTIM_TIMB_DAC - tim = (struct stm32_hrtim_timcmn_s*)priv->timb; + switch (output_tim_ch_get(output)) + { + case HRTIM_OUT_CH1: + { + slave->pwm.ch1.set = set; + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_SET1R_OFFSET, set); + break; + } + + case HRTIM_OUT_CH2: + { + slave->pwm.ch2.set = set; + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_SET2R_OFFSET, set); + break; + } + + default: + { + ret = -EINVAL; + goto errout; + } + } + +errout: + return ret; +} + +/**************************************************************************** + * Name: hrtim_output_rst_set + ****************************************************************************/ +static int hrtim_output_rst_set(FAR struct hrtim_dev_s *dev, uint16_t output, + uint32_t rst) +{ + FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; + FAR struct stm32_hrtim_slave_priv_s* slave; + uint8_t timer = 0; + int ret = OK; + + /* Get timer index from output */ + + timer = output_tim_index_get(output); + + /* Get Salve Timer data strucutre */ + + slave = hrtim_slave_get(priv, timer); + if (slave == NULL) + { + ret = -EINVAL; + goto errout; + } + + /* Set new RST value */ + + switch (output_tim_ch_get(output)) + { + case HRTIM_OUT_CH1: + { + slave->pwm.ch1.rst = rst; + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_RST1R_OFFSET, rst); + } + + case HRTIM_OUT_CH2: + { + slave->pwm.ch2.rst = rst; + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_RST2R_OFFSET, rst); + } + + default: + { + ret = -EINVAL; + goto errout; + } + } + +errout: + return ret; +} + +#endif + +/**************************************************************************** + * Name: hrtim_adc_config + * + * Description: + * Configure HRTIM ADC triggers + * + * Input Parameters: + * priv - A reference to the HRTIM structure + * + * Returned Value: + * 0 on success, a negated errno value on failure + * + ****************************************************************************/ + +#ifdef HRTIM_HAVE_ADC +static int hrtim_adc_config(FAR struct stm32_hrtim_s *priv) +{ + /* Configure ADC Trigger 1 */ + +#ifdef HRTIM_HAVE_ADC_TRG1 + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC1R_OFFSET, priv->adc->trg1); +#endif + + /* Configure ADC Trigger 2 */ + +#ifdef HRTIM_HAVE_ADC_TRG2 + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC2R_OFFSET, priv->adc->trg2); +#endif + + /* Configure ADC Trigger 3 */ + +#ifdef HRTIM_HAVE_ADC_TRG3 + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC3R_OFFSET, priv->adc->trg3); +#endif + + /* Configure ADC Trigger 4 */ + +#ifdef HRTIM_HAVE_ADC_TRG4 + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ADC4R_OFFSET, priv->adc->trg4); +#endif + + return OK; +} +#endif + +#ifdef CONFIG_STM32_HRTIM_DAC +/**************************************************************************** + * Name: hrtim_tim_dac_cfg + * + * Description: + * Configure single HRTIM Timer DAC synchronization event + * + * Input Parameters: + * priv - A reference to the HRTIM structure + * timer - Timer index + * dac - DAC synchronisation event configuration + * + * Returned Value: + * 0 on success, a negated errno value on failure + * + ****************************************************************************/ + +static int hrtim_tim_dac_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer, + uint8_t dac) +{ + FAR struct stm32_hrtim_tim_s *tim; + uint32_t regval = 0; + + tim = hrtim_tim_get(priv, timer); + + regval = hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET); + + regval |= (dac << HRTIM_CMNCR_DACSYNC_SHIFT); + + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET, regval); + + return OK; +} + +/**************************************************************************** + * Name: hrtim_dac_config + * + * Description: + * Configure HRTIM DAC synchronization + * + * Input Parameters: + * priv - A reference to the HRTIM structure + * + * Returned Value: + * 0 on success, a negated errno value on failure + * + ****************************************************************************/ + +static int hrtim_dac_config(FAR struct stm32_hrtim_s *priv) +{ + FAR struct stm32_hrtim_timcmn_s *tim; + + /* Configure DAC synchronization for Master Timer */ + +#ifdef CONFIG_STM32_HRTIM_MASTER_DAC + tim = (struct stm32_hrtim_timcmn_s*)priv->master; + hrtim_tim_dac_cfg(priv, HRTIM_TIMER_MASTER, tim->dac); +#endif + + /* Configure DAC synchronization for Timer A */ + +#ifdef CONFIG_STM32_HRTIM_TIMA_DAC + tim = (struct stm32_hrtim_timcmn_s*)priv->tima; + hrtim_tim_dac_cfg(priv, HRTIM_TIMER_TIMA, tim->dac); +#endif + + /* Configure DAC synchronization for Timer B */ + +#ifdef CONFIG_STM32_HRTIM_TIMB_DAC + tim = (struct stm32_hrtim_timcmn_s*)priv->timb; hrtim_tim_dac_cfg(priv, HRTIM_TIMER_TIMB, tim->dac); #endif @@ -2997,6 +3365,14 @@ static int hrtim_tim_dma_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer, int ret = OK; uint32_t regval = 0; + /* Sanity checking */ + + if (timer == HRTIM_TIMER_COMMON) + { + ret = -EINVAL; + goto errout; + } + if (timer == HRTIM_TIMER_MASTER) { /* Master support first 7 DMA requests */ @@ -3069,7 +3445,7 @@ static int hrtim_dma_cfg(FAR struct stm32_hrtim_s *priv) * Name: hrtim_deadtime_update ****************************************************************************/ -static int hrtim_deadtime_update(FAR struct stm32_dev_s *dev, uint8_t timer, +static int hrtim_deadtime_update(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t dt, uint16_t value) { FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; @@ -3078,17 +3454,18 @@ static int hrtim_deadtime_update(FAR struct stm32_dev_s *dev, uint8_t timer, uint32_t shift = 0; uint32_t mask = 0; - /* Sanity check */ + /* For safety reasons we saturate deadtime value if it exceeds + * the acceptable range. + */ if (value > 0x1FF) { - ret = -EINVAL; - goto errout; + value = 0x1FF; } /* Get shift value */ - switch (index) + switch (dt) { case HRTIM_DT_EDGE_RISING: { @@ -3115,7 +3492,7 @@ static int hrtim_deadtime_update(FAR struct stm32_dev_s *dev, uint8_t timer, /* Update register */ - hrtim_tim_modify(priv, timer, STM32_HRTIM_TIM_DTR_OFFSET, mask, regval); + hrtim_tim_modifyreg(priv, timer, STM32_HRTIM_TIM_DTR_OFFSET, mask, regval); errout: return ret; @@ -3125,7 +3502,8 @@ errout: * Name: hrtim_deadtime_get ****************************************************************************/ -static uint16_t hrtim_deadtime_get(FAR struct stm32_dev_s *dev, uint8_t dt) +static uint16_t hrtim_deadtime_get(FAR struct hrtim_dev_s *dev, uint8_t timer, + uint8_t dt) { #warning missing logic } @@ -3134,19 +3512,32 @@ static uint16_t hrtim_deadtime_get(FAR struct stm32_dev_s *dev, uint8_t dt) * Name: hrtim_tim_deadtime_cfg ****************************************************************************/ -static int hrtim_tim_deadtime_cfg(FAR struct stm32_hrtim_s *priv, uint8_t index) +static int hrtim_tim_deadtime_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer) { FAR struct stm32_hrtim_slave_priv_s* slave; uint32_t regval = 0; int ret = OK; - if (timer == HRTIM_TIMER_MASTER) + /* Sanity checking */ + + if (timer == HRTIM_TIMER_MASTER || timer == HRTIM_TIMER_COMMON) { ret = -EINVAL; goto errout; } - slave = (struct stm32_hrtim_slave_priv_s*)tim->priv; + /* Get Slave Timer data strucutre */ + + slave = hrtim_slave_get(priv, timer); + if (slave == NULL) + { + ret = -EINVAL; + goto errout; + } + + /* Configure deadtime prescaler */ + + regval |= slave->pwm.dt.prescaler << HRTIM_TIMDT_DTPRSC_SHIFT; /* Configure rising deadtime */ @@ -3158,14 +3549,14 @@ static int hrtim_tim_deadtime_cfg(FAR struct stm32_hrtim_s *priv, uint8_t index) /* Configure falling deadtime sign */ - if (slave->pwm.dt.fsign == HRTIM_DT_SIGN_POSITIVE) + if (slave->pwm.dt.fsign == HRTIM_DT_SIGN_NEGATIVE) { regval |= HRTIM_TIMDT_SDTF; } /* Configure risign deadtime sign */ - if (slave->pwm.dt.rsign == HRTIM_DT_SIGN_POSITIVE) + if (slave->pwm.dt.rsign == HRTIM_DT_SIGN_NEGATIVE) { regval |= HRTIM_TIMDT_SDTR; } @@ -3198,6 +3589,12 @@ static int hrtim_tim_deadtime_cfg(FAR struct stm32_hrtim_s *priv, uint8_t index) regval |= HRTIM_TIMDT_DTFLK; } + /* TODO: configure default deadtime values */ + + /* Write register */ + + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_DTR_OFFSET, regval); + errout: return ret; } @@ -3210,31 +3607,31 @@ static int hrtim_deadtime_config(FAR struct stm32_hrtim_s *priv) { /* Configure Timer A deadtime */ -#ifdef CONFIG_STM32_HRTIM_TIMA +#ifdef CONFIG_STM32_HRTIM_TIMA_DT hrtim_tim_deadtime_cfg(priv, HRTIM_TIMER_TIMA); #endif /* Configure Timer B deadtime */ -#ifdef CONFIG_STM32_HRTIM_TIMB +#ifdef CONFIG_STM32_HRTIM_TIMB_DT hrtim_tim_deadtime_cfg(priv, HRTIM_TIMER_TIMB); #endif /* Configure Timer C deadtime */ -#ifdef CONFIG_STM32_HRTIM_TIMC +#ifdef CONFIG_STM32_HRTIM_TIMC_DT hrtim_tim_deadtime_cfg(priv, HRTIM_TIMER_TIMC); #endif /* Configure Timer D deadtime */ -#ifdef CONFIG_STM32_HRTIM_TIMD +#ifdef CONFIG_STM32_HRTIM_TIMD_DT hrtim_tim_deadtime_cfg(priv, HRTIM_TIMER_TIMD); #endif /* Configure Timer E deadtime */ -#ifdef CONFIG_STM32_HRTIM_TIME +#ifdef CONFIG_STM32_HRTIM_TIME_DT hrtim_tim_deadtime_cfg(priv, HRTIM_TIMER_TIME); #endif @@ -3256,11 +3653,11 @@ static int hrtim_deadtime_config(FAR struct stm32_hrtim_s *priv) * state - Enable/disable operation * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ -static int hrtim_chopper_enable(FAR struct stm32_dev_s *dev, uint8_t timer, +static int hrtim_chopper_enable(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t chan, bool state) { FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; @@ -3296,13 +3693,13 @@ static int hrtim_chopper_enable(FAR struct stm32_dev_s *dev, uint8_t timer, { /* Set enable bit */ - hrtim_tim_modifyreg(priv, index, STM32_HRTIM_TIM_OUTR_OFFSET, 0, val); + hrtim_tim_modifyreg(priv, timer, STM32_HRTIM_TIM_OUTR_OFFSET, 0, val); } else { /* Clear enable bit */ - hrtim_tim_modifyreg(priv, index, STM32_HRTIM_TIM_OUTR_OFFSET, val, 0); + hrtim_tim_modifyreg(priv, timer, STM32_HRTIM_TIM_OUTR_OFFSET, val, 0); } errout: @@ -3316,31 +3713,28 @@ errout: static int hrtim_tim_chopper_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer) { - FAR struct stm32_hrtim_tim_s* tim; FAR struct stm32_hrtim_slave_priv_s* slave; int ret = OK; uint32_t regval = 0; - /* Master Timer has no outputs */ + /* Sanity checking */ - if (timer == HRTIM_TIMER_MASTER) + if (timer == HRTIM_TIMER_MASTER || timer == HRTIM_TIMER_COMMON) { ret = -EINVAL; goto errout; } - /* Get Timer data strucutre */ + /* Get Slave Timer data strucutre */ - tim = hrtim_tim_get(priv, timer); - if (tim == NULL) + slave = hrtim_slave_get(priv, timer); + if (slave == NULL) { ret = -EINVAL; goto errout; } - slave = (struct stm32_hrtim_slave_priv_s*)tim->priv; - /* Configure start pulsewidth */ regval |= slave->pwm.chp.start_pulse << HRTIM_TIMCHP_STRTPW_SHIFT; @@ -3357,6 +3751,7 @@ static int hrtim_tim_chopper_cfg(FAR struct stm32_hrtim_s *priv, hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_CHPR_OFFSET, regval); +errout: return OK; } @@ -3597,19 +3992,22 @@ static int hrtim_burst_config(FAR struct stm32_hrtim_s *priv) * timer - timer index * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ static int hrtim_tim_faults_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer) { - FAR struct stm32_hrtim_tim_s *tim; FAR struct stm32_hrtim_slave_priv_s *slave; uint32_t regval = 0; + int ret = OK; - tim = hrtim_tim_get(priv, timer); - - slave = tim->priv; + slave = hrtim_slave_get(priv, timer); + if (slave == NULL) + { + ret = -EINVAL; + goto errout; + } /* Get lock configuration */ @@ -3623,7 +4021,8 @@ static int hrtim_tim_faults_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer) hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_FLTR_OFFSET, regval); - return OK; +errout: + return ret; } /**************************************************************************** @@ -3637,7 +4036,7 @@ static int hrtim_tim_faults_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer) * index - Fault index * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -3779,7 +4178,7 @@ errout: * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -3853,7 +4252,7 @@ static int hrtim_faults_config(FAR struct stm32_hrtim_s *priv) * index - External Event index * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -4028,7 +4427,7 @@ errout: * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -4088,6 +4487,30 @@ static int hrtim_events_config(FAR struct stm32_hrtim_s *priv) } #endif /* CONFIG_STM32_HRTIM_FAULTS */ + +#ifdef CONFIG_STM32_HRTIM_INTERRUPTS + +/**************************************************************************** + * Name: hrtim_irq_cfg + ****************************************************************************/ + +static int hrtim_irq_cfg(FAR struct stm32_hrtim_s *priv, uint8_t timer, uint16_t irq) +{ + int ret = OK; + + if (timer == HRTIM_TIMER_COMMON) + { + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_IER_OFFSET, irq); + } + else + { + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_DIER_OFFSET, irq); + } + +errout: + return ret; +} + /**************************************************************************** * Name: hrtim_irq_config * @@ -4098,30 +4521,100 @@ static int hrtim_events_config(FAR struct stm32_hrtim_s *priv) * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ -#ifdef CONFIG_STM32_HRTIM_INTERRUPTS static int hrtim_irq_config(FAR struct stm32_hrtim_s *priv) { -#warning "hrtim_irq_config: missing logic" - return OK; -} +#ifdef CONFIG_STM32_HRTIM_MASTER_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_MASTER, priv->master->tim.irq); +#endif -void hrtim_irq_ack(FAR struct hrtim_dev_s *dev, uint8_t timer, int source); -{ -#warning "hrtim_irq_ack: missing logic" -} -#endif /* CONFIG_STM32_HRTIM_INTERRUPTS */ +#ifdef CONFIG_STM32_HRTIM_TIMA_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_TIMA, priv->tima->tim.irq); +#endif -/**************************************************************************** +#ifdef CONFIG_STM32_HRTIM_TIMB_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_TIMB, priv->timb->tim.irq); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMB_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_TIMB, priv->timc->tim.irq); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMB_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_TIMB, priv->timd->tim.irq); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMB_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_TIMB, priv->time->tim.irq); +#endif + +#ifdef CONFIG_STM32_HRTIM_COMMON_IRQ + hrtim_irq_cfg(priv, HRTIM_TIMER_COMMON, priv->irq); +#endif + + return OK; +} + +/**************************************************************************** + * Name: hrtim_irq_ack + ****************************************************************************/ + +static int hrtim_irq_ack(FAR struct hrtim_dev_s *dev, uint8_t timer, int source) +{ + FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; + + if (timer == HRTIM_TIMER_COMMON) + { + /* Write to the HRTIM common clear interrupt register */ + + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_ICR_OFFSET, source); + } + else + { + /* Each timer has its own ICR register */ + + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_ICR_OFFSET, source); + } + + return OK; +} + +/**************************************************************************** + * Name: hrtim_irq_get + ****************************************************************************/ + +static uint16_t hrtim_irq_get(FAR struct hrtim_dev_s *dev, uint8_t timer) +{ + FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; + uint32_t regval = 0; + + if (timer == HRTIM_TIMER_COMMON) + { + /* Get HRTIM common status interrupt register */ + + regval = hrtim_cmn_getreg(priv, STM32_HRTIM_CMN_ISR_OFFSET); + } + else + { + /* Each timer has its own ISR register */ + + regval = hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_ISR_OFFSET); + } + + return (uint16_t)regval; +} +#endif /* CONFIG_STM32_HRTIM_INTERRUPTS */ + +/**************************************************************************** * Name: hrtim_tim_mode_set * * Description: * Set HRTIM Timer mode * - * Input parameters: + * Input Parameters: * priv - A reference to the HRTIM block * timer - HRTIM Timer index * mode - Timer mode configuration @@ -4166,17 +4659,9 @@ static void hrtim_tim_mode_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, regval |= HRTIM_CMNCR_CONT; } - /* Configure push-pull mode. Only Slaves */ - - if (mode & HRTIM_MODE_PSHPLL && timer != HRTIM_TIMER_MASTER) - { - regval |= HRTIM_TIMCR_PSHPLL; - } - /* Write register */ hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET, regval); - } /**************************************************************************** @@ -4189,7 +4674,7 @@ static void hrtim_tim_mode_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, * priv - A reference to the HRTIM structure * * Returned Value: - * None + * None * ****************************************************************************/ @@ -4220,20 +4705,91 @@ static void hrtim_mode_config(FAR struct stm32_hrtim_s *priv) #endif } +/**************************************************************************** + * Name: hrtim_cmpcap_mask_get + * + * Description: + * This function returns not significant bits in counter/capture + * regsiters for given HRTIM Timer index. + * + * Input Parameters: + * priv - A reference to the HRTIM structure + * timer - HRTIM Timer index + * + * Returned Value: + * Not significant bits for counter/capture registers + * + ****************************************************************************/ + +static uint8_t hrtim_cmpcap_mask_get(FAR struct stm32_hrtim_s *priv, + uint8_t timer) +{ + FAR struct stm32_hrtim_tim_s* tim; + uint8_t mask = 0; + + /* Get Timer data strucutre */ + + tim = hrtim_tim_get(priv, timer); + if (tim == NULL) + { + mask = 0; + goto errout; + } + + /* Not significant bits depens on timer prescaler */ + + switch(tim->tim.prescaler) + { + case HRTIM_PRESCALER_1: + { + mask = 0b11111; + break; + } + case HRTIM_PRESCALER_2: + { + mask = 0b1111; + break; + } + case HRTIM_PRESCALER_4: + { + mask = 0b111; + break; + } + case HRTIM_PRESCALER_8: + { + mask = 0b11; + break; + } + case HRTIM_PRESCALER_16: + { + mask = 0b1; + break; + } + default: + { + mask = 0; + break; + } + } + +errout: + return mask; +} + /**************************************************************************** * Name: hrtim_cmp_update * * Description: * Try update HRTIM Timer compare register. * - * Input parameters: + * Input Parameters: * dev - HRTIM device structure * timer - HRTIM Timer index * index - Compare register timer * cmp - New compare register value * * Returned Value: - * Zero on success; a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -4243,6 +4799,7 @@ static int hrtim_cmp_update(FAR struct hrtim_dev_s *dev, uint8_t timer, FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; int ret = OK; uint32_t offset = 0; + uint8_t mask = 0; switch (index) { @@ -4277,6 +4834,16 @@ static int hrtim_cmp_update(FAR struct hrtim_dev_s *dev, uint8_t timer, } } + /* REVISIT: what should we do if cmp value is not significant ? + * At this moment we set compare register to the nearest significant value. + */ + + mask = hrtim_cmpcap_mask_get(priv, timer); + if (cmp <= mask) + { + cmp = mask + 1; + } + hrtim_tim_putreg(priv, timer, offset, cmp); errout: @@ -4289,13 +4856,13 @@ errout: * Description: * Try update HRTIM Timer period register. * - * Input parameters: + * Input Parameters: * dev - HRTIM device structure * timer - HRTIM Timer index * per - New period register value * * Returned Value: - * Zero on success; a negated errno value on failure + * 0 on success; a negated errno value on failure * ****************************************************************************/ @@ -4314,12 +4881,12 @@ static int hrtim_per_update(FAR struct hrtim_dev_s *dev, uint8_t timer, * Description: * Get HRTIM Timer period value * - * Input parameters: + * Input Parameters: * dev - HRTIM device structure * timer - HRTIM Timer index * * Returned Value: - * Zero on success; a negated errno value on failure + * Timer period value * ****************************************************************************/ @@ -4336,13 +4903,13 @@ static uint16_t hrtim_per_get(FAR struct hrtim_dev_s *dev, uint8_t timer) * Description: * Get HRTIM Timer compare register * - * Input parameters: + * Input Parameters: * priv - A reference to the HRTIM block * timer - HRTIM Timer index * index - Compare register timer * * Returned Value: - * Zero on success; a negated errno value on failure + * Timer compare value * ****************************************************************************/ @@ -4392,13 +4959,134 @@ errout: return cmpx; } +/**************************************************************************** + * Name: hrtim_fclk_get + * + * Description: + * Get HRTIM Timer clock value + * + * Input Parameters: + * dev - HRTIM device structure + * timer - HRTIM Timer index + * + * Returned Value: + * Timer clock value + * + ****************************************************************************/ + +static uint64_t hrtim_fclk_get(FAR struct hrtim_dev_s *dev, uint8_t timer) +{ + FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; + FAR struct stm32_hrtim_tim_s *tim; + uint64_t fclk = 0; + + /* Get Timer data structure */ + + tim = hrtim_tim_get(priv, timer); + if (tim == NULL) + { + fclk = 0; + goto errout; + } + + fclk = tim->tim.fclk; + +errout: + return fclk; +} + +/**************************************************************************** + * Name: hrtim_soft_update + * + * Description: + * HRTIM Timer software update. + * This is bulk operation, so we can update many registers at the same time. + * + * Input Parameters: + * dev - HRTIM device structure + * timer - HRTIM Timer indexes + * + * Returned Value: + * 0 on success; a negated errno value on failure + * + ****************************************************************************/ + +static int hrtim_soft_update(FAR struct hrtim_dev_s *dev, uint8_t timer) +{ + FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv; + uint32_t regval = 0; + + regval |= (timer & HRTIM_TIMER_MASTER ? HRTIM_CR2_MSWU : 0); +#ifdef CONFIG_STM32_HRTIM_TIMA + regval |= (timer & HRTIM_TIMER_TIMA ? HRTIM_CR2_TASWU : 0); +#endif +#ifdef CONFIG_STM32_HRTIM_TIMB + regval |= (timer & HRTIM_TIMER_TIMB ? HRTIM_CR2_TBSWU : 0); +#endif +#ifdef CONFIG_STM32_HRTIM_TIMC + regval |= (timer & HRTIM_TIMER_TIMC ? HRTIM_CR2_TCSWU : 0); +#endif +#ifdef CONFIG_STM32_HRTIM_TIMD + regval |= (timer & HRTIM_TIMER_TIMD ? HRTIM_CR2_TDSWU : 0); +#endif +#ifdef CONFIG_STM32_HRTIM_TIME + regval |= (timer & HRTIM_TIMER_TIME ? HRTIM_CR2_TESWU : 0); +#endif + + /* Bits in HRTIM CR2 common register are automatically reset, + * so we can just write to it. + */ + + hrtim_cmn_putreg(priv, STM32_HRTIM_CMN_CR2_OFFSET, regval); + + return OK; +} + +/**************************************************************************** + * Name: hrtim_tim_freq_set + * + * Description: + * Set HRTIM Timer frequency + * + * Returned Value: + * 0 on success, a negated errno value on failure + * + ****************************************************************************/ + +static int hrtim_tim_freq_set(FAR struct hrtim_dev_s *hrtim, uint8_t timer, + uint64_t freq) +{ + uint64_t per = 0; + uint64_t fclk = 0; + int ret = OK; + + /* Get Timer period value for given frequency */ + + fclk = HRTIM_FCLK_GET(hrtim, timer); + per = fclk/freq; + if (per > HRTIM_PER_MAX) + { + tmrerr("ERROR: can not achieve timer pwm freq=%u if fclk=%llu\n", + (uint32_t)freq, (uint64_t)fclk); + ret = -EINVAL; + goto errout; + } + + /* Set Timer period value */ + + HRTIM_PER_SET(hrtim, timer, (uint16_t)per); + + errout: + return ret; +} + /**************************************************************************** * Name: hrtim_tim_reset_set * * Description: * Set HRTIM Timer Reset events * - * Input parameters: + * Input Parameters: * priv - A reference to the HRTIM block * timer - HRTIM Timer index * reset - Reset configuration @@ -4409,17 +5097,135 @@ errout: ****************************************************************************/ static int hrtim_tim_reset_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, - uint32_t reset) + uint64_t reset) { int ret = OK; + uint32_t regval = 0; - if (timer == HRTIM_TIMER_MASTER) + /* Sanity checking */ + + if (timer == HRTIM_TIMER_MASTER || timer == HRTIM_TIMER_COMMON) { ret = -EINVAL; goto errout; } - hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_RSTR_OFFSET, reset); + /* First 18 bits can be written directly */ + + regval |= (reset & 0x3FFFF); + + /* TimerX reset events differ for individual timers */ + + switch(timer) + { +#ifdef CONFIG_STM32_HRTIM_TIMA + case HRTIM_TIMER_TIMA: + { + regval |= ((reset & HRTIM_RST_TBCMP1) ? HRTIM_TIMARST_TIMBCMP1 : 0); + regval |= ((reset & HRTIM_RST_TBCMP2) ? HRTIM_TIMARST_TIMBCMP2 : 0); + regval |= ((reset & HRTIM_RST_TBCMP4) ? HRTIM_TIMARST_TIMBCMP4 : 0); + regval |= ((reset & HRTIM_RST_TCCMP1) ? HRTIM_TIMARST_TIMCCMP1 : 0); + regval |= ((reset & HRTIM_RST_TCCMP2) ? HRTIM_TIMARST_TIMCCMP2 : 0); + regval |= ((reset & HRTIM_RST_TCCMP4) ? HRTIM_TIMARST_TIMCCMP4 : 0); + regval |= ((reset & HRTIM_RST_TDCMP1) ? HRTIM_TIMARST_TIMDCMP1 : 0); + regval |= ((reset & HRTIM_RST_TDCMP2) ? HRTIM_TIMARST_TIMDCMP2 : 0); + regval |= ((reset & HRTIM_RST_TDCMP4) ? HRTIM_TIMARST_TIMDCMP4 : 0); + regval |= ((reset & HRTIM_RST_TECMP1) ? HRTIM_TIMARST_TIMECMP1 : 0); + regval |= ((reset & HRTIM_RST_TECMP2) ? HRTIM_TIMARST_TIMECMP2 : 0); + regval |= ((reset & HRTIM_RST_TECMP4) ? HRTIM_TIMARST_TIMECMP4 : 0); + + break; + } +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMB + case HRTIM_TIMER_TIMB: + { + regval |= ((reset & HRTIM_RST_TACMP1) ? HRTIM_TIMBRST_TIMACMP1 : 0); + regval |= ((reset & HRTIM_RST_TACMP2) ? HRTIM_TIMBRST_TIMACMP2 : 0); + regval |= ((reset & HRTIM_RST_TACMP4) ? HRTIM_TIMBRST_TIMACMP4 : 0); + regval |= ((reset & HRTIM_RST_TCCMP1) ? HRTIM_TIMBRST_TIMCCMP1 : 0); + regval |= ((reset & HRTIM_RST_TCCMP2) ? HRTIM_TIMBRST_TIMCCMP2 : 0); + regval |= ((reset & HRTIM_RST_TCCMP4) ? HRTIM_TIMBRST_TIMCCMP4 : 0); + regval |= ((reset & HRTIM_RST_TDCMP1) ? HRTIM_TIMBRST_TIMDCMP1 : 0); + regval |= ((reset & HRTIM_RST_TDCMP2) ? HRTIM_TIMBRST_TIMDCMP2 : 0); + regval |= ((reset & HRTIM_RST_TDCMP4) ? HRTIM_TIMBRST_TIMDCMP4 : 0); + regval |= ((reset & HRTIM_RST_TECMP1) ? HRTIM_TIMBRST_TIMECMP1 : 0); + regval |= ((reset & HRTIM_RST_TECMP2) ? HRTIM_TIMBRST_TIMECMP2 : 0); + regval |= ((reset & HRTIM_RST_TECMP4) ? HRTIM_TIMBRST_TIMECMP4 : 0); + + break; + } +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMC + case HRTIM_TIMER_TIMC: + { + regval |= ((reset & HRTIM_RST_TACMP1) ? HRTIM_TIMCRST_TIMACMP1 : 0); + regval |= ((reset & HRTIM_RST_TACMP2) ? HRTIM_TIMCRST_TIMACMP2 : 0); + regval |= ((reset & HRTIM_RST_TACMP4) ? HRTIM_TIMCRST_TIMACMP4 : 0); + regval |= ((reset & HRTIM_RST_TBCMP1) ? HRTIM_TIMCRST_TIMBCMP1 : 0); + regval |= ((reset & HRTIM_RST_TBCMP2) ? HRTIM_TIMCRST_TIMBCMP2 : 0); + regval |= ((reset & HRTIM_RST_TBCMP4) ? HRTIM_TIMCRST_TIMBCMP4 : 0); + regval |= ((reset & HRTIM_RST_TDCMP1) ? HRTIM_TIMCRST_TIMDCMP1 : 0); + regval |= ((reset & HRTIM_RST_TDCMP2) ? HRTIM_TIMCRST_TIMDCMP2 : 0); + regval |= ((reset & HRTIM_RST_TDCMP4) ? HRTIM_TIMCRST_TIMDCMP4 : 0); + regval |= ((reset & HRTIM_RST_TECMP1) ? HRTIM_TIMCRST_TIMECMP1 : 0); + regval |= ((reset & HRTIM_RST_TECMP2) ? HRTIM_TIMCRST_TIMECMP2 : 0); + regval |= ((reset & HRTIM_RST_TECMP4) ? HRTIM_TIMCRST_TIMECMP4 : 0); + + break; + } +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMD + case HRTIM_TIMER_TIMD: + { + regval |= ((reset & HRTIM_RST_TACMP1) ? HRTIM_TIMDRST_TIMACMP1 : 0); + regval |= ((reset & HRTIM_RST_TACMP2) ? HRTIM_TIMDRST_TIMACMP2 : 0); + regval |= ((reset & HRTIM_RST_TACMP4) ? HRTIM_TIMDRST_TIMACMP4 : 0); + regval |= ((reset & HRTIM_RST_TBCMP1) ? HRTIM_TIMDRST_TIMBCMP1 : 0); + regval |= ((reset & HRTIM_RST_TBCMP2) ? HRTIM_TIMDRST_TIMBCMP2 : 0); + regval |= ((reset & HRTIM_RST_TBCMP4) ? HRTIM_TIMDRST_TIMBCMP4 : 0); + regval |= ((reset & HRTIM_RST_TCCMP1) ? HRTIM_TIMDRST_TIMCCMP1 : 0); + regval |= ((reset & HRTIM_RST_TCCMP2) ? HRTIM_TIMDRST_TIMCCMP2 : 0); + regval |= ((reset & HRTIM_RST_TCCMP4) ? HRTIM_TIMDRST_TIMCCMP4 : 0); + regval |= ((reset & HRTIM_RST_TECMP1) ? HRTIM_TIMDRST_TIMECMP1 : 0); + regval |= ((reset & HRTIM_RST_TECMP2) ? HRTIM_TIMDRST_TIMECMP2 : 0); + regval |= ((reset & HRTIM_RST_TECMP4) ? HRTIM_TIMDRST_TIMECMP4 : 0); + + break; + } +#endif + +#ifdef CONFIG_STM32_HRTIM_TIME + case HRTIM_TIMER_TIME: + { + regval |= ((reset & HRTIM_RST_TACMP1) ? HRTIM_TIMERST_TIMACMP1 : 0); + regval |= ((reset & HRTIM_RST_TACMP2) ? HRTIM_TIMERST_TIMACMP2 : 0); + regval |= ((reset & HRTIM_RST_TACMP4) ? HRTIM_TIMERST_TIMACMP4 : 0); + regval |= ((reset & HRTIM_RST_TBCMP1) ? HRTIM_TIMERST_TIMBCMP1 : 0); + regval |= ((reset & HRTIM_RST_TBCMP2) ? HRTIM_TIMERST_TIMBCMP2 : 0); + regval |= ((reset & HRTIM_RST_TBCMP4) ? HRTIM_TIMERST_TIMBCMP4 : 0); + regval |= ((reset & HRTIM_RST_TCCMP1) ? HRTIM_TIMERST_TIMCCMP1 : 0); + regval |= ((reset & HRTIM_RST_TCCMP2) ? HRTIM_TIMERST_TIMCCMP2 : 0); + regval |= ((reset & HRTIM_RST_TCCMP4) ? HRTIM_TIMERST_TIMCCMP4 : 0); + regval |= ((reset & HRTIM_RST_TDCMP1) ? HRTIM_TIMERST_TIMDCMP1 : 0); + regval |= ((reset & HRTIM_RST_TDCMP2) ? HRTIM_TIMERST_TIMDCMP2 : 0); + regval |= ((reset & HRTIM_RST_TDCMP4) ? HRTIM_TIMERST_TIMDCMP4 : 0); + + break; + } +#endif + + default: + { + ret = -EINVAL; + goto errout; + } + } + + hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_RSTR_OFFSET, regval); errout: return ret; @@ -4458,13 +5264,37 @@ static int hrtim_reset_config(FAR struct stm32_hrtim_s *priv) } static int hrtim_tim_update_set(FAR struct stm32_hrtim_s *priv, uint8_t timer, - uint32_t update) + uint16_t update) { uint32_t regval = 0; regval = hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_CR_OFFSET); - /* TODO: Configure update events */ + /* Configure update events */ + + regval |= (update & HRTIM_UPDATE_MSTU ? HRTIM_TIMCR_MSTU : 0); + regval |= (update & HRTIM_UPDATE_RSTU ? HRTIM_TIMCR_RSTU : 0); + regval |= (update & HRTIM_UPDATE_REPU ? HRTIM_TIMCR_REPU : 0); + +#ifdef CONFIG_STM32_HRTIM_TIMA + regval |= (update & HRTIM_UPDATE_TAU ? HRTIM_TIMCR_TAU : 0); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMB + regval |= (update & HRTIM_UPDATE_TBU ? HRTIM_TIMCR_TBU : 0); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMC + regval |= (update & HRTIM_UPDATE_TCU ? HRTIM_TIMCR_TCU : 0); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIMD + regval |= (update & HRTIM_UPDATE_TDU ? HRTIM_TIMCR_TDU : 0); +#endif + +#ifdef CONFIG_STM32_HRTIM_TIME + regval |= (update & HRTIM_UPDATE_TEU ? HRTIM_TIMCR_TEU : 0); +#endif /* TODO: Configure update gating */ @@ -4517,7 +5347,7 @@ static int hrtim_update_config(FAR struct stm32_hrtim_s *priv) * priv - A reference to the HRTIM structure * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -4595,6 +5425,17 @@ static int stm32_hrtimconfig(FAR struct stm32_hrtim_s *priv) } #endif + /* Configure HRTIM outputs deadtime */ + +#if defined(CONFIG_STM32_HRTIM_DEADTIME) + ret = hrtim_deadtime_config(priv); + if (ret != OK) + { + tmrerr("ERROR: HRTIM deadtime configuration failed!\n"); + goto errout; + } +#endif + /* Configure HRTIM outputs GPIOs */ #if defined(CONFIG_STM32_HRTIM_PWM) @@ -4652,7 +5493,7 @@ static int stm32_hrtimconfig(FAR struct stm32_hrtim_s *priv) /* Configure interrupts */ -#ifdef CONFIG_STM32_HRTIM_INTERRUTPS +#ifdef CONFIG_STM32_HRTIM_INTERRUPTS ret = hrtim_irq_config(priv); if (ret != OK) { @@ -4794,7 +5635,6 @@ FAR struct hrtim_dev_s* stm32_hrtiminitialize(void) if (ret < 0) { tmrerr("ERROR: Failed to initialize HRTIM1: %d\n", ret); - errno = -ret; return NULL; } diff --git a/arch/arm/src/stm32/stm32_hrtim.h b/arch/arm/src/stm32/stm32_hrtim.h index 1085951fb9049690e94bcf7a7d8e66cb3aebe442..323488ae3023cae204ae7a8eb65381f179ad6994 100644 --- a/arch/arm/src/stm32/stm32_hrtim.h +++ b/arch/arm/src/stm32/stm32_hrtim.h @@ -187,7 +187,7 @@ # error "APB2 prescaler factor can not be greater than 2" # else # define HRTIM_HAVE_CLK_FROM_PLL 1 -# define HRTIM_CLOCK 2*STM32_PLL_FREQUENCY +# define HRTIM_MAIN_CLOCK 2*STM32_PLL_FREQUENCY # endif # else # error "Clock system must be set to PLL" @@ -195,23 +195,41 @@ #else # error "Not supported yet: system freezes when no PLL selected." # define HRTIM_HAVE_CLK_FROM_APB2 1 -# if STM32_RCC_CFGR_PPRE2 == RCC_CFGR_PPRE2_HCLK -# define HRTIM_CLOCK STM32_PCLK2_FREQUENCY +# if STM32_RCC_CFGR_PPRE2 == RCC_CFGR_PPRE2_HCLK +# define HRTIM_MAIN_CLOCK STM32_PCLK2_FREQUENCY # else -# define HRTIM_CLOCK 2*STM32_PCLK2_FREQUENCY +# define HRTIM_MAIN_CLOCK 2*STM32_PCLK2_FREQUENCY # endif #endif +/* High-resolution equivalent clock */ + +#define HRTIM_CLOCK (HRTIM_MAIN_CLOCK*32ull) + /* Helpers **************************************************************************/ #define HRTIM_CMP_SET(hrtim, tim, index, cmp) \ (hrtim)->hd_ops->cmp_update(hrtim, tim, index, cmp) #define HRTIM_PER_SET(hrtim, tim, per) \ (hrtim)->hd_ops->per_update(hrtim, tim, per) -#define HRTIM_OUTPUTS_ENABLE(hrtim, tim, state) \ - (hrtim)->hd_ops->outputs_enable(hrtim, tim, state) -#define HRTIM_OUTPUTS_ENABLE(hrtim, tim, state) \ - (hrtim)->hd_ops->outputs_enable(hrtim, tim, state) +#define HRTIM_PER_GET(hrtim, tim) \ + (hrtim)->hd_ops->per_get(hrtim, tim) +#define HRTIM_FCLK_GET(hrtim, tim) \ + (hrtim)->hd_ops->fclk_get(hrtim, tim) +#define HRTIM_IRQ_GET(hrtim, irq) \ + (hrtim)->hd_ops->irq_get(hrtim, irq) +#define HRTIM_IRQ_ACK(hrtim, irq, ack) \ + (hrtim)->hd_ops->irq_ack(hrtim, irq, ack) +#define HRTIM_SOFT_UPDATE(hrtim, timer) \ + (hrtim)->hd_ops->soft_update(hrtim, timer) +#define HRTIM_FREQ_SET(hrtim, timer,freq) \ + (hrtim)->hd_ops->freq_set(hrtim, timer, freq) +#define HRTIM_OUTPUTS_ENABLE(hrtim, outputs, state) \ + (hrtim)->hd_ops->outputs_enable(hrtim, outputs, state) +#define HRTIM_OUTPUT_SET_SET(hrtim, output, set) \ + (hrtim)->hd_ops->output_set_set(hrtim, output, set) +#define HRTIM_OUTPUT_RST_SET(hrtim, output, rst) \ + (hrtim)->hd_ops->output_rst_set(hrtim, output, rst) #define HRTIM_BURST_CMP_SET(hrtim, cmp) \ (hrtim)->hd_ops->burst_cmp_set(hrtim, cmp) #define HRTIM_BURST_PER_SET(hrtim, per) \ @@ -220,6 +238,13 @@ (hrtim)->hd_ops->burst_pre_set(hrtim, pre) #define HRTIM_BURST_ENABLE(hrtim, state) \ (hrtim)->hd_ops->burst_enable(hrtim, state) +#define HRTIM_DEADTIME_UPDATE(hrtim, tim, dt, val) \ + (hrtim)->hd_ops->deadtime_update(hrtim, tim, dt, val) + +#define HRTIM_PER_MAX 0xFFFF +#define HRTIM_CMP_MAX 0xFFFF +#define HRTIM_CPT_MAX 0xFFFF +#define HRTIM_REP_MAX 0xFF /************************************************************************************ * Public Types @@ -229,23 +254,23 @@ enum stm32_hrtim_tim_e { - HRTIM_TIMER_MASTER = 0, + HRTIM_TIMER_MASTER = (1<<0), #ifdef CONFIG_STM32_HRTIM_TIMA - HRTIM_TIMER_TIMA = 1, + HRTIM_TIMER_TIMA = (1<<1), #endif #ifdef CONFIG_STM32_HRTIM_TIMB - HRTIM_TIMER_TIMB = 2, + HRTIM_TIMER_TIMB = (1<<2), #endif #ifdef CONFIG_STM32_HRTIM_TIMC - HRTIM_TIMER_TIMC = 3, + HRTIM_TIMER_TIMC = (1<<3), #endif #ifdef CONFIG_STM32_HRTIM_TIMD - HRTIM_TIMER_TIMD = 4, + HRTIM_TIMER_TIMD = (1<<4), #endif #ifdef CONFIG_STM32_HRTIM_TIME - HRTIM_TIMER_TIME = 5, + HRTIM_TIMER_TIME = (1<<5), #endif - HRTIM_TIMER_COMMON = 6 + HRTIM_TIMER_COMMON = (1<<6) }; /* Source which can force the Tx1/Tx2 output to its inactive state */ @@ -332,62 +357,62 @@ enum stm32_hrtim_tim_rst_e { /* Timer owns events */ - HRTIM_RST_UPDT, - HRTIM_RST_CMP4, - HRTIM_RST_CMP2, + HRTIM_RST_UPDT = (1<<1), + HRTIM_RST_CMP4 = (1<<2), + HRTIM_RST_CMP2 = (1<<3), /* Master Timer Events */ - HRTIM_RST_MSTCMP4, - HRTIM_RST_MSTCMP3, - HRTIM_RST_MSTCMP2, - HRTIM_RST_MSTCMP1, - HRTIM_RST_MSTPER, + HRTIM_RST_MSTPER = (1<<4), + HRTIM_RST_MSTCMP1 = (1<<5), + HRTIM_RST_MSTCMP2 = (1<<6), + HRTIM_RST_MSTCMP3 = (1<<7), + HRTIM_RST_MSTCMP4 = (1<<8), - /* TimerX events */ + /* External Events */ - HRTIM_RST_TECMP4, - HRTIM_RST_TECMP2, - HRTIM_RST_TECMP1, - HRTIM_RST_TDCMP4, - HRTIM_RST_TDCMP2, - HRTIM_RST_TDCMP1, - HRTIM_RST_TCCMP4, - HRTIM_RST_TCCMP2, - HRTIM_RST_TCCMP1, - HRTIM_RST_TBCMP4, - HRTIM_RST_TBCMP2, - HRTIM_RST_TBCMP1, - HRTIM_RST_TACMP4, - HRTIM_RST_TACMP2, - HRTIM_RST_TACMP1, + HRTIM_RST_EXTEVNT1 = (1<<9), + HRTIM_RST_EXTEVNT2 = (1<<10), + HRTIM_RST_EXTEVNT3 = (1<<11), + HRTIM_RST_EXTEVNT4 = (1<<12), + HRTIM_RST_EXTEVNT5 = (1<<13), + HRTIM_RST_EXTEVNT6 = (1<<14), + HRTIM_RST_EXTEVNT7 = (1<<15), + HRTIM_RST_EXTEVNT8 = (1<<16), + HRTIM_RST_EXTEVNT9 = (1<<17), + HRTIM_RST_EXTEVNT10 = (1<<18), - /* External Events */ + /* TimerX events */ - HRTIM_RST_EXTEVNT10, - HRTIM_RST_EXTEVNT9, - HRTIM_RST_EXTEVNT8, - HRTIM_RST_EXTEVNT7, - HRTIM_RST_EXTEVNT6, - HRTIM_RST_EXTEVNT5, - HRTIM_RST_EXTEVNT4, - HRTIM_RST_EXTEVNT3, - HRTIM_RST_EXTEVNT2, - HRTIM_RST_EXTEVNT1 + HRTIM_RST_TACMP1 = (1<<19), + HRTIM_RST_TACMP2 = (1<<20), + HRTIM_RST_TACMP4 = (1<<21), + HRTIM_RST_TBCMP1 = (1<<22), + HRTIM_RST_TBCMP2 = (1<<23), + HRTIM_RST_TBCMP4 = (1<<24), + HRTIM_RST_TCCMP1 = (1<<25), + HRTIM_RST_TCCMP2 = (1<<26), + HRTIM_RST_TCCMP4 = (1<<27), + HRTIM_RST_TDCMP1 = (1<<28), + HRTIM_RST_TDCMP2 = (1<<29), + HRTIM_RST_TDCMP4 = (1<<30), + HRTIM_RST_TECMP1 = (1<<31), + HRTIM_RST_TECMP2 = (1<<32), + HRTIM_RST_TECMP4 = (1<<33), }; /* HRTIM Timer X prescaler */ enum stm32_hrtim_tim_prescaler_e { - HRTIM_PRESCALER_1, - HRTIM_PRESCALER_2, - HRTIM_PRESCALER_4, - HRTIM_PRESCALER_8, - HRTIM_PRESCALER_16, - HRTIM_PRESCALER_32, - HRTIM_PRESCALER_64, - HRTIM_PRESCALER_128 + HRTIM_PRESCALER_1, /* CKPSC = 0 */ + HRTIM_PRESCALER_2, /* CKPSC = 1 */ + HRTIM_PRESCALER_4, /* CKPSC = 2 */ + HRTIM_PRESCALER_8, /* CKPSC = 3 */ + HRTIM_PRESCALER_16, /* CKPSC = 4 */ + HRTIM_PRESCALER_32, /* CKPSC = 5 */ + HRTIM_PRESCALER_64, /* CKPSC = 6 */ + HRTIM_PRESCALER_128 /* CKPSC = 7 */ }; /* HRTIM Timer Master/Slave mode */ @@ -398,10 +423,6 @@ enum stm32_hrtim_mode_e HRTIM_MODE_HALF = (1 << 1), /* Half mode */ HRTIM_MODE_RETRIG = (1 << 2), /* Re-triggerable mode */ HRTIM_MODE_CONT = (1 << 3), /* Continuous mode */ - - /* Only slave Timers */ - - HRTIM_MODE_PSHPLL = (1 << 7), /* Push-Pull mode */ }; /* HRTIM Slave Timer auto-delayed mode @@ -571,7 +592,7 @@ enum stm32_outputs_e enum stm32_hrtim_deadtime_sign_e { HRTIM_DT_SIGN_POSITIVE = 0, - HRTIM_DT_DIGN_NEGATIVE = 1 + HRTIM_DT_SIGN_NEGATIVE = 1 }; /* HRTIM Deadtime types */ @@ -759,6 +780,21 @@ enum stm32_hrtim_dac_e HRTIM_DAC_TRIG3 = 3 }; +/* HRTIM Timer update events */ + +enum stm32_tim_update_e +{ + HRTIM_UPDATE_NONE = 0, + HRTIM_UPDATE_MSTU = (1 << 0), + HRTIM_UPDATE_TAU = (1 << 2), + HRTIM_UPDATE_TBU = (1 << 3), + HRTIM_UPDATE_TCU = (1 << 4), + HRTIM_UPDATE_TDU = (1 << 5), + HRTIM_UPDATE_TEU = (1 << 6), + HRTIM_UPDATE_RSTU = (1 << 7), + HRTIM_UPDATE_REPU = (1 << 8), +}; + /* HRTIM Master Timer interrupts */ enum stm32_irq_master_e @@ -967,12 +1003,22 @@ struct stm32_hrtim_ops_s uint16_t (*per_get)(FAR struct hrtim_dev_s *dev, uint8_t timer); uint16_t (*cmp_get)(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t index); + uint64_t (*fclk_get)(FAR struct hrtim_dev_s *dev, uint8_t timer); + int (*soft_update)(FAR struct hrtim_dev_s *dev, uint8_t timer); + int (*freq_set)(FAR struct hrtim_dev_s *hrtim, uint8_t timer, + uint64_t freq); + #ifdef CONFIG_STM32_HRTIM_INTERRUPTS - void (*irq_ack)(FAR struct hrtim_dev_s *dev, uint8_t timer, int source); + int (*irq_ack)(FAR struct hrtim_dev_s *dev, uint8_t timer, int source); + uint16_t (*irq_get)(FAR struct hrtim_dev_s *dev, uint8_t timer); #endif #ifdef CONFIG_STM32_HRTIM_PWM int (*outputs_enable)(FAR struct hrtim_dev_s *dev, uint16_t outputs, bool state); + int (*output_set_set)(FAR struct hrtim_dev_s *dev, uint16_t output, + uint32_t set); + int (*output_rst_set)(FAR struct hrtim_dev_s *dev, uint16_t output, + uint32_t rst); #endif #ifdef CONFIG_STM32_HRTIM_BURST int (*burst_enable)(FAR struct hrtim_dev_s *dev, bool state); @@ -988,8 +1034,10 @@ struct stm32_hrtim_ops_s uint8_t chan, bool state); #endif #ifdef CONFIG_STM32_HRTIM_DEADTIME - int (*deadtime_update)(FAR struct hrtim_dev_s *dev, uint8_t dt, uint16_t value); - uint16_t (*deadtime_get)(FAR struct hrtim_dev_s *dev, uint8_t dt); + int (*deadtime_update)(FAR struct hrtim_dev_s *dev, uint8_t timer, + uint8_t dt, uint16_t value); + uint16_t (*deadtime_get)(FAR struct hrtim_dev_s *dev, uint8_t timer, + uint8_t dt); #endif #ifdef CONFIG_STM32_HRTIM_CAPTURE uint16_t (*capture_get)(FAR struct hrtim_dev_s *dev, uint8_t timer, diff --git a/arch/arm/src/stm32/stm32_i2c.h b/arch/arm/src/stm32/stm32_i2c.h index f36ee952f55178cff12bc2a13fb95a6fb85a5182..c61f17332bda21440dcc8332569b40711d874124 100644 --- a/arch/arm/src/stm32/stm32_i2c.h +++ b/arch/arm/src/stm32/stm32_i2c.h @@ -79,7 +79,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -95,7 +95,7 @@ FAR struct i2c_master_s *stm32_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the stm32_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_i2s.c b/arch/arm/src/stm32/stm32_i2s.c index 46ac8f6eec3c7b0821baa4701a484193953be931..f68eb8683da8249c0a19f6dce4153fdd913f0fb0 100644 --- a/arch/arm/src/stm32/stm32_i2s.c +++ b/arch/arm/src/stm32/stm32_i2s.c @@ -2160,7 +2160,7 @@ errout_with_exclsem: * Setup the MCK divider based on the currently selected data width and * the sample rate * - * Input Parameter: + * Input Parameters: * priv - I2C device structure (only the sample rate and data length is * needed at this point). * @@ -2562,7 +2562,7 @@ static void i2s3_configure(struct stm32_i2s_s *priv) * Description: * Initialize the selected i2S port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple I2S interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_i2s.h b/arch/arm/src/stm32/stm32_i2s.h index 5e6d51b817f27a51b50c628663b149d6d56cb420..fc7a702b7e5f0424adc99149c6cb98a7ea4ba453 100644 --- a/arch/arm/src/stm32/stm32_i2s.h +++ b/arch/arm/src/stm32/stm32_i2s.h @@ -71,7 +71,7 @@ extern "C" * Description: * Initialize the selected I2S port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple I2S interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c index 98adf74f36c234c450c0566af39ff950e5eee81b..402351aafa264b10bd62efa25408c43b8eebd890 100644 --- a/arch/arm/src/stm32/stm32_irq.c +++ b/arch/arm/src/stm32/stm32_irq.c @@ -387,7 +387,7 @@ void up_irqinitialize(void) up_enable_irq(STM32_IRQ_MEMFAULT); #endif -#ifdef CONFIG_RTC +#if defined(CONFIG_RTC) && !defined(CONFIG_RTC_EXTERNAL) /* RTC was initialized earlier but IRQs weren't ready at that time */ stm32_rtc_irqinitialize(); diff --git a/arch/arm/src/stm32/stm32_iwdg.c b/arch/arm/src/stm32/stm32_iwdg.c index d26ec9f71a375f6c211c1e6c0a87f1c50b15b1e1..2ceaf9bd4bbf2327b59e95022a64016e510fbb32 100644 --- a/arch/arm/src/stm32/stm32_iwdg.c +++ b/arch/arm/src/stm32/stm32_iwdg.c @@ -315,7 +315,7 @@ static inline void stm32_setprescaler(FAR struct stm32_lowerhalf_s *priv) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -371,7 +371,7 @@ static int stm32_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -396,7 +396,7 @@ static int stm32_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -429,7 +429,7 @@ static int stm32_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * status - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -488,7 +488,7 @@ static int stm32_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -639,7 +639,7 @@ static int stm32_settimeout(FAR struct watchdog_lowerhalf_s *lower, * /dev/watchdog0 * lsifreq - The calibrated LSI clock frequency * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_ltdc.c b/arch/arm/src/stm32/stm32_ltdc.c index 5b794d17dd4ac2b2773c8886d5414705f0e7f454..9c798d1ab5c5ad7bddf8602763a1ec57f8138988 100644 --- a/arch/arm/src/stm32/stm32_ltdc.c +++ b/arch/arm/src/stm32/stm32_ltdc.c @@ -1162,7 +1162,7 @@ static int stm32_ltdcirq(int irq, void *context, FAR void *arg) * that a register reload was been completed. * Note! The caller must use this function within a critical section. * - * Return: + * Returned Value: * OK - On success otherwise ERROR * ****************************************************************************/ @@ -1457,7 +1457,7 @@ static inline uint8_t stm32_ltdc_lgetopac(FAR struct stm32_layer_s *layer) * Parameter: * layer - Reference to the layer control structure * - * Return: + * Returned Value: * true - layer valid * false - layer invalid * @@ -1487,7 +1487,7 @@ static inline bool stm32_ltdc_lvalidate(FAR const struct stm32_layer_s *layer) * srcxpos - Top left x position from where data visible in the active area * srcypos - Top left y position from where data visible in the active area * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1949,7 +1949,7 @@ static void stm32_ltdc_lenable(FAR struct stm32_layer_s *layer) } /**************************************************************************** - * Name stm32_ltdc_lclear + * Name: stm32_ltdc_lclear * * Description: * Clear the whole layer @@ -1958,7 +1958,7 @@ static void stm32_ltdc_lenable(FAR struct stm32_layer_s *layer) * layer - Reference to the layer control structure * color - The color to clear * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid * @@ -2172,7 +2172,7 @@ static void stm32_ltdc_linit(int lid) * vtable - The framebuffer driver object * vinfo - the videoinfo object * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2207,7 +2207,7 @@ static int stm32_getvideoinfo(struct fb_vtable_s *vtable, * vtable - The framebuffer driver object * pinfo - the planeinfo object * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2242,7 +2242,7 @@ static int stm32_getplaneinfo(struct fb_vtable_s *vtable, int planeno, * vtable - The framebuffer driver object * cmap - the color table * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2269,7 +2269,7 @@ static int stm32_getcmap(struct fb_vtable_s *vtable, * vtable - The framebuffer driver object * cmap - the color table * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2296,7 +2296,7 @@ static int stm32_putcmap(struct fb_vtable_s *vtable, * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2330,7 +2330,7 @@ static int stm32_lgetvideoinfo(struct ltdc_layer_s *layer, * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2364,7 +2364,7 @@ static int stm32_lgetplaneinfo(struct ltdc_layer_s *layer, int planeno, * layer - Reference to the layer structure * cmap - color lookup table with up the 256 entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2424,7 +2424,7 @@ static int stm32_setclut(struct ltdc_layer_s *layer, * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2523,7 +2523,7 @@ static int stm32_getclut(struct ltdc_layer_s *layer, * e.g. get the current active or inactive layer. * See LTDC_LAYER_* for possible values * - * Return: + * Returned Value: * OK - On success * Null if invalid flag * @@ -2600,7 +2600,7 @@ static int stm32_getlid(FAR struct ltdc_layer_s *layer, int *lid, * layer - Reference to the layer structure * argb - ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2636,7 +2636,7 @@ static int stm32_setcolor(FAR struct ltdc_layer_s *layer, uint32_t argb) * layer - Reference to the layer structure * argb - Reference to store the ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2673,7 +2673,7 @@ static int stm32_getcolor(FAR struct ltdc_layer_s *layer, uint32_t *argb) * layer - Reference to the layer structure * rgb - RGB888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2709,7 +2709,7 @@ static int stm32_setcolorkey(FAR struct ltdc_layer_s *layer, uint32_t rgb) * layer - Reference to the layer structure * rgb - Reference to store the RGB888 color key * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2750,7 +2750,7 @@ static int stm32_getcolorkey(FAR struct ltdc_layer_s *layer, uint32_t *rgb) * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2786,7 +2786,7 @@ static int stm32_setalpha(FAR struct ltdc_layer_s *layer, uint8_t alpha) * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2823,7 +2823,7 @@ static int stm32_getalpha(FAR struct ltdc_layer_s *layer, uint8_t *alpha) * layer - Reference to the layer structure * mode - Blend mode (see LTDC_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2955,7 +2955,7 @@ static int stm32_setblendmode(FAR struct ltdc_layer_s *layer, uint32_t mode) * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL ****************************************************************************/ @@ -2994,7 +2994,7 @@ static int stm32_getblendmode(FAR struct ltdc_layer_s *layer, uint32_t *mode) * srcxpos - x position of the visible pixel of the whole layer * srcypos - y position of the visible pixel of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -3056,7 +3056,7 @@ static int stm32_setarea(FAR struct ltdc_layer_s *layer, * srcxpos - Reference to store the referenced x position of the whole layer * srcypos - Reference to store the reterenced y position of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -3096,7 +3096,7 @@ static int stm32_getarea(FAR struct ltdc_layer_s *layer, * layer - Reference to the layer structure * mode - operation mode * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid * -ECANCELED - Operation cancelled, something goes wrong @@ -3259,7 +3259,7 @@ static int stm32_update(FAR struct ltdc_layer_s *layer, uint32_t mode) * src - Reference to the source layer * srcarea - Reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -3310,7 +3310,7 @@ static int stm32_blit(FAR struct ltdc_layer_s *dest, * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -3360,7 +3360,7 @@ static int stm32_blend(FAR struct ltdc_layer_s *dest, * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * area outside the visible area of the layer. @@ -3402,7 +3402,7 @@ static int stm32_fillarea(FAR struct ltdc_layer_s *layer, * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the layer control structure on success or Null if lid * is invalid. * @@ -3428,7 +3428,7 @@ FAR struct ltdc_layer_s *stm32_ltdcgetlayer(int lid) * Description: * Initialize the ltdc controller * - * Return: + * Returned Value: * OK * ****************************************************************************/ @@ -3517,10 +3517,10 @@ int stm32_ltdcinitialize(void) * Return a a reference to the framebuffer object for the specified video * plane. * - * Input parameters: + * Input Parameters: * None * - * Returned value: + * Returned Value: * Reference to the framebuffer object (NULL on failure) * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_ltdc.h b/arch/arm/src/stm32/stm32_ltdc.h index 33ebc3e5580e995df514c57c0381701d9205d9c4..7c73de31fe482d396f68b2081280eb74411888af 100644 --- a/arch/arm/src/stm32/stm32_ltdc.h +++ b/arch/arm/src/stm32/stm32_ltdc.h @@ -133,7 +133,7 @@ struct ltdc_layer_s * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -151,7 +151,7 @@ struct ltdc_layer_s * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -171,7 +171,7 @@ struct ltdc_layer_s * e.g. get the current active or inactive layer. * See LTDC_LAYER_* for possible values * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -192,7 +192,7 @@ struct ltdc_layer_s * enable - Enable or disable clut support (if false cmap is ignored and can * be NULL) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -210,7 +210,7 @@ struct ltdc_layer_s * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -229,7 +229,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * argb - ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -245,7 +245,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * argb - Reference to store the ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -263,7 +263,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * rgb - RGB888 color key * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -279,7 +279,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * rgb - Reference to store the RGB888 color key * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -301,7 +301,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -317,7 +317,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -335,7 +335,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * mode - Blend mode (see LTDC_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -373,7 +373,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -400,7 +400,7 @@ struct ltdc_layer_s * srcxpos - x position of the visible pixel of the whole layer * srcypos - y position of the visible pixel of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -426,7 +426,7 @@ struct ltdc_layer_s * srcxpos - Reference to store the referenced x position of the whole layer * srcypos - Reference to store the reterenced y position of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -445,7 +445,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * mode - operation mode (see LTDC_UPDATE_*) * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid * -ECANCELED - Operation cancelled, something goes wrong @@ -489,7 +489,7 @@ struct ltdc_layer_s * src - Reference to the source layer * srcarea - Reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -518,7 +518,7 @@ struct ltdc_layer_s * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -543,7 +543,7 @@ struct ltdc_layer_s * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * area outside the visible area of the layer. @@ -607,7 +607,7 @@ struct stm32_ltdc_s * Description: * Initialize the ltdc controller * - * Return: + * Returned Value: * OK * ************************************************************************************/ @@ -625,7 +625,7 @@ void stm32_ltdcuninitialize(void); * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the layer control structure on success or Null if parameter * invalid. * diff --git a/arch/arm/src/stm32/stm32_opamp.c b/arch/arm/src/stm32/stm32_opamp.c index e79e8ed8068845ea906423062e4e591446921173..e839bba863d452f5100c46177751baccb9d23311 100644 --- a/arch/arm/src/stm32/stm32_opamp.c +++ b/arch/arm/src/stm32/stm32_opamp.c @@ -1402,7 +1402,6 @@ FAR struct opamp_dev_s* stm32_opampinitialize(int intf) if (ret < 0) { aerr("ERROR: Failed to initialize OPAMP%d: %d\n", intf, ret); - errno = -ret; return NULL; } diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c index 8a6382d345b0bac1274828f69fc4ef199722c731..1b29ae09e5e66cfbcda18e69c37c70745546c5ed 100644 --- a/arch/arm/src/stm32/stm32_otgfshost.c +++ b/arch/arm/src/stm32/stm32_otgfshost.c @@ -1265,7 +1265,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1327,7 +1327,7 @@ static int stm32_ctrlep_alloc(FAR struct stm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3820,7 +3820,7 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3911,7 +3911,7 @@ static int stm32_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4041,7 +4041,7 @@ static int stm32_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4100,7 +4100,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4156,7 +4156,7 @@ static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4224,7 +4224,7 @@ static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4270,7 +4270,7 @@ static int stm32_alloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4306,7 +4306,7 @@ static int stm32_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4350,7 +4350,7 @@ static int stm32_ioalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4393,7 +4393,7 @@ static int stm32_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4596,7 +4596,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4668,7 +4668,7 @@ static ssize_t stm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4724,7 +4724,7 @@ static int stm32_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4813,7 +4813,7 @@ static int stm32_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4865,7 +4865,7 @@ static int stm32_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c index ad1091d02f76de61f65b18e9c77825710ea571db..c276742ab7e0dc39fe339628f57c405f3b8f8144 100644 --- a/arch/arm/src/stm32/stm32_otghshost.c +++ b/arch/arm/src/stm32/stm32_otghshost.c @@ -1270,7 +1270,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1332,7 +1332,7 @@ static int stm32_ctrlep_alloc(FAR struct stm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3825,7 +3825,7 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3916,7 +3916,7 @@ static int stm32_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4046,7 +4046,7 @@ static int stm32_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4105,7 +4105,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4161,7 +4161,7 @@ static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4229,7 +4229,7 @@ static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4275,7 +4275,7 @@ static int stm32_alloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4311,7 +4311,7 @@ static int stm32_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4355,7 +4355,7 @@ static int stm32_ioalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4398,7 +4398,7 @@ static int stm32_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4601,7 +4601,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4673,7 +4673,7 @@ static ssize_t stm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4729,7 +4729,7 @@ static int stm32_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4818,7 +4818,7 @@ static int stm32_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4870,7 +4870,7 @@ static int stm32_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32/stm32_pm.h b/arch/arm/src/stm32/stm32_pm.h index 7fc93ba688f9d324dfc550b647f217c550ffcb0d..8feee1f5666fc1ee29b618fc05475b1f01571b08 100644 --- a/arch/arm/src/stm32/stm32_pm.h +++ b/arch/arm/src/stm32/stm32_pm.h @@ -102,7 +102,7 @@ int stm32_pmstop(bool lpds); * Input Parameters: * None * - * Returned Value. + * Returned Value: * On success, this function will not return (STANDBY mode can only be * terminated with a reset event). Otherwise, STANDBY mode did not occur * and a negated errno value is returned to indicate the cause of the diff --git a/arch/arm/src/stm32/stm32_pminitialize.c b/arch/arm/src/stm32/stm32_pminitialize.c index e9b6d4780cb43c27cead52ed1293ac5866134e4d..243bc53aa4e7bce92750c80d3aabe4ed5e2839a2 100644 --- a/arch/arm/src/stm32/stm32_pminitialize.c +++ b/arch/arm/src/stm32/stm32_pminitialize.c @@ -76,10 +76,10 @@ * *before* any other device drivers are initialized (since they may * attempt to register with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_pmstandby.c b/arch/arm/src/stm32/stm32_pmstandby.c index 2b4de6a6f0ec407160bd8f8761b1e2da06c4f00a..952e14317fcd76f6a42b6df9d5de1435c1792003 100644 --- a/arch/arm/src/stm32/stm32_pmstandby.c +++ b/arch/arm/src/stm32/stm32_pmstandby.c @@ -71,7 +71,7 @@ * Input Parameters: * None * - * Returned Value. + * Returned Value: * On success, this function will not return (STANDBY mode can only be * terminated with a reset event). Otherwise, STANDBY mode did not occur * and a negated errno value is returned to indicate the cause of the diff --git a/arch/arm/src/stm32/stm32_pwm.c b/arch/arm/src/stm32/stm32_pwm.c index 0e9db5005947119a375cdffe2e31745a5498f9e3..7aadb98ae7278d4560483fff54e297ead1bb309e 100644 --- a/arch/arm/src/stm32/stm32_pwm.c +++ b/arch/arm/src/stm32/stm32_pwm.c @@ -1095,7 +1095,7 @@ static void pwm_putreg(struct stm32_pwmtimer_s *priv, int offset, uint16_t value * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -1182,7 +1182,7 @@ static void pwm_dumpregs(struct stm32_pwmtimer_s *priv, FAR const char *msg) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -1815,7 +1815,7 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv, * Description: * Try to change only channel duty. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * channel - Channel to by updated * duty - New duty. @@ -1897,7 +1897,7 @@ static int pwm_update_duty(FAR struct stm32_pwmtimer_s *priv, uint8_t channel, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * * Returned Value: @@ -1980,7 +1980,7 @@ static int pwm_interrupt(struct stm32_pwmtimer_s *priv) * Description: * Handle timer 1 and 8 interrupts. * - * Input parameters: + * Input Parameters: * Standard NuttX interrupt inputs * * Returned Value: @@ -2008,7 +2008,7 @@ static int pwm_tim8interrupt(int irq, void *context, FAR void *arg) * Description: * Pick an optimal pulse count to program the RCR. * - * Input parameters: + * Input Parameters: * count - The total count remaining * * Returned Value: @@ -2055,7 +2055,7 @@ static uint8_t pwm_pulsecount(uint32_t count) * Description: * Enable or disable APB clock for the timer peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -2188,7 +2188,7 @@ static void pwm_set_apb_clock(FAR struct stm32_pwmtimer_s *priv, bool on) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -2241,7 +2241,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -2303,7 +2303,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -2390,7 +2390,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -2549,7 +2549,7 @@ static int pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/stm32/stm32_pwr.c b/arch/arm/src/stm32/stm32_pwr.c index 04cf7e9387cb0efe3991a5571a15db67efb1467a..5a4b863b55db64a3eb018782ed9e251bb6e8864c 100644 --- a/arch/arm/src/stm32/stm32_pwr.c +++ b/arch/arm/src/stm32/stm32_pwr.c @@ -263,7 +263,7 @@ void stm32_pwr_enablebkp(bool writable) * wupin - Selects the WKUP pin to enable/disable * wupon - state to set it to * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned on any * failure. The only cause of failure is if the selected MCU does not support * the requested wakeup pin. @@ -359,7 +359,7 @@ bool stm32_pwr_getwuf(void) * Input Parameters: * regon - state to set it to * - * Returned Values: + * Returned Value: * None * ************************************************************************************/ @@ -390,7 +390,7 @@ void stm32_pwr_enablebreg(bool regon) * Input Parameters: * vos - Properly aligned voltage scaling select bits for the PWR_CR register. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -432,7 +432,7 @@ void stm32_pwr_setvos(uint16_t vos) * Input Parameters: * pls - PVD level * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32/stm32_pwr.h b/arch/arm/src/stm32/stm32_pwr.h index b93b34108cd66ec652549f5a0a3700b94fcf1268..ee56a40d18e5d8aca5f8cd3d6e465fdb481d8165 100644 --- a/arch/arm/src/stm32/stm32_pwr.h +++ b/arch/arm/src/stm32/stm32_pwr.h @@ -152,7 +152,7 @@ void stm32_pwr_enablebkp(bool writable); * wupin - Selects the WKUP pin to enable/disable * wupon - state to set it to * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned on any * failure. The only cause of failure is if the selected MCU does not support * the requested wakeup pin. @@ -195,7 +195,7 @@ bool stm32_pwr_getwuf(void); * Input Parameters: * regon - state to set it to * - * Returned Values: + * Returned Value: * None * ************************************************************************************/ @@ -215,7 +215,7 @@ void stm32_pwr_enablebreg(bool regon); * Input Parameters: * vos - Properly aligned voltage scaling select bits for the PWR_CR register. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -237,7 +237,7 @@ void stm32_pwr_setvos(uint16_t vos); * Input Parameters: * pls - PVD level * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c index 5bc98ad32296f5b7b40ed6f1003608a6cbbfe595..661e737f8a8e736f01a779109ee6a091255fb132 100644 --- a/arch/arm/src/stm32/stm32_qencoder.c +++ b/arch/arm/src/stm32/stm32_qencoder.c @@ -574,7 +574,7 @@ static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset, uint3 * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the QENCODER block status * * Returned Value: @@ -1173,7 +1173,7 @@ static int stm32_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, unsigned long * devpath - The full path to the driver to register. E.g., "/dev/qe0" * tim - The timer number to used. 'tim' must be an element of {1,2,3,4,5,8} * - * Returned Values: + * Returned Value: * Zero on success; A negated errno value is returned on failure. * ************************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_qencoder.h b/arch/arm/src/stm32/stm32_qencoder.h index bea28531b6722f1a9ae9dc81ad54f98027a2994e..98c5b25f11c7bcdaf0e1a6958c746be3a8dbbae2 100644 --- a/arch/arm/src/stm32/stm32_qencoder.h +++ b/arch/arm/src/stm32/stm32_qencoder.h @@ -130,7 +130,7 @@ * devpath - The full path to the driver to register. E.g., "/dev/qe0" * tim - The timer number to used. 'tim' must be an element of {1,2,3,4,5,8} * - * Returned Values: + * Returned Value: * Zero on success; A negated errno value is returned on failure. * ************************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_sdadc.c b/arch/arm/src/stm32/stm32_sdadc.c index e8236a05f93cb247eec7aee1b48dfb2929bc7823..67e348c81d05dc04d3e4e775298441624516785b 100644 --- a/arch/arm/src/stm32/stm32_sdadc.c +++ b/arch/arm/src/stm32/stm32_sdadc.c @@ -456,7 +456,7 @@ static void tim_modifyreg(FAR struct stm32_dev_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the SDADC block state * * Returned Value: @@ -629,7 +629,8 @@ static void sdadc_rccreset(FAR struct stm32_dev_s *priv, bool reset) /**************************************************************************** * Name: sdadc_power_down_idle * - * Description : Enables or disables power down during the idle phase. + * Description: + * Enables or disables power down during the idle phase. * * Input Parameters: * priv - A reference to the SDADC block state @@ -670,7 +671,8 @@ static void sdadc_power_down_idle(FAR struct stm32_dev_s *priv, bool pdi_high) /**************************************************************************** * Name: sdadc_enable * - * Description : Enables or disables the specified SDADC peripheral. + * Description: + * Enables or disables the specified SDADC peripheral. * Does not start conversion unless the SDADC is * triggered by timer * diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c index 31ecd08604c3c5d4fd4d731cc789f8f09d45d2c2..1d9f99e72b2996366c3463ad440fdbb41552c4f7 100644 --- a/arch/arm/src/stm32/stm32_sdio.c +++ b/arch/arm/src/stm32/stm32_sdio.c @@ -2500,7 +2500,7 @@ static sdio_eventset_t stm32_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)stm32_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2954,7 +2954,7 @@ static void stm32_default(void) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -3028,7 +3028,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -3075,7 +3075,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_sdio.h b/arch/arm/src/stm32/stm32_sdio.h index 04c65ba00f975b35761ef391016503ecb9e5c22d..4fc477a0e44d2cf5e81839d24377cb525f6ccf9a 100644 --- a/arch/arm/src/stm32/stm32_sdio.h +++ b/arch/arm/src/stm32/stm32_sdio.h @@ -71,7 +71,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -93,7 +93,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -111,7 +111,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 74b70ffd0617aaa5c2b73b50f575bd0844c52a8f..a14404835b9899127329d50204790779592d3229 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -1381,7 +1381,7 @@ static void up_set_format(struct uart_dev_s *dev) * Description: * Enable or disable APB clock for the USART peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the UART driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -2274,7 +2274,7 @@ static bool up_rxavailable(struct uart_dev_s *dev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index 71f6dbfb3a5796e3352f1c11d08df7403f2fd4ca..585a3e9231cd626533916ee60f946c4687d3ec5a 100644 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/arch/arm/src/stm32/stm32_spi.c @@ -1122,13 +1122,6 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency) uint16_t setbits; uint32_t actual; - /* Limit to max possible (if STM32_SPI_CLK_MAX is defined in board.h) */ - - if (frequency > STM32_SPI_CLK_MAX) - { - frequency = STM32_SPI_CLK_MAX; - } - /* Has the frequency changed? */ if (frequency != priv->frequency) @@ -1677,7 +1670,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t * Description: * Initialize the selected SPI bus in its default state (Master, 8-bit, mode 0, etc.) * - * Input Parameter: + * Input Parameters: * priv - private SPI device structure * * Returned Value: @@ -1782,7 +1775,7 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_spi.h b/arch/arm/src/stm32/stm32_spi.h index ee99808c6abbee3f0eb8baa843f150ca327ede21..bcc2f0e14bb68c8aa17407b7f781a37c138359cc 100644 --- a/arch/arm/src/stm32/stm32_spi.h +++ b/arch/arm/src/stm32/stm32_spi.h @@ -78,7 +78,7 @@ struct spi_dev_s; * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * bus number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32/stm32_tim.h b/arch/arm/src/stm32/stm32_tim.h index bc6ef090c62a94740aefbdb0dabfe131250fe744..2e0828fafa27326e18d4991d07cb18e6cd0dcfd5 100644 --- a/arch/arm/src/stm32/stm32_tim.h +++ b/arch/arm/src/stm32/stm32_tim.h @@ -208,7 +208,7 @@ int stm32_tim_deinit(FAR struct stm32_tim_dev_s *dev); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - the timer number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/stm32/stm32_tim_lowerhalf.c b/arch/arm/src/stm32/stm32_tim_lowerhalf.c index d8415ac040569c34c9c50eb6d20ae0af1cc7e009..d0a9619517e2e6d2fb9c7ec7d48cfe6375ed1fa1 100644 --- a/arch/arm/src/stm32/stm32_tim_lowerhalf.c +++ b/arch/arm/src/stm32/stm32_tim_lowerhalf.c @@ -261,7 +261,7 @@ static struct stm32_lowerhalf_s g_tim14_lowerhalf = * * Input Parameters: * - * Returned Values: + * Returned Value: * ****************************************************************************/ @@ -297,7 +297,7 @@ static int stm32_timer_handler(int irq, void * context, void * arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -335,7 +335,7 @@ static int stm32_start(FAR struct timer_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -369,7 +369,7 @@ static int stm32_stop(struct timer_lowerhalf_s *lower) * driver state structure. * timeout - The new timeout value in microseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -414,7 +414,7 @@ static int stm32_settimeout(FAR struct timer_lowerhalf_s *lower, uint32_t timeou * behavior is restored, * arg - Argument that will be provided in the callback * - * Returned Values: + * Returned Value: * The previous timer expiration function pointer or NULL is there was * no previous function pointer. * @@ -462,7 +462,7 @@ static void stm32_setcallback(FAR struct timer_lowerhalf_s *lower, * form /dev/timer0 * timer - the timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/stm32/stm32_wdg.h b/arch/arm/src/stm32/stm32_wdg.h index 64815bfe908dc66576aa95528550a7406d05a07e..264734b9f53bcdc63f5829188fc56bb78f666ea3 100644 --- a/arch/arm/src/stm32/stm32_wdg.h +++ b/arch/arm/src/stm32/stm32_wdg.h @@ -79,7 +79,7 @@ extern "C" * /dev/watchdog0 * lsifreq - The calibrated LSI clock frequency * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -100,7 +100,7 @@ void stm32_iwdginitialize(FAR const char *devpath, uint32_t lsifreq); * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_wwdg.c b/arch/arm/src/stm32/stm32_wwdg.c index 79d34656dae29aeb710c5aaed5fe0769ef242d03..ba2b994fa40840b8c47b354042ad56af4f977d92 100644 --- a/arch/arm/src/stm32/stm32_wwdg.c +++ b/arch/arm/src/stm32/stm32_wwdg.c @@ -281,7 +281,7 @@ static void stm32_setwindow(FAR struct stm32_lowerhalf_s *priv, uint8_t window) * Input Parameters: * Usual interrupt handler arguments. * - * Returned Values: + * Returned Value: * Always returns OK. * ****************************************************************************/ @@ -329,7 +329,7 @@ static int stm32_interrupt(int irq, FAR void *context, FAR void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -361,7 +361,7 @@ static int stm32_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -395,7 +395,7 @@ static int stm32_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -426,7 +426,7 @@ static int stm32_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * status - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -482,7 +482,7 @@ static int stm32_getstatus(FAR struct watchdog_lowerhalf_s *lower, * "lower-half" driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -618,7 +618,7 @@ static int stm32_settimeout(FAR struct watchdog_lowerhalf_s *lower, * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous watchdog expiration function pointer or NULL is there was * no previous function pointer, i.e., if the previous behavior was * reset-on-expiration (NULL is also returned if an error occurs). @@ -686,7 +686,7 @@ static xcpt_t stm32_capture(FAR struct watchdog_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -742,7 +742,7 @@ static int stm32_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32f10xxx_dma.c b/arch/arm/src/stm32/stm32f10xxx_dma.c index c3c666e937b5a4deced4a2dc36b7f92f83819de9..72da836ad1b561c0abf4d4ab38b91351d8c022b9 100644 --- a/arch/arm/src/stm32/stm32f10xxx_dma.c +++ b/arch/arm/src/stm32/stm32f10xxx_dma.c @@ -395,7 +395,7 @@ void weak_function up_dmainitialize(void) * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * chndx - Identifies the stream/channel resource. For the STM32 F1, this * is simply the channel number as provided by the DMACHAN_* definitions * in chip/stm32f10xxx_dma.h. @@ -626,7 +626,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle) * of the processor. Note that this only applies to memory addresses, it * will return false for any peripheral address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32f20xxx_dma.c b/arch/arm/src/stm32/stm32f20xxx_dma.c index 8c06819f7a5db56e83bf8f605713d501a2225245..86b95f7f1379c2244d51fb385c73d466d583488b 100644 --- a/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/arch/arm/src/stm32/stm32f20xxx_dma.c @@ -525,7 +525,7 @@ void weak_function up_dmainitialize(void) * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * dmamap - Identifies the stream/channel resource. For the STM32 F2, this * is a bit-encoded value as provided by the DMAMAP_* definitions * in chip/stm32f20xxx_dma.h @@ -856,7 +856,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle) * of the processor. Note that this only applies to memory addresses, it * will return false for any peripheral address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32f33xxx_adc.c b/arch/arm/src/stm32/stm32f33xxx_adc.c index 4eb887e1484a97afea75710a57901079269086e6..b75641c27af4025af20198ce85d57ebb63179c6b 100644 --- a/arch/arm/src/stm32/stm32f33xxx_adc.c +++ b/arch/arm/src/stm32/stm32f33xxx_adc.c @@ -804,7 +804,7 @@ static void tim_modifyreg(FAR struct stm32_dev_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the ADC block status * * Returned Value: @@ -1350,9 +1350,9 @@ static void adc_rccreset(FAR struct stm32_dev_s *priv, bool reset) /**************************************************************************** * Name: adc_enable * - * Description : Enables or disables the specified ADC peripheral. - * Also, starts a conversion when the ADC is not - * triggered by timers + * Description: + * Enables or disables the specified ADC peripheral. Also, starts a + * conversion when the ADC is not triggered by timers * * Input Parameters: * diff --git a/arch/arm/src/stm32/stm32f33xxx_dma.c b/arch/arm/src/stm32/stm32f33xxx_dma.c index af091e2fec6c4278df7634e10673432878589627..1c0c626e601abab15c1fb1f7666f2d188c22f966 100644 --- a/arch/arm/src/stm32/stm32f33xxx_dma.c +++ b/arch/arm/src/stm32/stm32f33xxx_dma.c @@ -343,7 +343,7 @@ void weak_function up_dmainitialize(void) * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * chndx - Identifies the stream/channel resource. For the STM32 F1, this * is simply the channel number as provided by the DMACHAN_* definitions * in chip/stm32f10xxx_dma.h. @@ -574,7 +574,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle) * of the processor. Note that this only applies to memory addresses, it * will return false for any peripheral address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32f40xxx_dma.c b/arch/arm/src/stm32/stm32f40xxx_dma.c index 6dedd5a337de43551eb6624533eca765e8a5adb3..7f528f1a330e471eb1e0bd22f5126cd9dc3a42d8 100644 --- a/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -524,7 +524,7 @@ void weak_function up_dmainitialize(void) * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * dmamap - Identifies the stream/channel resource. For the STM32 F4, this * is a bit-encoded value as provided by the DMAMAP_* definitions * in chip/stm32f40xxx_dma.h @@ -863,7 +863,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle) * of the processor. Note that this only applies to memory addresses, it * will return false for any peripheral address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c index 86de66e7f56ccc3967845e01fe2c3b1ef8ed7e52..ac3c85adc00bbd08968cc2de39356c89eae3719a 100644 --- a/arch/arm/src/stm32/stm32f40xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c @@ -270,7 +270,6 @@ struct stm32_i2c_priv_s volatile int dcnt; /* Current message length */ uint16_t flags; /* Current message flags */ bool check_addr_ACK; /* Flag to signal if on next interrupt address has ACKed */ - uint8_t total_msg_len; /* Flag to signal a short read sequence */ /* I2C trace support */ @@ -1260,27 +1259,6 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) priv->status = status; - /* Any new message should begin with "Start" condition - * However there were 2 situations where that was not true - * Situation 1: priv->msgc == 0 came from DMA RX handler and should - * be managed - * - * Situation 2: If an error is injected that looks like a STOP the - * interrupt will be reentered with some status that will be incorrect. This - * will ensure that the error handler will clear the interrupt enables and - * return the error to the waiting task. - */ - - if (priv->dcnt == -1 && priv->msgc != 0 && (status & I2C_SR1_SB) == 0) - { -#ifdef CONFIG_STM32_I2C_DMA - return OK; -#else - priv->status |= I2C_SR1_TIMEOUT; - goto state_error; -#endif - } - /* Check if this is a new transmission so to set up the * trace table accordingly. */ @@ -1327,13 +1305,33 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) if (priv->dcnt == -1 && priv->msgc > 0) { + /* Any new message should begin with "Start" condition + * However there were 2 situations where that was not true + * Situation 1: Next message continue transmission sequence of previous message + * + * Situation 2: If an error is injected that looks like a STOP the + * interrupt will be reentered with some status that will be incorrect. This + * will ensure that the error handler will clear the interrupt enables and + * return the error to the waiting task. + */ + + if (((priv->msgv[0].flags & I2C_M_NORESTART) != 0 && (status & I2C_SR1_TXE) == 0) || + ((priv->msgv[0].flags & I2C_M_NORESTART) == 0 && (status & I2C_SR1_SB) == 0)) + { +#if defined(CONFIG_STM32_I2C_DMA) || defined(CONFIG_I2C_POLLED) + return OK; +#else + priv->status |= I2C_SR1_TIMEOUT; + goto state_error; +#endif + } + i2cinfo("Switch to new message\n"); /* Get current message to process data and copy to private structure */ priv->ptr = priv->msgv->buffer; /* Copy buffer to private struct */ priv->dcnt = priv->msgv->length; /* Set counter of current msg length */ - priv->total_msg_len = priv->msgv->length; /* Set total msg length */ priv->flags = priv->msgv->flags; /* Copy flags to private struct */ i2cinfo("Current flags %i\n", priv->flags); @@ -1435,9 +1433,11 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) priv->dcnt = -1; +#ifndef CONFIG_I2C_POLLED /* Restart ISR by setting an interrupt buffer bit */ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_ITBUFEN); +#endif } } @@ -1504,10 +1504,6 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) priv->check_addr_ACK = false; - /* Enable RxNE and TxE buffers in order to receive one or multiple bytes */ - - stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_ITBUFEN); - /* Note: * * When reading a single byte the stop condition has to be set @@ -1518,7 +1514,7 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * after the clearing of the address. */ - if (priv->dcnt == 1 && priv->total_msg_len == 1) + if (priv->dcnt == 1) { /* this should only happen when receiving a message of length 1 */ @@ -1532,6 +1528,12 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) stm32_i2c_modifyreg(priv, STM32_I2C_CR1_OFFSET, I2C_CR1_ACK, 0); +#ifndef CONFIG_I2C_POLLED + /* Enable RxNE and TxE buffers in order to receive one or multiple bytes */ + + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_ITBUFEN); +#endif + /* Clear ADDR flag by reading SR2 and adding it to status */ status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16); @@ -1554,7 +1556,7 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) stm32_i2c_traceevent(priv, I2CEVENT_ADDRESS_ACKED_READ_1, 0); } - else if (priv->dcnt == 2 && priv->total_msg_len == 2) + else if (priv->dcnt == 2) { /* This should only happen when receiving a message of length 2 */ @@ -1627,6 +1629,15 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) stm32_dmastart(priv->rxdma, stm32_i2c_dmarxcallback, priv, false); stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_DMAEN); +#else +#ifndef CONFIG_I2C_POLLED + if (priv->dcnt > 3) + { + /* Don't enable I2C_CR2_ITBUFEN for messages longer than 3 bytes */ + + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_ITBUFEN); + } +#endif #endif } } @@ -1638,8 +1649,60 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * begin immediately after. */ - else if ((priv->flags & (I2C_M_READ)) == 0 && - (status & (I2C_SR1_ADDR | I2C_SR1_TXE)) != 0) + else if ((priv->flags & I2C_M_READ) == 0 && + (status & I2C_SR1_BTF) != 0 && + priv->dcnt == 0) + { + /* After last byte, check what to do based on next message flags */ + + if (priv->msgc == 0) + { + /* If last message send stop bit */ + + stm32_i2c_sendstop(priv); + i2cinfo("Stop sent dcnt = %i msgc = %i\n", priv->dcnt, priv->msgc); + + /* Decrease counter to get to next message */ + + priv->dcnt--; + i2cinfo("dcnt %i\n", priv->dcnt); + stm32_i2c_traceevent(priv, I2CEVENT_WRITE_STOP, priv->dcnt); + } + + /* If there is a next message with no flags or the read flag + * a restart sequence has to be sent. + * Note msgv already points to the next message. + */ + + else if (priv->msgc > 0 && + (priv->msgv->flags == 0 || (priv->msgv[0].flags & I2C_M_READ) != 0)) + { + /* Send start */ + + stm32_i2c_sendstart(priv); + + stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); + + i2cinfo("Restart detected!\n"); + i2cinfo("Nextflag %i\n", priv->msgv[0].flags); + + /* Decrease counter to get to next message */ + + priv->dcnt--; + i2cinfo("dcnt %i\n", priv->dcnt); + stm32_i2c_traceevent(priv, I2CEVENT_WRITE_RESTART, priv->dcnt); + } + else + { + i2cinfo("Write mode: next message has an unrecognized flag.\n"); + stm32_i2c_traceevent(priv, I2CEVENT_WRITE_FLAG_ERROR, priv->msgv->flags); + } + + status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16); + } + else if ((priv->flags & I2C_M_READ) == 0 && + (status & (I2C_SR1_ADDR | I2C_SR1_TXE)) != 0 && + priv->dcnt != 0) { /* The has cleared(ADDR is set, ACK was received after the address) * or the transmit buffer is empty flag has been set(TxE) then we can @@ -1662,134 +1725,101 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * msg flags) has to be set. */ - if (priv->dcnt >= 1) - { #ifdef CONFIG_STM32_I2C_DMA - /* if DMA is enabled, only makes sense to make use of it for longer - than 1 B transfers.. */ + /* if DMA is enabled, only makes sense to make use of it for longer + * than 1 B transfers. + */ - if (priv->dcnt > 1) - { - i2cinfo("Starting dma transfer and disabling interrupts\n"); + if (priv->dcnt > 1) + { + i2cinfo("Starting DMA transfer and disabling interrupts\n"); - /* The DMA must be initialized and enabled before the I2C data transfer. - * The DMAEN bit must be set in the I2C_CR2 register before the ADDR event. - */ + /* The DMA must be initialized and enabled before the I2C data + * transfer. The DMAEN bit must be set in the I2C_CR2 register + * before the ADDR event. + */ - stm32_dmasetup(priv->txdma, priv->config->base+STM32_I2C_DR_OFFSET, - (uint32_t) priv->ptr, priv->dcnt, - DMA_SCR_DIR_M2P | - DMA_SCR_MSIZE_8BITS | - DMA_SCR_PSIZE_8BITS | - DMA_SCR_MINC | - I2C_DMA_PRIO ); + stm32_dmasetup(priv->txdma, priv->config->base+STM32_I2C_DR_OFFSET, + (uint32_t) priv->ptr, priv->dcnt, + DMA_SCR_DIR_M2P | + DMA_SCR_MSIZE_8BITS | + DMA_SCR_PSIZE_8BITS | + DMA_SCR_MINC | + I2C_DMA_PRIO ); - /* Do not enable the ITBUFEN bit in the I2C_CR2 register if DMA is - * used. - */ + /* Do not enable the ITBUFEN bit in the I2C_CR2 register if DMA is + * used. + */ - stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_ITBUFEN, 0); + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_ITBUFEN, 0); #ifndef CONFIG_I2C_POLLED - /* Now let DMA do all the work, disable i2c interrupts */ + /* Now let DMA do all the work, disable i2c interrupts */ - regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET); - regval &= ~I2C_CR2_ALLINTS; - stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval); + regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET); + regval &= ~I2C_CR2_ALLINTS; + stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval); #endif - /* In the interrupt routine after the EOT interrupt, disable DMA - * requests then wait for a BTF event before programming the Stop - * condition. To do this, we'll just call the ISR again in - * dma tx callback, in which point we fall into the msgc==0 case - * which ultimately sends the stop..TODO: but we don't explicitly - * wait for BTF bit being set... - * Start DMA. - */ - - stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_DMAEN); - stm32_dmastart(priv->txdma, stm32_i2c_dmatxcallback, priv, false); - } - else -#endif /* CONFIG_STM32_I2C_DMA */ - { - /* Transmitting message. Send byte == write data into write register */ - - stm32_i2c_putreg(priv, STM32_I2C_DR_OFFSET, *priv->ptr++); - - /* Decrease current message length */ + /* In the interrupt routine after the EOT interrupt, disable DMA + * requests then wait for a BTF event before programming the Stop + * condition. To do this, we'll just call the ISR again in + * DMA tx callback, in which point we fall into the msgc==0 case + * which ultimately sends the stop..TODO: but we don't explicitly + * wait for BTF bit being set... + * Start DMA. + */ - stm32_i2c_traceevent(priv, I2CEVENT_WRITE_TO_DR, priv->dcnt); - priv->dcnt--; - } + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_DMAEN); + stm32_dmastart(priv->txdma, stm32_i2c_dmatxcallback, priv, false); } - else if (priv->dcnt == 0) + else +#endif /* CONFIG_STM32_I2C_DMA */ { - /* After last byte, check what to do based on next message flags */ - - if (priv->msgc == 0) +#ifndef CONFIG_I2C_POLLED + if (priv->dcnt == 1 && + (priv->msgc == 0 || (priv->msgv->flags & I2C_M_NORESTART) == 0)) { - /* If last message send stop bit */ - - stm32_i2c_sendstop(priv); - i2cinfo("Stop sent dcnt = %i msgc = %i\n", priv->dcnt, priv->msgc); - - /* Decrease counter to get to next message */ - - priv->dcnt--; - i2cinfo("dcnt %i\n", priv->dcnt); - stm32_i2c_traceevent(priv, I2CEVENT_WRITE_STOP, priv->dcnt); + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_ITBUFEN, 0); } +#endif - /* If there is a next message with no flags or the read flag - * a restart sequence has to be sent. - * Note msgv already points to the next message. - */ + /* Transmitting message. Send byte == write data into write register */ - else if (priv->msgc > 0 && - (priv->msgv->flags == 0 || (priv->msgv[0].flags & I2C_M_READ) != 0)) - { - /* ACK ISR (for some reason this is necessary even though the - * sendstart should clear the BTF). - */ + stm32_i2c_putreg(priv, STM32_I2C_DR_OFFSET, *priv->ptr++); - stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); + /* Decrease current message length */ - /* Send start */ + stm32_i2c_traceevent(priv, I2CEVENT_WRITE_TO_DR, priv->dcnt); + priv->dcnt--; - stm32_i2c_sendstart(priv); + if ((status & I2C_SR1_ADDR) != 0 && priv->dcnt > 0) + { + /* Transmitting message. ADDR -> BTF & TXE - Send one more byte */ - i2cinfo("Restart detected!\n"); - i2cinfo("Nextflag %i\n", priv->msgv[0].flags); + stm32_i2c_putreg(priv, STM32_I2C_DR_OFFSET, *priv->ptr++); - /* Decrease counter to get to next message */ + /* Decrease current message length */ + stm32_i2c_traceevent(priv, I2CEVENT_WRITE_TO_DR, priv->dcnt); priv->dcnt--; - i2cinfo("dcnt %i\n", priv->dcnt); - stm32_i2c_traceevent(priv, I2CEVENT_WRITE_RESTART, priv->dcnt); } - /* If there is a next message with the NO_RESTART flag - * do nothing. - */ - - else if (priv->msgc > 0 && ((priv->msgv->flags & I2C_M_NORESTART) != 0)) +#ifndef CONFIG_I2C_POLLED + if (((status & I2C_SR1_ADDR) != 0 && priv->dcnt > 0) || + (priv->msgc > 0 && (priv->msgv->flags & I2C_M_NORESTART) != 0)) + { + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_ITBUFEN); + } +#endif + if (priv->dcnt == 0 && + priv->msgc > 0 && (priv->msgv->flags & I2C_M_NORESTART) != 0) { /* Set condition to get to next message */ priv->dcnt =- 1; stm32_i2c_traceevent(priv, I2CEVENT_WRITE_NO_RESTART, priv->dcnt); } - else - { - i2cinfo("Write mode: next message has an unrecognized flag.\n"); - stm32_i2c_traceevent(priv, I2CEVENT_WRITE_FLAG_ERROR, priv->msgv->flags); - } - } - else - { - i2cerr("Write mode error.\n"); - stm32_i2c_traceevent(priv, I2CEVENT_WRITE_ERROR, 0); } } @@ -1798,6 +1828,7 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * Handles all read related I2C protocol logic. * * * * * * * * WARNING STM32F1xx HARDWARE ERRATA * * * * * * * + * * source: https://github.com/hikob/openlab/blob/master/drivers/stm32/i2c.c * * RXNE-only events should not be handled since it sometimes @@ -1820,172 +1851,67 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * -> the i2c transfer was B1 B2 B3 B4 B5(B6 is not sent) */ - else if ((priv->flags & (I2C_M_READ)) != 0 && (status & I2C_SR1_RXNE) != 0) + else if ((priv->flags & (I2C_M_READ)) != 0 && + (status & (I2C_SR1_RXNE | I2C_SR1_BTF)) != 0) { /* When read flag is set and the receive buffer is not empty *(RXNE is set) then the driver can read from the data register. */ - i2cinfo("Entering read mode dcnt = %i msgc = %i, status %i\n", + status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16); + + i2cinfo("Entering read mode dcnt = %i msgc = %i, status 0x%04x\n", priv->dcnt, priv->msgc, status); - /* Implementation of method 2 for receiving data following - * the stm32f1xx reference manual. + /* Byte #N-3W, we don't want to manage RxNE interrupt anymore, bytes + * N, N-1, N-2 will be read with BTF: */ - /* Case total message length = 1 */ - - if (priv->dcnt == 1 && priv->total_msg_len == 1) +#ifndef CONFIG_I2C_POLLED + if (priv->dcnt < 5) { - i2cinfo("short read N=1: Read data from data register(DR)\n"); - - *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - priv->dcnt = -1; - stm32_i2c_traceevent(priv, I2CEVENT_READ, 0); - } - - /* Case total message length = 2 */ - - else if (priv->dcnt == 2 && priv->total_msg_len == 2 && !(status & I2C_SR1_BTF)) - { - i2cinfo("short read N=2: DR full, SR empty. Waiting for more bytes.\n"); - stm32_i2c_traceevent(priv, I2CEVENT_READ_SR_EMPTY, 0); + stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_ITBUFEN, 0); } - else if (priv->dcnt == 2 && priv->total_msg_len == 2 && (status & I2C_SR1_BTF)) +#else + if (priv->dcnt == 1 || priv->dcnt > 3 || (status & I2C_SR1_BTF) != 0) +#endif { - i2cinfo("short read N=2: DR and SR full setting stop bit and reading twice\n"); - - /* Send Stop/Restart */ + /* BTF: N-2/N-1, set NACK, read N-2 */ - if (priv->msgc > 0) - { - stm32_i2c_sendstart(priv); - } - else + if (priv->dcnt == 3) { - stm32_i2c_sendstop(priv); + stm32_i2c_modifyreg(priv, STM32_I2C_CR1_OFFSET, I2C_CR1_ACK, 0); } - *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - priv->dcnt--; - *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - priv->dcnt--; - - /* Stop request already programmed so set dcnt for next message */ - - priv->dcnt--; - - /* Set trace */ - - stm32_i2c_traceevent(priv, I2CEVENT_READ_2, 0); - } + /* BTF: N-1/N, STOP/START, read N-1, N */ -#ifndef CONFIG_STM32_I2C_DMA - /* Case total message length >= 3 */ - - else if (priv->dcnt >= 4 && priv->total_msg_len >= 3) - { - /* Read data from data register(DR). Note this clears the - * RXNE(receive buffer not empty) flag. - */ - - i2cinfo("Read data from data register(DR)\n"); - *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - - /* Decrease current message length */ - - priv->dcnt--; - stm32_i2c_traceevent(priv, I2CEVENT_READ, 0); - } - else if (priv->dcnt == 3 && priv->total_msg_len >= 3 && !(status & I2C_SR1_BTF)) - { - i2cinfo("short read N=3: DR full, SR empty. Waiting for more bytes.\n"); - stm32_i2c_traceevent(priv, I2CEVENT_READ_SR_EMPTY, 0); - } - else if (priv->dcnt == 3 && (status & I2C_SR1_BTF) && priv->total_msg_len >= 3) - { - /* This means that we are reading dcnt 3 and there is already dcnt 2 in - * the shift register. - * This coincides with EV7_1 in the reference manual. - */ - - i2cinfo("Program NACK\n"); - i2cinfo("Read data from data register(DR) dcnt=3\n"); - - stm32_i2c_traceevent(priv, I2CEVENT_READ_3, priv->dcnt); - - /* Program NACK */ - - stm32_i2c_modifyreg(priv, STM32_I2C_CR1_OFFSET, I2C_CR1_ACK, 0); + else if (priv->dcnt == 2) + { + if (priv->msgc > 0) + { + stm32_i2c_sendstart(priv); + } + else + { + stm32_i2c_sendstop(priv); + } + + /* Read byte #N-1 */ + + *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); + priv->dcnt--; + } - /* Read dcnt = 3, to ensure a BTF event after having recieved - * in the shift register. - */ + /* Read last or current byte */ *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - - /* Decrease current message length */ - priv->dcnt--; - } - else if (priv->dcnt == 2 && priv->total_msg_len >= 3 && !(status & I2C_SR1_BTF)) - { - i2cinfo("short read N=3: DR full, SR empty. Waiting for more bytes.\n"); - stm32_i2c_traceevent(priv, I2CEVENT_READ_SR_EMPTY, 0); - } - else if (priv->dcnt == 2 && (status & I2C_SR1_BTF) && priv->total_msg_len >= 3) - { - i2cinfo("Program stop\n"); - i2cinfo("Read data from data register(DR) dcnt=2\n"); - i2cinfo("Read data from data register(SR) dcnt=1\n"); - i2cinfo("Setting condition to stop ISR dcnt = -1\n"); - - stm32_i2c_traceevent(priv, I2CEVENT_READ_3, priv->dcnt); - /* Program Stop/Restart */ - - if (priv->msgc > 0) + if (priv->dcnt == 0) { - stm32_i2c_sendstart(priv); + priv->dcnt = -1; } - else - { - stm32_i2c_sendstop(priv); - } - - /* read dcnt = 2 */ - - *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - - /* read last byte dcnt=1 */ - - *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); - - /* Stop already sent will not get another interrupt set - * condition to stop ISR - */ - - priv->dcnt = -1; - } -#endif /* CONFIG_STM32_I2C_DMA */ - - /* Error handling for read mode */ - - else - { - i2cinfo("I2C read mode no correct state detected\n"); - i2cinfo(" state %i, dcnt=%i\n", status, priv->dcnt); - - /* Set condition to terminate ISR and wake waiting thread */ - - priv->dcnt = -1; - priv->msgc = 0; - stm32_i2c_traceevent(priv, I2CEVENT_READ_ERROR, 0); } - - /* Read rest of the state */ - - status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16); } /* Empty call handler @@ -2023,6 +1949,15 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16); + /* No any error bit is set, but driver is in incorrect state, signal + * it with "Bus error" bit. + */ + + if ((status & I2C_SR1_ERRORMASK) != 0) + { + priv->status |= I2C_SR1_BERR; + } + i2cinfo(" No correct state detected(start bit, read or write) \n"); i2cinfo(" state %i\n", status); @@ -2049,7 +1984,7 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) /* Clear interrupt flags */ -#ifndef CONFIG_STM32_I2C_DMA +#if !defined(CONFIG_STM32_I2C_DMA) && !defined(CONFIG_I2C_POLLED) state_error: #endif stm32_i2c_putreg(priv, STM32_I2C_SR1_OFFSET, 0); diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index 8657d6e166728cb16b35cb25e43c89c2db167fff..460a3872d8729e6bcd9b06b48cb0801667bd05e2 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -58,7 +58,7 @@ #include -#ifdef CONFIG_RTC +#if defined(CONFIG_RTC) && !defined(CONFIG_RTC_EXTERNAL) /**************************************************************************** * Pre-processor Definitions @@ -1659,4 +1659,5 @@ int stm32_rtc_rdalarm(FAR struct alm_rdalarm_s *alminfo) } #endif -#endif /* CONFIG_RTC */ +#endif /* CONFIG_RTC && !CONFIG_RTC_EXTERNAL */ + diff --git a/arch/arm/src/stm32f0/stm32f0_gpio.c b/arch/arm/src/stm32f0/stm32f0_gpio.c index ffa77a43ecc7c7dcd7488760b7ce7b2f2a49d306..d6ee49b6e92aaba84cf22072dfade5db677204db 100644 --- a/arch/arm/src/stm32f0/stm32f0_gpio.c +++ b/arch/arm/src/stm32f0/stm32f0_gpio.c @@ -115,7 +115,7 @@ void stm32f0_gpioinit(void) * function, it must be unconfigured with stm32f0_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * A negated errono valu on invalid port, or when pin is locked as ALT * function. @@ -336,7 +336,7 @@ int stm32f0_configgpio(uint32_t cfgset) * operate in PWM mode could produce excessive on-board currents and trigger * over-current/alarm function. * - * Returns: + * Returned Value: * OK on success * A negated errno value on invalid port * diff --git a/arch/arm/src/stm32f0/stm32f0_gpio.h b/arch/arm/src/stm32f0/stm32f0_gpio.h index 4cbe0a40dff1058dc404b790d466f1af6e35f87d..14c95cce3f6d3bbf97055e2df1d2c6dd760f6b58 100644 --- a/arch/arm/src/stm32f0/stm32f0_gpio.h +++ b/arch/arm/src/stm32f0/stm32f0_gpio.h @@ -256,7 +256,7 @@ EXTERN const uint32_t g_gpiobase[STM32F0_NPORTS]; * function, it must be unconfigured with stm32f0_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * ERROR on invalid port, or when pin is locked as ALT function. * @@ -277,7 +277,7 @@ int stm32f0_configgpio(uint32_t cfgset); * operate in PWM mode could produce excessive on-board currents and trigger * over-current/alarm function. * - * Returns: + * Returned Value: * OK on success * ERROR on invalid port * diff --git a/arch/arm/src/stm32f0/stm32f0_i2c.h b/arch/arm/src/stm32f0/stm32f0_i2c.h index 29bcbdccd1d920f4d89c8aad5bd7cf59c05f7b3f..dd127b788acf7bcc01733d8f3d333febc58703e4 100644 --- a/arch/arm/src/stm32f0/stm32f0_i2c.h +++ b/arch/arm/src/stm32f0/stm32f0_i2c.h @@ -74,7 +74,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -90,7 +90,7 @@ FAR struct i2c_master_s *stm32f0_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the stm32f0_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/stm32f0/stm32f0_serial.c b/arch/arm/src/stm32f0/stm32f0_serial.c index 91d6cc9828b9469faeb0339f7d92108ba3a465ef..3231ebdf6de485bc6f46c760ef8057b9a5f6bd47 100644 --- a/arch/arm/src/stm32f0/stm32f0_serial.c +++ b/arch/arm/src/stm32f0/stm32f0_serial.c @@ -1033,7 +1033,7 @@ static void stm32f0serial_setformat(FAR struct uart_dev_s *dev) * Description: * Enable or disable APB clock for the USART peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the USART driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -1907,7 +1907,7 @@ static bool stm32f0serial_rxavailable(FAR struct uart_dev_s *dev) * Return true if USART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - USART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is diff --git a/arch/arm/src/stm32f7/Kconfig b/arch/arm/src/stm32f7/Kconfig index 9e80a64934b48cf3070b84721cffe06a35735234..4f07188d09781fc28154483d036831990a6747b6 100644 --- a/arch/arm/src/stm32f7/Kconfig +++ b/arch/arm/src/stm32f7/Kconfig @@ -1430,6 +1430,7 @@ config STM32F7_SDMMC1 select ARCH_HAVE_SDIO select ARCH_HAVE_SDIOWAIT_WRCOMPLETE select SDIO_PREFLIGHT + select SDIO_BLOCKSETUP config STM32F7_SDMMC2 bool "SDMMC2" @@ -1439,6 +1440,7 @@ config STM32F7_SDMMC2 select ARCH_HAVE_SDIO select ARCH_HAVE_SDIOWAIT_WRCOMPLETE select SDIO_PREFLIGHT + select SDIO_BLOCKSETUP config STM32F7_SPDIFRX bool "SPDIFRX" diff --git a/arch/arm/src/stm32f7/Make.defs b/arch/arm/src/stm32f7/Make.defs index ccb0fe66549f1d9f2fcba3e5e35de444c0ce983d..fb05fecf339a0498364acc7e53f0aa2c7b9dfdee 100644 --- a/arch/arm/src/stm32f7/Make.defs +++ b/arch/arm/src/stm32f7/Make.defs @@ -44,7 +44,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_initialize.c diff --git a/arch/arm/src/stm32f7/chip/stm32f72xx73xx_memorymap.h b/arch/arm/src/stm32f7/chip/stm32f72xx73xx_memorymap.h index 669fd36abdb47a5baa6a8c32943192f099d65fda..c786506f768cbc62d706a2f5459f25416e9cb438 100644 --- a/arch/arm/src/stm32f7/chip/stm32f72xx73xx_memorymap.h +++ b/arch/arm/src/stm32f7/chip/stm32f72xx73xx_memorymap.h @@ -112,7 +112,6 @@ #define STM32_TIM14_BASE 0x40002000 /* 0x40002000-0x400023ff: TIM14 */ #define STM32_LPTIM1_BASE 0x40002400 /* 0x40002400-0x400027ff: LPTIM1 */ #define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP Registers */ -#define STM32_BKP_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP Registers */ #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff: WWDG */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff: IWDG */ #define STM32_SPI2_BASE 0x40003800 /* 0x40003800-0x40003bff: SPI2 / I2S2 */ diff --git a/arch/arm/src/stm32f7/chip/stm32f74xx75xx_memorymap.h b/arch/arm/src/stm32f7/chip/stm32f74xx75xx_memorymap.h index 89d5223845b90b011bb72eb2cf98ae685df73596..55b8481512b1bf2d861a16e372cc97fae09db45e 100644 --- a/arch/arm/src/stm32f7/chip/stm32f74xx75xx_memorymap.h +++ b/arch/arm/src/stm32f7/chip/stm32f74xx75xx_memorymap.h @@ -113,7 +113,6 @@ #define STM32_TIM14_BASE 0x40002000 /* 0x40002000-0x400023ff: TIM14 */ #define STM32_LPTIM1_BASE 0x40002400 /* 0x40002400-0x400027ff: LPTIM1 */ #define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP Registers */ -#define STM32_BKP_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP Registers */ #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff: WWDG */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff: IWDG */ #define STM32_SPI2_BASE 0x40003800 /* 0x40003800-0x40003bff: SPI2 / I2S2 */ diff --git a/arch/arm/src/stm32f7/chip/stm32f76xx77xx_memorymap.h b/arch/arm/src/stm32f7/chip/stm32f76xx77xx_memorymap.h index 0c27a36e93cf8323cf2032bf812d1b9e9272bad8..6d988895e0d3ec8283416e0defd0ff8b1b912a87 100644 --- a/arch/arm/src/stm32f7/chip/stm32f76xx77xx_memorymap.h +++ b/arch/arm/src/stm32f7/chip/stm32f76xx77xx_memorymap.h @@ -113,7 +113,6 @@ #define STM32_TIM14_BASE 0x40002000 /* 0x40002000-0x400023ff: TIM14 */ #define STM32_LPTIM1_BASE 0x40002400 /* 0x40002400-0x400027ff: LPTIM1 */ #define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP Registers */ -#define STM32_BKP_BASE 0x40002800 /* 0x40002800-0x40002bff: RTC & BKP Registers */ #define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff: WWDG */ #define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff: IWDG */ #define STM32_CAN3_BASE 0x40003400 /* 0x40003400-0x400037ff: CAN3 */ diff --git a/arch/arm/src/stm32f7/stm32_adc.c b/arch/arm/src/stm32f7/stm32_adc.c index 0d226ab46a3e462830b359bf2e52fa329af9a7e2..710209a2bf1558ffb98c97090d7e7dd213b9e708 100644 --- a/arch/arm/src/stm32f7/stm32_adc.c +++ b/arch/arm/src/stm32f7/stm32_adc.c @@ -568,7 +568,7 @@ static void tim_modifyreg(FAR struct stm32_dev_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the ADC block status * * Returned Value: @@ -1082,9 +1082,9 @@ static void adc_rccreset(FAR struct stm32_dev_s *priv, bool reset) /**************************************************************************** * Name: adc_enable * - * Description : Enables or disables the specified ADC peripheral. - * Also, starts a conversion when the ADC is not - * triggered by timers + * Description: + * Enables or disables the specified ADC peripheral. Also, starts a + * conversion when the ADC is not triggered by timers * * Input Parameters: * diff --git a/arch/arm/src/stm32f7/stm32_dma.c b/arch/arm/src/stm32f7/stm32_dma.c index a5d185944d547b5728037d867f7913287c5c4427..7a083e3239c7ca772ff7fc5002babad9f6b0dbf7 100644 --- a/arch/arm/src/stm32f7/stm32_dma.c +++ b/arch/arm/src/stm32f7/stm32_dma.c @@ -527,7 +527,7 @@ void weak_function up_dmainitialize(void) * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * dmamap - Identifies the stream/channel resource. For the STM32 F7, this * is a bit-encoded value as provided by the DMAMAP_* definitions * in chip/stm32f7xxxxxxx_dma.h @@ -874,7 +874,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle) * ccr. * ccr - DMA stream configuration register * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_dma.h b/arch/arm/src/stm32f7/stm32_dma.h index e0494d538129693a0a9d1649ef97f67f486e9f5f..567e2330647a9ff517b9f94ebc370bed128befbe 100644 --- a/arch/arm/src/stm32f7/stm32_dma.h +++ b/arch/arm/src/stm32f7/stm32_dma.h @@ -135,7 +135,7 @@ extern "C" * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * chan - Identifies the stream/channel resource * For the STM32 F7, this is a bit encoded value as provided by the * the DMAMAP_* definitions in chip/stm32f7xxxxxxx_dma.h @@ -248,7 +248,7 @@ size_t stm32_dmaresidual(DMA_HANDLE handle); * ccr. * ccr - DMA stream configuration register * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_dma2d.c b/arch/arm/src/stm32f7/stm32_dma2d.c index f0ec2123395195801555101cd0d75d126f4cd237..9e952d2ead31c401ca4421fff941f489f1885946 100644 --- a/arch/arm/src/stm32f7/stm32_dma2d.c +++ b/arch/arm/src/stm32f7/stm32_dma2d.c @@ -481,7 +481,7 @@ static int stm32_dma2dirq(int irq, void *context, FAR void *arg) * loading or dma transfer was completed. * Note! The caller must use this function within a critical section. * - * Return: + * Returned Value: * On success OK otherwise ERROR * ****************************************************************************/ @@ -526,7 +526,7 @@ static int stm32_dma2d_waitforirq(void) * Parameter: * pfcreg - PFC control Register * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -614,7 +614,7 @@ static int stm32_dma2d_start(void) * Parameter: * layer - Reference to the common layer state structure * - * Return: + * Returned Value: * memory address * ****************************************************************************/ @@ -640,7 +640,7 @@ static uint32_t stm32_dma2d_memaddress(FAR const struct stm32_dma2d_s *layer, * Parameter: * layer - Reference to the common layer state structure * - * Return: + * Returned Value: * line offset * ****************************************************************************/ @@ -664,7 +664,7 @@ static fb_coord_t stm32_dma2d_lineoffset(FAR const struct stm32_dma2d_s *layer, * layer - Reference to the common layer state structure * fmt - Reference to the location to store the pixel format * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -723,7 +723,7 @@ static int stm32_dma2d_pixelformat(uint8_t fmt, uint8_t *fmtmap) * layer - Reference to the common layer state structure * bpp - Reference to the location to store the pixel format * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -764,7 +764,7 @@ static int stm32_dma2d_bpp(uint8_t fmt, uint8_t *bpp) * Description: * Get a free layer id * - * Return: + * Returned Value: * The number of the free layer * -1 if no free layer is available * @@ -791,7 +791,7 @@ static int stm32_dma2d_lfreelid(void) * Description: * Allocate a new layer structure * - * Return: + * Returned Value: * A new allocated layer structure or NULL on error. * ****************************************************************************/ @@ -880,7 +880,7 @@ static void stm32_dma2d_llayerscleanup(void) * Description: * Helper to validate if the layer is valid * - * Return: + * Returned Value: * true if validates otherwise false * ****************************************************************************/ @@ -902,7 +902,7 @@ static inline bool stm32_dma2d_lvalidate(FAR const struct stm32_dma2d_s *layer) * ypos - The y position inside the whole layer * area - the area inside the whole layer * - * Return: + * Returned Value: * true if area is inside the whole layer otherwise false * ****************************************************************************/ @@ -1156,7 +1156,7 @@ static void stm32_dma2d_lpfc(FAR const struct stm32_dma2d_s *layer, * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1193,7 +1193,7 @@ static int stm32_dma2dgetvideoinfo(FAR struct dma2d_layer_s *layer, * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1229,7 +1229,7 @@ static int stm32_dma2dgetplaneinfo(FAR struct dma2d_layer_s *layer, int planeno, * layer - Reference to the layer structure * lid - Reference to store the layer id * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1265,7 +1265,7 @@ static int stm32_dma2dgetlid(FAR struct dma2d_layer_s *layer, int *lid) * layer - Reference to the layer structure * cmap - color lookup table with up the 256 entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1384,7 +1384,7 @@ static int stm32_dma2dsetclut(FAR struct dma2d_layer_s *layer, * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1476,7 +1476,7 @@ static int stm32_dma2dgetclut(FAR struct dma2d_layer_s *layer, * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1511,7 +1511,7 @@ static int stm32_dma2dsetalpha(FAR struct dma2d_layer_s *layer, uint8_t alpha) * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1548,7 +1548,7 @@ static int stm32_dma2dgetalpha(FAR struct dma2d_layer_s *layer, uint8_t *alpha) * layer - Reference to the layer structure * mode - Blend mode (see DMA2D_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1597,7 +1597,7 @@ static int stm32_dma2dsetblendmode(FAR struct dma2d_layer_s *layer, * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1637,7 +1637,7 @@ static int stm32_dma2dgetblendmode(FAR struct dma2d_layer_s *layer, * src - Valid reference to the source layer * srcarea - Valid reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -1746,7 +1746,7 @@ static int stm32_dma2dblit(FAR struct dma2d_layer_s *dest, * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -1853,7 +1853,7 @@ static int stm32_dma2dblend(FAR struct dma2d_layer_s *dest, * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * area outside the visible area of the layer. @@ -1929,7 +1929,7 @@ static int stm32_dma2dfillarea(FAR struct dma2d_layer_s *layer, * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the dma2d layer control structure on success or Null if no * related exist. * @@ -1962,7 +1962,7 @@ FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid) * height - Layer height * fmt - Pixel format of the layer * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL * @@ -2082,7 +2082,7 @@ FAR struct dma2d_layer_s *up_dma2dcreatelayer(fb_coord_t width, * Parameter: * layer - Reference to the layer to remove * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2124,7 +2124,7 @@ int up_dma2dremovelayer(FAR struct dma2d_layer_s *layer) * Description: * Initialize the dma2d controller * - * Return: + * Returned Value: * OK - On success * An error if initializing failed. * @@ -2240,7 +2240,7 @@ void up_dma2duninitialize(void) * layer - a valid reference to the low level ltdc layer structure * clut - a pointer to a valid memory region to hold 256 clut colors * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL * @@ -2261,7 +2261,6 @@ FAR struct dma2d_layer_s *stm32_dma2dinitltdc(FAR struct stm32_ltdc_s *layer) { lcderr("ERROR: Returning -EINVAL, unsupported pixel format: %d\n", layer->vinfo.fmt); - errno = -EINVAL; return NULL; } diff --git a/arch/arm/src/stm32f7/stm32_dma2d.h b/arch/arm/src/stm32f7/stm32_dma2d.h index 26d9f0faa8b63722de20fd70a05699b984d507f2..9ffc8289cd7f50531e70346b09ebde86a24c3155 100644 --- a/arch/arm/src/stm32f7/stm32_dma2d.h +++ b/arch/arm/src/stm32f7/stm32_dma2d.h @@ -74,7 +74,7 @@ struct dma2d_layer_s * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -92,7 +92,7 @@ struct dma2d_layer_s * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -109,7 +109,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * lid - Reference to store the layer id * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -127,7 +127,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * cmap - color lookup table with up the 256 entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -145,7 +145,7 @@ struct dma2d_layer_s * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -167,7 +167,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -183,7 +183,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -201,7 +201,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * mode - Blend mode (see DMA2D_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -230,7 +230,7 @@ struct dma2d_layer_s * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -250,7 +250,7 @@ struct dma2d_layer_s * src - Reference to the source layer * srcarea - Reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the * selected source area outside the visible area of the @@ -281,7 +281,7 @@ struct dma2d_layer_s * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the * selected source area outside the visible area of the @@ -308,7 +308,7 @@ struct dma2d_layer_s * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the * selected area outside the visible area of the layer. @@ -340,7 +340,7 @@ struct stm32_ltdc_s; /* Forward declaration */ * Parameter: * layer - a valid reference to the low level ltdc layer structure * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL and errno is set to * -EINVAL if one of the parameter is invalid @@ -358,7 +358,7 @@ FAR struct dma2d_layer_s *stm32_dma2dinitltdc(FAR struct stm32_ltdc_s *layer); * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the dma2d layer control structure on success or Null if no * related exist. * @@ -377,7 +377,7 @@ FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid); * height - Layer height * fmt - Pixel format of the layer * - * Return: + * Returned Value: * On success - A valid dma2d layer reference * On error - NULL and errno is set to * -EINVAL if one of the parameter is invalid @@ -399,7 +399,7 @@ FAR struct dma2d_layer_s *up_dma2dcreatelayer(fb_coord_t width, * Parameter: * layer - Reference to the layer to remove * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -413,7 +413,7 @@ int up_dma2dremovelayer(FAR struct dma2d_layer_s *layer); * Description: * Initialize the dma2d controller * - * Return: + * Returned Value: * OK - On success * An error if initializing failed. * diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index 8c0eddd847ee3fefca621ef2be1000becf0def0e..d5337d8f48c86ad27a757348f7a163a6022b1614 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32f7/stm32_ethernet.c * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -732,7 +732,7 @@ static int stm32_addmac(struct net_driver_s *dev, const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int stm32_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2958,16 +2958,17 @@ static void stm32_rxdescinit(struct stm32_ethmac_s *priv, * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)dev->d_private; #endif int ret; switch (cmd) { +#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_ARCH_PHY_INTERRUPT case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { @@ -3005,6 +3006,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in); } break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ default: ret = -ENOTTY; @@ -3013,7 +3015,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: stm32_phyintenable @@ -4095,7 +4097,7 @@ int stm32_ethinitialize(int intf) priv->dev.d_addmac = stm32_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = stm32_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = stm32_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_stm32ethmac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/stm32f7/stm32_exti_alarm.c b/arch/arm/src/stm32f7/stm32_exti_alarm.c index 8fba01b53a4361a2ba34db6728b48e3a29009c92..552241b4907ce2366b9266cc8ad7593f3bf6d1d3 100644 --- a/arch/arm/src/stm32f7/stm32_exti_alarm.c +++ b/arch/arm/src/stm32f7/stm32_exti_alarm.c @@ -116,7 +116,7 @@ static int stm32_exti_alarm_isr(int irq, void *context, FAR void *arg) * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * diff --git a/arch/arm/src/stm32f7/stm32_exti_pwr.c b/arch/arm/src/stm32f7/stm32_exti_pwr.c index 3c4f2d07a3be4107326520c4e25a76a0bf0ef5f9..f521aaff24ebf9ae3a50bb42e30569177a64aa65 100644 --- a/arch/arm/src/stm32f7/stm32_exti_pwr.c +++ b/arch/arm/src/stm32f7/stm32_exti_pwr.c @@ -122,7 +122,7 @@ static int stm32_exti_pvd_isr(int irq, void *context, void *arg) * - event: generate event when set * - func: when non-NULL, generate interrupt * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32f7/stm32_exti_pwr.h b/arch/arm/src/stm32f7/stm32_exti_pwr.h index 67e22d05ff8400fb6b14f351c19f09f9a724e7f8..90b0185d594f5f5e64189a55709295de91e51fa9 100644 --- a/arch/arm/src/stm32f7/stm32_exti_pwr.h +++ b/arch/arm/src/stm32f7/stm32_exti_pwr.h @@ -60,7 +60,7 @@ * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32f7/stm32_gpio.c b/arch/arm/src/stm32f7/stm32_gpio.c index e9b3f0d8a9ad0d5d4a3c387b6665b6614954f3d5..cf153dd48207fba5e0441271ff441903b47d892f 100644 --- a/arch/arm/src/stm32f7/stm32_gpio.c +++ b/arch/arm/src/stm32f7/stm32_gpio.c @@ -136,7 +136,7 @@ void stm32_gpioinit(void) * function, it must be unconfigured with stm32_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * A negated errono value on invalid port, or when pin is locked as ALT * function. @@ -359,7 +359,7 @@ int stm32_configgpio(uint32_t cfgset) * operate in PWM mode could produce excessive on-board currents and trigger * over-current/alarm function. * - * Returns: + * Returned Value: * OK on success * A negated errno value on invalid port * diff --git a/arch/arm/src/stm32f7/stm32_i2c.h b/arch/arm/src/stm32f7/stm32_i2c.h index c5608176387158c74c643c7d56f6c2606c1af5e6..e2223f53c8f16a7441a313287308d953858008dc 100644 --- a/arch/arm/src/stm32f7/stm32_i2c.h +++ b/arch/arm/src/stm32f7/stm32_i2c.h @@ -74,7 +74,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -90,7 +90,7 @@ FAR struct i2c_master_s *stm32_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the stm32_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/stm32f7/stm32_ltdc.c b/arch/arm/src/stm32f7/stm32_ltdc.c index 3a992d928fad6ff71e94b686e2454a71390f4ec6..185a6ade19a9f35a550197c2e75ab43b1879b224 100644 --- a/arch/arm/src/stm32f7/stm32_ltdc.c +++ b/arch/arm/src/stm32f7/stm32_ltdc.c @@ -1168,7 +1168,7 @@ static int stm32_ltdcirq(int irq, void *context, FAR void *arg) * that a register reload was been completed. * Note! The caller must use this function within a critical section. * - * Return: + * Returned Value: * OK - On success otherwise ERROR * ****************************************************************************/ @@ -1467,7 +1467,7 @@ static inline uint8_t stm32_ltdc_lgetopac(FAR struct stm32_layer_s *layer) * Parameter: * layer - Reference to the layer control structure * - * Return: + * Returned Value: * true - layer valid * false - layer invalid * @@ -1497,7 +1497,7 @@ static inline bool stm32_ltdc_lvalidate(FAR const struct stm32_layer_s *layer) * srcxpos - Top left x position from where data visible in the active area * srcypos - Top left y position from where data visible in the active area * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -1959,7 +1959,7 @@ static void stm32_ltdc_lenable(FAR struct stm32_layer_s *layer) } /**************************************************************************** - * Name stm32_ltdc_lclear + * Name: stm32_ltdc_lclear * * Description: * Clear the whole layer @@ -1968,7 +1968,7 @@ static void stm32_ltdc_lenable(FAR struct stm32_layer_s *layer) * layer - Reference to the layer control structure * color - The color to clear * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid * @@ -2182,7 +2182,7 @@ static void stm32_ltdc_linit(int lid) * vtable - The framebuffer driver object * vinfo - the videoinfo object * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2217,7 +2217,7 @@ static int stm32_getvideoinfo(struct fb_vtable_s *vtable, * vtable - The framebuffer driver object * pinfo - the planeinfo object * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2252,7 +2252,7 @@ static int stm32_getplaneinfo(struct fb_vtable_s *vtable, int planeno, * vtable - The framebuffer driver object * cmap - the color table * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2279,7 +2279,7 @@ static int stm32_getcmap(struct fb_vtable_s *vtable, * vtable - The framebuffer driver object * cmap - the color table * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2306,7 +2306,7 @@ static int stm32_putcmap(struct fb_vtable_s *vtable, * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2340,7 +2340,7 @@ static int stm32_lgetvideoinfo(struct ltdc_layer_s *layer, * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2374,7 +2374,7 @@ static int stm32_lgetplaneinfo(struct ltdc_layer_s *layer, int planeno, * layer - Reference to the layer structure * cmap - color lookup table with up the 256 entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2434,7 +2434,7 @@ static int stm32_setclut(struct ltdc_layer_s *layer, * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2533,7 +2533,7 @@ static int stm32_getclut(struct ltdc_layer_s *layer, * e.g. get the current active or inactive layer. * See LTDC_LAYER_* for possible values * - * Return: + * Returned Value: * OK - On success * Null if invalid flag * @@ -2610,7 +2610,7 @@ static int stm32_getlid(FAR struct ltdc_layer_s *layer, int *lid, * layer - Reference to the layer structure * argb - ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2646,7 +2646,7 @@ static int stm32_setcolor(FAR struct ltdc_layer_s *layer, uint32_t argb) * layer - Reference to the layer structure * argb - Reference to store the ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2683,7 +2683,7 @@ static int stm32_getcolor(FAR struct ltdc_layer_s *layer, uint32_t *argb) * layer - Reference to the layer structure * rgb - RGB888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2719,7 +2719,7 @@ static int stm32_setcolorkey(FAR struct ltdc_layer_s *layer, uint32_t rgb) * layer - Reference to the layer structure * rgb - Reference to store the RGB888 color key * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2760,7 +2760,7 @@ static int stm32_getcolorkey(FAR struct ltdc_layer_s *layer, uint32_t *rgb) * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2796,7 +2796,7 @@ static int stm32_setalpha(FAR struct ltdc_layer_s *layer, uint8_t alpha) * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2833,7 +2833,7 @@ static int stm32_getalpha(FAR struct ltdc_layer_s *layer, uint8_t *alpha) * layer - Reference to the layer structure * mode - Blend mode (see LTDC_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -2965,7 +2965,7 @@ static int stm32_setblendmode(FAR struct ltdc_layer_s *layer, uint32_t mode) * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL ****************************************************************************/ @@ -3004,7 +3004,7 @@ static int stm32_getblendmode(FAR struct ltdc_layer_s *layer, uint32_t *mode) * srcxpos - x position of the visible pixel of the whole layer * srcypos - y position of the visible pixel of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -3066,7 +3066,7 @@ static int stm32_setarea(FAR struct ltdc_layer_s *layer, * srcxpos - Reference to store the referenced x position of the whole layer * srcypos - Reference to store the reterenced y position of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -3106,7 +3106,7 @@ static int stm32_getarea(FAR struct ltdc_layer_s *layer, * layer - Reference to the layer structure * mode - operation mode * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid * -ECANCELED - Operation cancelled, something goes wrong @@ -3269,7 +3269,7 @@ static int stm32_update(FAR struct ltdc_layer_s *layer, uint32_t mode) * src - Reference to the source layer * srcarea - Reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -3320,7 +3320,7 @@ static int stm32_blit(FAR struct ltdc_layer_s *dest, * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -3370,7 +3370,7 @@ static int stm32_blend(FAR struct ltdc_layer_s *dest, * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * area outside the visible area of the layer. @@ -3412,7 +3412,7 @@ static int stm32_fillarea(FAR struct ltdc_layer_s *layer, * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the layer control structure on success or Null if lid * is invalid. * @@ -3452,7 +3452,7 @@ void stm32_ltdcreset(void) * Description: * Initialize the ltdc controller * - * Return: + * Returned Value: * OK * ****************************************************************************/ @@ -3541,10 +3541,10 @@ int stm32_ltdcinitialize(void) * Return a a reference to the framebuffer object for the specified video * plane. * - * Input parameters: + * Input Parameters: * None * - * Returned value: + * Returned Value: * Reference to the framebuffer object (NULL on failure) * ****************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_ltdc.h b/arch/arm/src/stm32f7/stm32_ltdc.h index 8b3593e86da3e41f81cf289861d4b805301dafcb..c2226ec43ef3a9a84e5b0db8678ab3a44b07142f 100644 --- a/arch/arm/src/stm32f7/stm32_ltdc.h +++ b/arch/arm/src/stm32f7/stm32_ltdc.h @@ -125,7 +125,7 @@ struct ltdc_layer_s * layer - Reference to the layer control structure * vinfo - Reference to the video info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -143,7 +143,7 @@ struct ltdc_layer_s * planeno - Number of the plane * pinfo - Reference to the plane info structure * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -163,7 +163,7 @@ struct ltdc_layer_s * e.g. get the current active or inactive layer. * See LTDC_LAYER_* for possible values * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -184,7 +184,7 @@ struct ltdc_layer_s * enable - Enable or disable clut support (if false cmap is ignored and can * be NULL) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -202,7 +202,7 @@ struct ltdc_layer_s * cmap - Reference to valid color lookup table accept up the 256 color * entries * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -221,7 +221,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * argb - ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -237,7 +237,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * argb - Reference to store the ARGB8888 color value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -255,7 +255,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * rgb - RGB888 color key * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -271,7 +271,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * rgb - Reference to store the RGB888 color key * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -293,7 +293,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * alpha - Alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -309,7 +309,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * alpha - Reference to store the alpha value * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -327,7 +327,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * mode - Blend mode (see LTDC_BLEND_*) * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -365,7 +365,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * mode - Reference to store the blend mode * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -392,7 +392,7 @@ struct ltdc_layer_s * srcxpos - x position of the visible pixel of the whole layer * srcypos - y position of the visible pixel of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL * @@ -418,7 +418,7 @@ struct ltdc_layer_s * srcxpos - Reference to store the referenced x position of the whole layer * srcypos - Reference to store the reterenced y position of the whole layer * - * Return: + * Returned Value: * On success - OK * On error - -EINVAL */ @@ -437,7 +437,7 @@ struct ltdc_layer_s * layer - Reference to the layer structure * mode - operation mode (see LTDC_UPDATE_*) * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid * -ECANCELED - Operation cancelled, something goes wrong @@ -481,7 +481,7 @@ struct ltdc_layer_s * src - Reference to the source layer * srcarea - Reference to the selected area of the source layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -510,7 +510,7 @@ struct ltdc_layer_s * back - Reference to the background layer * backarea - Reference to the selected area of the background layer * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * source area outside the visible area of the destination layer. @@ -535,7 +535,7 @@ struct ltdc_layer_s * color - Color to fill the selected area. Color must be formatted * according to the layer pixel format. * - * Return: + * Returned Value: * OK - On success * -EINVAL - If one of the parameter invalid or if the size of the selected * area outside the visible area of the layer. @@ -609,7 +609,7 @@ struct stm32_ltdc_s * Description: * Initialize the ltdc controller * - * Return: + * Returned Value: * OK * ************************************************************************************/ @@ -627,7 +627,7 @@ void stm32_ltdcuninitialize(void); * Parameter: * lid - Layer identifier * - * Return: + * Returned Value: * Reference to the layer control structure on success or Null if parameter * invalid. * diff --git a/arch/arm/src/stm32f7/stm32_otghost.c b/arch/arm/src/stm32f7/stm32_otghost.c index 548a6f393de2f17754528ee12af09d06024919c5..1a9b8c1feac796e1aa21a129dc81688f8ae8b983 100644 --- a/arch/arm/src/stm32f7/stm32_otghost.c +++ b/arch/arm/src/stm32f7/stm32_otghost.c @@ -1265,7 +1265,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -1327,7 +1327,7 @@ static int stm32_ctrlep_alloc(FAR struct stm32_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -3819,7 +3819,7 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3910,7 +3910,7 @@ static int stm32_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4040,7 +4040,7 @@ static int stm32_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4099,7 +4099,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4155,7 +4155,7 @@ static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4223,7 +4223,7 @@ static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4269,7 +4269,7 @@ static int stm32_alloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4305,7 +4305,7 @@ static int stm32_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4349,7 +4349,7 @@ static int stm32_ioalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4392,7 +4392,7 @@ static int stm32_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4595,7 +4595,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4667,7 +4667,7 @@ static ssize_t stm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4723,7 +4723,7 @@ static int stm32_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4812,7 +4812,7 @@ static int stm32_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4864,7 +4864,7 @@ static int stm32_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32f7/stm32_pwr.c b/arch/arm/src/stm32f7/stm32_pwr.c index c9d2d5dae44159523fb02e629f6873d56350c284..573796a78805d24bb062c841d8be1cf5fe26bad0 100644 --- a/arch/arm/src/stm32f7/stm32_pwr.c +++ b/arch/arm/src/stm32f7/stm32_pwr.c @@ -200,7 +200,7 @@ void stm32_pwr_enablebkp(bool writable) * Input Parameters: * regon - state to set it to * - * Returned Values: + * Returned Value: * None * ************************************************************************************/ @@ -229,7 +229,7 @@ void stm32_pwr_enablebreg(bool regon) * Input Parameters: * vos - Properly aligned voltage scaling select bits for the PWR_CR register. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -264,7 +264,7 @@ void stm32_pwr_setvos(uint16_t vos) * Input Parameters: * pls - PVD level * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32f7/stm32_pwr.h b/arch/arm/src/stm32f7/stm32_pwr.h index c80de12ae1707689cd498cd13275af2dda22edd2..b332e424a0deb2cd595c6f4fb936511245a707bb 100644 --- a/arch/arm/src/stm32f7/stm32_pwr.h +++ b/arch/arm/src/stm32f7/stm32_pwr.h @@ -119,7 +119,7 @@ void stm32_pwr_enablebkp(bool writable); * Input Parameters: * regon - state to set it to * - * Returned Values: + * Returned Value: * None * ************************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_sdmmc.c b/arch/arm/src/stm32f7/stm32_sdmmc.c index e6168ad6631e788c5025279f33eb108bf01fd421..86481dd42fb4d593d77778c5b3e4b677a09737bc 100644 --- a/arch/arm/src/stm32f7/stm32_sdmmc.c +++ b/arch/arm/src/stm32f7/stm32_sdmmc.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32f7/stm32_sdmmc.c * - * Copyright (C) 2009, 2011-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011-2018 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * David Sidrane * @@ -388,6 +388,10 @@ struct stm32_dev_s bool dmamode; /* true: DMA mode transfer */ DMA_HANDLE dma; /* Handle for DMA channel */ #endif + + /* Misc */ + + uint32_t blocksize; /* Current block size */ }; /* Register logging support */ @@ -421,8 +425,8 @@ struct stm32_sampleregs_s /* Low-level helpers ********************************************************/ -static inline void sdmmc_putreg32(struct stm32_dev_s *priv, uint32_t value,\ - int offset); +static inline void sdmmc_putreg32(struct stm32_dev_s *priv, uint32_t value, + int offset); static inline uint32_t sdmmc_getreg32(struct stm32_dev_s *priv, int offset); static void stm32_takesem(struct stm32_dev_s *priv); #define stm32_givesem(priv) (nxsem_post(&priv->waitsem)) @@ -438,7 +442,7 @@ static inline uint32_t stm32_getpwrctrl(struct stm32_dev_s *priv); #ifdef CONFIG_STM32F7_SDMMC_XFRDEBUG static void stm32_sampleinit(void); static void stm32_sdiosample(struct stm32_dev_s *priv, - struct stm32_sdioregs_s *regs); + struct stm32_sdioregs_s *regs); static void stm32_sample(struct stm32_dev_s *priv, int index); static void stm32_sdiodump(struct stm32_sdioregs_s *regs, const char *msg); static void stm32_dumpsample(struct stm32_dev_s *priv, @@ -458,13 +462,15 @@ static void stm32_dmacallback(DMA_HANDLE handle, uint8_t status, void *arg); static uint8_t stm32_log2(uint16_t value); static void stm32_dataconfig(struct stm32_dev_s *priv, uint32_t timeout, - uint32_t dlen, uint32_t dctrl); + uint32_t dlen, uint32_t dctrl); static void stm32_datadisable(struct stm32_dev_s *priv); static void stm32_sendfifo(struct stm32_dev_s *priv); static void stm32_recvfifo(struct stm32_dev_s *priv); static void stm32_eventtimeout(int argc, uint32_t arg); -static void stm32_endwait(struct stm32_dev_s *priv, sdio_eventset_t wkupevent); -static void stm32_endtransfer(struct stm32_dev_s *priv, sdio_eventset_t wkupevent); +static void stm32_endwait(struct stm32_dev_s *priv, + sdio_eventset_t wkupevent); +static void stm32_endtransfer(struct stm32_dev_s *priv, + sdio_eventset_t wkupevent); /* Interrupt Handling *******************************************************/ @@ -495,6 +501,8 @@ static int stm32_attach(FAR struct sdio_dev_s *dev); static int stm32_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t arg); +static void stm32_blocksetup(FAR struct sdio_dev_s *dev, + unsigned int blocksize, unsigned int nblocks); static int stm32_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, size_t nbytes); static int stm32_sendsetup(FAR struct sdio_dev_s *dev, @@ -543,6 +551,7 @@ static void stm32_default(struct stm32_dev_s *priv); /**************************************************************************** * Private Data ****************************************************************************/ + #ifdef CONFIG_STM32F7_SDMMC1 struct stm32_dev_s g_sdmmcdev1 = { @@ -558,9 +567,7 @@ struct stm32_dev_s g_sdmmcdev1 = .clock = stm32_clock, .attach = stm32_attach, .sendcmd = stm32_sendcmd, -#ifdef CONFIG_SDIO_BLOCKSETUP - .blocksetup = stm32_blocksetup, /* Not implemented yet */ -#endif + .blocksetup = stm32_blocksetup, .recvsetup = stm32_recvsetup, .sendsetup = stm32_sendsetup, .cancel = stm32_cancel, @@ -620,9 +627,7 @@ struct stm32_dev_s g_sdmmcdev2 = .clock = stm32_clock, .attach = stm32_attach, .sendcmd = stm32_sendcmd, -#ifdef CONFIG_SDIO_BLOCKSETUP - .blocksetup = stm32_blocksetup, /* Not implemented yet */ -#endif + .blocksetup = stm32_blocksetup, .recvsetup = stm32_recvsetup, .sendsetup = stm32_sendsetup, .cancel = stm32_cancel, @@ -1433,6 +1438,19 @@ static void stm32_endwait(struct stm32_dev_s *priv, sdio_eventset_t wkupevent) static void stm32_endtransfer(struct stm32_dev_s *priv, sdio_eventset_t wkupevent) { + /* Disable the DTEN bit (it should not be left set after previous read when + * the next write initialization starts). + */ + +#if 1 + sdmmc_putreg32(priv, + sdmmc_getreg32(priv, STM32_SDMMC_DCTRL_OFFSET) & + ~STM32_SDMMC_DCTRL_DTEN, + STM32_SDMMC_DCTRL_OFFSET); +#else + stm32_datadisable(priv); +#endif + /* Disable all transfer related interrupts */ stm32_configxfrints(priv, 0); @@ -2057,6 +2075,30 @@ static int stm32_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t arg) return OK; } +/**************************************************************************** + * Name: stm32_blocksetup + * + * Description: + * Configure block size and the number of blocks for next transfer. + * + * Input Parameters: + * dev - An instance of the SDIO device interface. + * blocksize - The selected block size. + * nblocks - The number of blocks to transfer. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void stm32_blocksetup(FAR struct sdio_dev_s *dev, unsigned int blocksize, + unsigned int nblocks) +{ + struct stm32_dev_s *priv = (struct stm32_dev_s *)dev; + + priv->blocksize = blocksize; +} + /**************************************************************************** * Name: stm32_recvsetup * @@ -2103,7 +2145,7 @@ static int stm32_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, /* Then set up the SDIO data path */ - dblocksize = stm32_log2(nbytes) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; + dblocksize = stm32_log2(priv->blocksize) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; stm32_dataconfig(priv, SDMMC_DTIMER_DATATIMEOUT, nbytes, dblocksize | STM32_SDMMC_DCTRL_DTDIR); @@ -2158,7 +2200,7 @@ static int stm32_sendsetup(FAR struct sdio_dev_s *dev, FAR const /* Then set up the SDIO data path */ - dblocksize = stm32_log2(nbytes) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; + dblocksize = stm32_log2(priv->blocksize) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; stm32_dataconfig(priv, SDMMC_DTIMER_DATATIMEOUT, nbytes, dblocksize); /* Enable TX interrupts */ @@ -2649,7 +2691,7 @@ static sdio_eventset_t stm32_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)stm32_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -2882,7 +2924,7 @@ static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, /* Then set up the SDIO data path */ - dblocksize = stm32_log2(buflen) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; + dblocksize = stm32_log2(priv->blocksize) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; stm32_dataconfig(priv, SDMMC_DTIMER_DATATIMEOUT, buflen, dblocksize | STM32_SDMMC_DCTRL_DTDIR); @@ -2975,7 +3017,7 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev, /* Then set up the SDIO data path */ - dblocksize = stm32_log2(buflen) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; + dblocksize = stm32_log2(priv->blocksize) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT; stm32_dataconfig(priv, SDMMC_DTIMER_DATATIMEOUT, buflen, dblocksize); /* Configure the TX DMA */ @@ -3115,7 +3157,7 @@ static void stm32_default(struct stm32_dev_s *priv) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -3251,7 +3293,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -3298,7 +3340,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_sdmmc.h b/arch/arm/src/stm32f7/stm32_sdmmc.h index 8e722497c5f296141a7fd40b87f4c581c0806c5a..095af548052f433d5f9f6f70f393f4d0de9c3ec2 100644 --- a/arch/arm/src/stm32f7/stm32_sdmmc.h +++ b/arch/arm/src/stm32f7/stm32_sdmmc.h @@ -72,7 +72,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -94,7 +94,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -112,7 +112,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32f7/stm32_serial.c b/arch/arm/src/stm32f7/stm32_serial.c index 3f639e178ef302d4e824be6427490285c20515a1..ba6edead3016e2f3ef828ed96f25b1b5f4d68ef1 100644 --- a/arch/arm/src/stm32f7/stm32_serial.c +++ b/arch/arm/src/stm32f7/stm32_serial.c @@ -1369,7 +1369,7 @@ static void up_set_format(struct uart_dev_s *dev) * Description: * Enable or disable APB clock for the USART peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the UART driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -2235,7 +2235,7 @@ static bool up_rxavailable(struct uart_dev_s *dev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is diff --git a/arch/arm/src/stm32f7/stm32_spi.c b/arch/arm/src/stm32f7/stm32_spi.c index 8ddf22bd3a004b54ea7e7947ac9b3e4873cd8403..cd1dc679893c6159f57090205a3df5cdbb405389 100644 --- a/arch/arm/src/stm32f7/stm32_spi.c +++ b/arch/arm/src/stm32f7/stm32_spi.c @@ -36,7 +36,7 @@ /************************************************************************************ * The external functions, stm32_spi1/2/3/4/5/6select and stm32_spi1/2/3/4/5/6status - * must be * provided by board-specific logic. They are implementations of the select + * must be provided by board-specific logic. They are implementations of the select * and status methods of the SPI interface defined by struct spi_ops_s (see * include/nuttx/spi/spi.h). All other methods (including stm32_spibus_initialize()) * are provided by common STM32 logic. To use this common SPI logic on your @@ -1190,6 +1190,9 @@ static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode) FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)dev; uint16_t setbits; uint16_t clrbits; +#ifdef CONFIG_STM32F7_SPI_DMA + uint16_t cr2bits; +#endif spiinfo("mode=%d\n", mode); @@ -1225,9 +1228,39 @@ static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode) return; } + /* Disable SPI then change mode */ + spi_modifycr1(priv, 0, SPI_CR1_SPE); spi_modifycr1(priv, setbits, clrbits); + +#ifdef CONFIG_STM32F7_SPI_DMA + /* Enabling SPI causes a spurious received character indication + * which confuse the DMA controller so we disable DMA during that + * enabling; and flush the SPI RX FIFO before re-enabling DMA. + */ + + cr2bits = spi_getreg(priv, STM32_SPI_CR2_OFFSET); + spi_modifycr2(priv, 0, SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN); +#endif + + /* Re-enable SPI */ + + spi_modifycr1(priv, SPI_CR1_SPE, 0); + while ((spi_getreg(priv, STM32_SPI_SR_OFFSET) & SPI_SR_FRLVL_MASK) != 0) + { + /* Flush SPI read FIFO */ + + spi_getreg(priv, STM32_SPI_DR_OFFSET); + } + +#ifdef CONFIG_STM32F7_SPI_DMA + + /* Re-enable DMA (with SPI disabled) */ + + spi_modifycr1(priv, 0, SPI_CR1_SPE); + spi_modifycr2(priv, cr2bits & (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN), 0); spi_modifycr1(priv, SPI_CR1_SPE, 0); +#endif /* Save the mode so that subsequent re-configurations will be faster */ @@ -1666,7 +1699,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t * Description: * Initialize the selected SPI bus in its default state (Master, 8-bit, mode 0, etc.) * - * Input Parameter: + * Input Parameters: * priv - private SPI device structure * * Returned Value: @@ -1755,7 +1788,7 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32f7/stm32_spi.h b/arch/arm/src/stm32f7/stm32_spi.h index 27751073564b3364ffe6cb15bb1ed9df2ad7f26e..f8c1ee9a1fc2dd644b2cc189aa24eb8a5974576e 100644 --- a/arch/arm/src/stm32f7/stm32_spi.h +++ b/arch/arm/src/stm32f7/stm32_spi.h @@ -71,7 +71,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * bus number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32f7/stm32_tim.h b/arch/arm/src/stm32f7/stm32_tim.h index 5f3bf82c1002d61ccb4f46768ba84259f0a0262b..06d7fe8e841035adaab4c793af900871783f49e8 100644 --- a/arch/arm/src/stm32f7/stm32_tim.h +++ b/arch/arm/src/stm32f7/stm32_tim.h @@ -196,7 +196,7 @@ int stm32_tim_deinit(FAR struct stm32_tim_dev_s *dev); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - the timer number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_adc.c b/arch/arm/src/stm32l4/stm32l4_adc.c index 56a9ae81d769756417303db54d56d21a63b5174a..ada9f4d8791639036a11b66359417ec50d4cdd05 100644 --- a/arch/arm/src/stm32l4/stm32l4_adc.c +++ b/arch/arm/src/stm32l4/stm32l4_adc.c @@ -592,7 +592,7 @@ static void tim_modifyreg(FAR struct stm32_dev_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the ADC block status * * Returned Value: @@ -1145,7 +1145,8 @@ static void adc_rccreset(FAR struct stm32_dev_s *priv, bool reset) /**************************************************************************** * Name: adc_enable * - * Description : Enables the specified ADC peripheral. + * Description: + * Enables the specified ADC peripheral. * * Input Parameters: * priv - A reference to the ADC block status diff --git a/arch/arm/src/stm32l4/stm32l4_can.c b/arch/arm/src/stm32l4/stm32l4_can.c index 7667481c6cd31c982f8725ffaa211474c219ecb8..2bc5dcd2e6062cc00953548c8d155770aa782a48 100644 --- a/arch/arm/src/stm32l4/stm32l4_can.c +++ b/arch/arm/src/stm32l4/stm32l4_can.c @@ -1627,7 +1627,7 @@ static int stm32l4can_txinterrupt(int irq, FAR void *context, FAR void *arg) * Where: * Tpclk1 is the period of the APB1 clock (PCLK1). * - * Input Parameter: + * Input Parameters: * priv - A reference to the CAN block status * * Returned Value: @@ -1726,7 +1726,7 @@ static int stm32l4can_bittiming(FAR struct stm32l4_can_s *priv) * peripheral, no registers are changed. The initialization mode is * required to change the baud rate. * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1777,7 +1777,7 @@ static int stm32l4can_enterinitmode(FAR struct stm32l4_can_s *priv) * Description: * Put the CAN cell out of the Initialization mode (to Normal mode) * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1827,7 +1827,7 @@ static int stm32l4can_exitinitmode(FAR struct stm32l4_can_s *priv) * Description: * CAN cell initialization * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1905,7 +1905,7 @@ static int stm32l4can_cellinit(FAR struct stm32l4_can_s *priv) * are set to zero thus supressing all filtering because anything masked * with zero matches zero. * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * * Returned Value: @@ -1981,7 +1981,7 @@ static int stm32l4can_filterinit(FAR struct stm32l4_can_s *priv) * Description: * Add a filter for extended CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - A pointer to a structure describing the filter * @@ -2006,7 +2006,7 @@ static int stm32l4can_addextfilter(FAR struct stm32l4_can_s *priv, * Description: * Remove a filter for extended CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - The filter index previously returned by the * CANIOC_ADD_EXTFILTER command @@ -2031,7 +2031,7 @@ static int stm32l4can_delextfilter(FAR struct stm32l4_can_s *priv, int arg) * Description: * Add a filter for standard CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - A pointer to a structure describing the filter * @@ -2054,7 +2054,7 @@ static int stm32l4can_addstdfilter(FAR struct stm32l4_can_s *priv, * Description: * Remove a filter for standard CAN IDs * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this CAN block * arg - The filter index previously returned by the * CANIOC_ADD_STDFILTER command @@ -2081,7 +2081,7 @@ static int stm32l4can_delstdfilter(FAR struct stm32l4_can_s *priv, int arg) * Description: * Initialize the selected CAN port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple CAN interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_can.h b/arch/arm/src/stm32l4/stm32l4_can.h index ded35c173ba2eb7c461f0869afea606deced54b4..c7ff34733d576ae07013c4e46e22548ee72220ff 100644 --- a/arch/arm/src/stm32l4/stm32l4_can.h +++ b/arch/arm/src/stm32l4/stm32l4_can.h @@ -122,7 +122,7 @@ extern "C" * Description: * Initialize the selected CAN port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple CAN interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_comp.c b/arch/arm/src/stm32l4/stm32l4_comp.c index 8e2f4ff90868690c01f53b246b6a8326a8536411..0c954c7c8be82b0a6ac6642cb037af705b191862 100644 --- a/arch/arm/src/stm32l4/stm32l4_comp.c +++ b/arch/arm/src/stm32l4/stm32l4_comp.c @@ -342,7 +342,7 @@ static int stm32l4_exti_comp_isr(int irq, void *context, FAR void *arg) * Parameters: * cfg - configuration * - * Returns: + * Returned Value: * 0 on success, a negated errno value on failure * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_dfsdm.c b/arch/arm/src/stm32l4/stm32l4_dfsdm.c index 89a57ea86ec2d229940418e2d7f8639edee76fbe..a52ad71df0346a2844778f3a5cb3ab3416011b92 100644 --- a/arch/arm/src/stm32l4/stm32l4_dfsdm.c +++ b/arch/arm/src/stm32l4/stm32l4_dfsdm.c @@ -545,7 +545,7 @@ static void tim_modifyreg(FAR struct stm32_dev_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the DFSDM block status * * Returned Value: @@ -1070,7 +1070,8 @@ static void dfsdm_rccreset(FAR struct stm32_dev_s *priv, bool reset) /**************************************************************************** * Name: dfsdm_enable * - * Description : Enables the DFSDM peripheral. + * Description: + * Enables the DFSDM peripheral. * * Input Parameters: * priv - A reference to the DFSDM block status diff --git a/arch/arm/src/stm32l4/stm32l4_dma.h b/arch/arm/src/stm32l4/stm32l4_dma.h index 5eb679be70bf4c9e8eb70ce75e3ee317f3d60736..c31246526767e3b94301e4bb1a30c5040da938c2 100644 --- a/arch/arm/src/stm32l4/stm32l4_dma.h +++ b/arch/arm/src/stm32l4/stm32l4_dma.h @@ -145,7 +145,7 @@ extern "C" * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * chan - Identifies the stream/channel resource * This is a bit encoded value as provided by the DMACHAN_* definitions * in chip/stm32l4x6xx_dma.h @@ -249,7 +249,7 @@ size_t stm32l4_dmaresidual(DMA_HANDLE handle); * only applies to memory addresses, it will return false for any peripheral * address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_exti.h b/arch/arm/src/stm32l4/stm32l4_exti.h index 14d2e7100ae47454d1b6b9bd23516e985acaa48f..098ac6e720a7d35388d52d38bfcf13b53a40fc16 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti.h +++ b/arch/arm/src/stm32l4/stm32l4_exti.h @@ -101,7 +101,7 @@ int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge, * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * @@ -124,7 +124,7 @@ int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event, * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * @@ -148,7 +148,7 @@ int stm32l4_exti_wakeup(bool risingedge, bool fallingedge, bool event, * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_exti_alarm.c b/arch/arm/src/stm32l4/stm32l4_exti_alarm.c index 2a0b3fbb0ef469f0762c88c1e2897b9041b82b45..e0016e063768d1540d45541cd2609a163a605d78 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti_alarm.c +++ b/arch/arm/src/stm32l4/stm32l4_exti_alarm.c @@ -108,7 +108,7 @@ static int stm32l4_exti_alarm_isr(int irq, void *context, FAR void *arg) * - event: generate event when set * - func: when non-NULL, generate interrupt * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_exti_comp.c b/arch/arm/src/stm32l4/stm32l4_exti_comp.c index 147eb3f4b48e7ef294e9c72b78da29e4c46166e2..44d029e0b3e572dea69cdfe63c17ebca0710b246 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti_comp.c +++ b/arch/arm/src/stm32l4/stm32l4_exti_comp.c @@ -129,7 +129,7 @@ static int stm32l4_exti_comp_isr(int irq, void *context, FAR void *arg) * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_exti_pwr.c b/arch/arm/src/stm32l4/stm32l4_exti_pwr.c index ab19f6f3cb95384a0c35b84400d606c01fda2f8c..7d5df6709802dce39b672bf11b7b503898953be7 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti_pwr.c +++ b/arch/arm/src/stm32l4/stm32l4_exti_pwr.c @@ -113,7 +113,7 @@ static int stm32l4_exti_pvd_isr(int irq, void *context, FAR void *arg) * - event: generate event when set * - func: when non-NULL, generate interrupt * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_exti_pwr.h b/arch/arm/src/stm32l4/stm32l4_exti_pwr.h index 27e584779b9fe981ce6fc93a9f2c7b86a764b3de..c6e10a0fa759b9392a275a05e3a8700992e76b48 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti_pwr.h +++ b/arch/arm/src/stm32l4/stm32l4_exti_pwr.h @@ -59,7 +59,7 @@ * - func: when non-NULL, generate interrupt * - arg: Argument passed to the interrupt callback * - * Returns: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on * failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_exti_wakeup.c b/arch/arm/src/stm32l4/stm32l4_exti_wakeup.c index 195cf2c1ac0d9f116e7517e3fcb3cc2d88eac0e7..ddac94add35a412ab67c42fd2ae407577182fbb3 100644 --- a/arch/arm/src/stm32l4/stm32l4_exti_wakeup.c +++ b/arch/arm/src/stm32l4/stm32l4_exti_wakeup.c @@ -107,7 +107,7 @@ static int stm32l4_exti_wakeup_isr(int irq, void *context, FAR void *arg) * - event: generate event when set * - func: when non-NULL, generate interrupt * - * Returns: + * Returned Value: * Zero (OK) on success; a negated errno value on failure indicating the * nature of the failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_gpio.c b/arch/arm/src/stm32l4/stm32l4_gpio.c index f46f341662c932c26bee5f1ef467d2f7b9d43a05..a33b88c08fe0eb14742d69db2361d0159ae8aeb6 100644 --- a/arch/arm/src/stm32l4/stm32l4_gpio.c +++ b/arch/arm/src/stm32l4/stm32l4_gpio.c @@ -129,7 +129,7 @@ void stm32l4_gpioinit(void) * function, it must be unconfigured with stm32l4_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * A negated errono valu on invalid port, or when pin is locked as ALT * function. @@ -351,7 +351,7 @@ int stm32l4_configgpio(uint32_t cfgset) * operate in PWM mode could produce excessive on-board currents and trigger * over-current/alarm function. * - * Returns: + * Returned Value: * OK on success * A negated errno value on invalid port * diff --git a/arch/arm/src/stm32l4/stm32l4_gpio.h b/arch/arm/src/stm32l4/stm32l4_gpio.h index 3c7b615c4e878aee72cbcf2a696e64f64b7b69b7..56fb77a6bbe5ff43268b2432188ef3fe3826007e 100644 --- a/arch/arm/src/stm32l4/stm32l4_gpio.h +++ b/arch/arm/src/stm32l4/stm32l4_gpio.h @@ -273,7 +273,7 @@ EXTERN const uint32_t g_gpiobase[STM32L4_NPORTS]; * function, it must be unconfigured with stm32l4_unconfiggpio() with * the same cfgset first before it can be set to non-alternative function. * - * Returns: + * Returned Value: * OK on success * ERROR on invalid port, or when pin is locked as ALT function. * @@ -294,7 +294,7 @@ int stm32l4_configgpio(uint32_t cfgset); * operate in PWM mode could produce excessive on-board currents and trigger * over-current/alarm function. * - * Returns: + * Returned Value: * OK on success * ERROR on invalid port * diff --git a/arch/arm/src/stm32l4/stm32l4_i2c.h b/arch/arm/src/stm32l4/stm32l4_i2c.h index 267ee1d6640509d57d63137356fdaabf784306fb..3a38cc14bdca451a3428e3014e4acb5f5462a3e4 100644 --- a/arch/arm/src/stm32l4/stm32l4_i2c.h +++ b/arch/arm/src/stm32l4/stm32l4_i2c.h @@ -74,7 +74,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -90,7 +90,7 @@ FAR struct i2c_master_s *stm32l4_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the stm32l4_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_iwdg.c b/arch/arm/src/stm32l4/stm32l4_iwdg.c index 9977e4d727d5c8d886940994754f658c8bb81e00..bf0b1392bb9f7be6e9bbc06b8c24ab07967d5fbd 100644 --- a/arch/arm/src/stm32l4/stm32l4_iwdg.c +++ b/arch/arm/src/stm32l4/stm32l4_iwdg.c @@ -312,7 +312,7 @@ static inline void stm32l4_setprescaler(FAR struct stm32l4_lowerhalf_s *priv) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -360,7 +360,7 @@ static int stm32l4_start(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -385,7 +385,7 @@ static int stm32l4_stop(FAR struct watchdog_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -418,7 +418,7 @@ static int stm32l4_keepalive(FAR struct watchdog_lowerhalf_s *lower) * driver state structure. * status - The location to return the watchdog status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -477,7 +477,7 @@ static int stm32l4_getstatus(FAR struct watchdog_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in milliseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -602,7 +602,7 @@ static int stm32l4_settimeout(FAR struct watchdog_lowerhalf_s *lower, * /dev/watchdog0 * lsifreq - The calibrated LSI clock frequency * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c index b7e952d23171da1305254c61a83f0b3442e5b08e..e676d9504f2cd052439c44bc4d1ed5c6461e8c0a 100644 --- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c +++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c @@ -1267,7 +1267,7 @@ static int stm32l4_ctrlchan_alloc(FAR struct stm32l4_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1329,7 +1329,7 @@ static int stm32l4_ctrlep_alloc(FAR struct stm32l4_usbhost_s *priv, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -3825,7 +3825,7 @@ static void stm32l4_txfe_enable(FAR struct stm32l4_usbhost_s *priv, int chidx) * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -3916,7 +3916,7 @@ static int stm32l4_wait(FAR struct usbhost_connection_s *conn, * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4046,7 +4046,7 @@ static int stm32l4_enumerate(FAR struct usbhost_connection_s *conn, * maxpacketsize - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4105,7 +4105,7 @@ static int stm32l4_ep0configure(FAR struct usbhost_driver_s *drvr, * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4161,7 +4161,7 @@ static int stm32l4_epalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4229,7 +4229,7 @@ static int stm32l4_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4275,7 +4275,7 @@ static int stm32l4_alloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4311,7 +4311,7 @@ static int stm32l4_free(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer) * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4355,7 +4355,7 @@ static int stm32l4_ioalloc(FAR struct usbhost_driver_s *drvr, * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4398,7 +4398,7 @@ static int stm32l4_iofree(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4601,7 +4601,7 @@ static int stm32l4_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -4673,7 +4673,7 @@ static ssize_t stm32l4_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -4729,7 +4729,7 @@ static int stm32l4_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4818,7 +4818,7 @@ static int stm32l4_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep) * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -4870,7 +4870,7 @@ static int stm32l4_connect(FAR struct usbhost_driver_s *drvr, * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: diff --git a/arch/arm/src/stm32l4/stm32l4_pm.h b/arch/arm/src/stm32l4/stm32l4_pm.h index fd94299389c910afcafb9f8d6773fbdb1fd91731..530be06fcb4c7a398038fb20d3e8dcbb5cece397 100644 --- a/arch/arm/src/stm32l4/stm32l4_pm.h +++ b/arch/arm/src/stm32l4/stm32l4_pm.h @@ -108,7 +108,7 @@ int stm32l4_pmstop2(void); * Input Parameters: * None * - * Returned Value. + * Returned Value: * On success, this function will not return (STANDBY mode can only be * terminated with a reset event). Otherwise, STANDBY mode did not occur * and a negated errno value is returned to indicate the cause of the diff --git a/arch/arm/src/stm32l4/stm32l4_pminitialize.c b/arch/arm/src/stm32l4/stm32l4_pminitialize.c index 05988f21bf5723da1df9944580531b9fbf187c56..89a8547a58601b51bebf2e75601afe516f1a0436 100644 --- a/arch/arm/src/stm32l4/stm32l4_pminitialize.c +++ b/arch/arm/src/stm32l4/stm32l4_pminitialize.c @@ -60,10 +60,10 @@ * *before* any other device drivers are initialized (since they may * attempt to register with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_pmstandby.c b/arch/arm/src/stm32l4/stm32l4_pmstandby.c index c8730c14f9dcff17cd1eb28c887b40462d5f8c68..331d8446f32a558a1c55e88728f6510d97533a21 100644 --- a/arch/arm/src/stm32l4/stm32l4_pmstandby.c +++ b/arch/arm/src/stm32l4/stm32l4_pmstandby.c @@ -60,7 +60,7 @@ * Input Parameters: * None * - * Returned Value. + * Returned Value: * On success, this function will not return (STANDBY mode can only be * terminated with a reset event). Otherwise, STANDBY mode did not occur * and a negated errno value is returned to indicate the cause of the diff --git a/arch/arm/src/stm32l4/stm32l4_pwm.c b/arch/arm/src/stm32l4/stm32l4_pwm.c index 10531d20a8ccc334f37a9689c88ee2a34f84fc84..03639445845b372a86a85f98462a977a2c2eab48 100644 --- a/arch/arm/src/stm32l4/stm32l4_pwm.c +++ b/arch/arm/src/stm32l4/stm32l4_pwm.c @@ -676,7 +676,7 @@ static void stm32l4pwm_putreg(struct stm32l4_pwmtimer_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the PWM block status * * Returned Value: @@ -734,7 +734,7 @@ static void stm32l4pwm_dumpregs(struct stm32l4_pwmtimer_s *priv, * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -1360,7 +1360,7 @@ static int stm32l4pwm_timer(FAR struct stm32l4_pwmtimer_s *priv, * Description: * Try to change only channel duty. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * channel - Channel to by updated * duty - New duty. @@ -1442,7 +1442,7 @@ static int stm32l4pwm_update_duty(FAR struct stm32l4_pwmtimer_s *priv, * Description: * Handle timer interrupts. * - * Input parameters: + * Input Parameters: * priv - A reference to the lower half PWM driver state structure * * Returned Value: @@ -1525,7 +1525,7 @@ static int stm32l4pwm_interrupt(struct stm32l4_pwmtimer_s *priv) * Description: * Handle timer 1 and 8 interrupts. * - * Input parameters: + * Input Parameters: * Standard NuttX interrupt inputs * * Returned Value: @@ -1553,7 +1553,7 @@ static int stm32l4pwm_tim8interrupt(int irq, void *context, FAR void *arg) * Description: * Pick an optimal pulse count to program the RCR. * - * Input parameters: + * Input Parameters: * count - The total count remaining * * Returned Value: @@ -1600,7 +1600,7 @@ static uint8_t stm32l4pwm_pulsecount(uint32_t count) * Description: * Enable or disable APB clock for the timer peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -1693,7 +1693,7 @@ static void stm32l4pwm_setapbclock(FAR struct stm32l4_pwmtimer_s *priv, bool on) * should configure and initialize the device so that it is ready for use. * It should not, however, output pulses until the start method is called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -1755,7 +1755,7 @@ static int stm32l4pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -1816,7 +1816,7 @@ static int stm32l4pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -1903,7 +1903,7 @@ static int stm32l4pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -2020,7 +2020,7 @@ static int stm32l4pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/stm32l4/stm32l4_qencoder.c b/arch/arm/src/stm32l4/stm32l4_qencoder.c index 9f8a20fc9f83c381fd5df9a2612e6f68fe644e80..683b2f62639e993920d700247057ce7aaea8aac5 100644 --- a/arch/arm/src/stm32l4/stm32l4_qencoder.c +++ b/arch/arm/src/stm32l4/stm32l4_qencoder.c @@ -504,7 +504,7 @@ static void stm32l4_putreg32(FAR struct stm32l4_lowerhalf_s *priv, int offset, * Description: * Dump all timer registers. * - * Input parameters: + * Input Parameters: * priv - A reference to the QENCODER block status * * Returned Value: @@ -1108,7 +1108,7 @@ static int stm32l4_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, unsigned lon * devpath - The full path to the driver to register. E.g., "/dev/qe0" * tim - The timer number to used. 'tim' must be an element of {1,2,3,4,5,8} * - * Returned Values: + * Returned Value: * Zero on success; A negated errno value is returned on failure. * ************************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_qencoder.h b/arch/arm/src/stm32l4/stm32l4_qencoder.h index 7fccca772b36b5ccd677ab4f95d5c635b9dde563..b2d2b445c6ab9250b748d76d76916be2f2bfd5ba 100644 --- a/arch/arm/src/stm32l4/stm32l4_qencoder.h +++ b/arch/arm/src/stm32l4/stm32l4_qencoder.h @@ -129,7 +129,7 @@ * devpath - The full path to the driver to register. E.g., "/dev/qe0" * tim - The timer number to used. 'tim' must be an element of {1,2,3,4,5,8} * - * Returned Values: + * Returned Value: * Zero on success; A negated errno value is returned on failure. * ************************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_qspi.c b/arch/arm/src/stm32l4/stm32l4_qspi.c index 793fbb7ffaf21028c204d5423d7799802752d7b5..cf303e71b430e52978a3489d90766661563e73fa 100644 --- a/arch/arm/src/stm32l4/stm32l4_qspi.c +++ b/arch/arm/src/stm32l4/stm32l4_qspi.c @@ -1447,7 +1447,7 @@ static int qspi_memory_dma(struct stm32l4_qspidev_s *priv, ret = wd_start(priv->dmadog, DMA_TIMEOUT_TICKS, (wdentry_t)qspi_dma_timeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { spierr("ERROR: wd_start failed: %d\n", ret); } @@ -2421,7 +2421,7 @@ static int qspi_hw_initialize(struct stm32l4_qspidev_s *priv) * Description: * Initialize the selected QSPI port in master mode * - * Input Parameter: + * Input Parameters: * intf - Interface number(must be zero) * * Returned Value: @@ -2594,7 +2594,7 @@ errout_with_dmahandles: * Description: * Put the QSPI device into memory mapped mode * - * Input Parameter: + * Input Parameters: * dev - QSPI device * meminfo - parameters like for a memory transfer used for reading * @@ -2686,7 +2686,7 @@ void stm32l4_qspi_enter_memorymapped(struct qspi_dev_s* dev, * Description: * Take the QSPI device out of memory mapped mode * - * Input Parameter: + * Input Parameters: * dev - QSPI device * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_qspi.h b/arch/arm/src/stm32l4/stm32l4_qspi.h index ed65850fc56e69e0e043a761d1f81574f336abd8..c9c87638ee2c7d5293349b1149c997543fd4315a 100644 --- a/arch/arm/src/stm32l4/stm32l4_qspi.h +++ b/arch/arm/src/stm32l4/stm32l4_qspi.h @@ -86,7 +86,7 @@ extern "C" * Description: * Initialize the selected QSPI port in master mode * - * Input Parameter: + * Input Parameters: * intf - Interface number(must be zero) * * Returned Value: @@ -103,7 +103,7 @@ FAR struct qspi_dev_s *stm32l4_qspi_initialize(int intf); * Description: * Put the QSPI device into memory mapped mode * - * Input Parameter: + * Input Parameters: * dev - QSPI device * meminfo - parameters like for a memory transfer used for reading * lpto - number of cycles to wait to automatically de-assert CS @@ -123,7 +123,7 @@ void stm32l4_qspi_enter_memorymapped(struct qspi_dev_s* dev, * Description: * Take the QSPI device out of memory mapped mode * - * Input Parameter: + * Input Parameters: * dev - QSPI device * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_sai.c b/arch/arm/src/stm32l4/stm32l4_sai.c index 80d07f024f37b217a9db77eed4d69ca00d069580..21892409d531e8e953f2abefc8542070535a3b37 100644 --- a/arch/arm/src/stm32l4/stm32l4_sai.c +++ b/arch/arm/src/stm32l4/stm32l4_sai.c @@ -479,7 +479,7 @@ static void sai_exclsem_take(struct stm32l4_sai_s *priv) * Setup the master clock divider based on the currently selected data width * and the sample rate * - * Input Parameter: + * Input Parameters: * priv - SAI device structure (only the sample rate and frequency are * needed at this point). * @@ -1288,7 +1288,7 @@ static void sai_buf_initialize(struct stm32l4_sai_s *priv) * Description: * Initialize the selected SAI port in its default state * - * Input Parameter: + * Input Parameters: * priv - private SAI device structure * * Returned Value: @@ -1353,7 +1353,7 @@ static void sai_portinitialize(struct stm32l4_sai_s *priv) * Description: * Initialize the selected SAI block * - * Input Parameter: + * Input Parameters: * intf - I2S interface number (identifying the "logical" SAI interface) * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_sdmmc.c b/arch/arm/src/stm32l4/stm32l4_sdmmc.c index 6da267d2d026ad70d7673833c7eedd7fc89a7109..38a7077d079066f03c500d7369a64395e0a24932 100644 --- a/arch/arm/src/stm32l4/stm32l4_sdmmc.c +++ b/arch/arm/src/stm32l4/stm32l4_sdmmc.c @@ -2637,7 +2637,7 @@ static sdio_eventset_t stm32_eventwait(FAR struct sdio_dev_s *dev, delay = MSEC2TICK(timeout); ret = wd_start(priv->waitwdog, delay, (wdentry_t)stm32_eventtimeout, 1, (uint32_t)priv); - if (ret != OK) + if (ret < 0) { mcerr("ERROR: wd_start failed: %d\n", ret); } @@ -3099,7 +3099,7 @@ static void stm32_default(struct stm32_dev_s *priv) * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -3234,7 +3234,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -3281,7 +3281,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot) * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_sdmmc.h b/arch/arm/src/stm32l4/stm32l4_sdmmc.h index 155cf209f1f29cc4a29e220448b178400a602a79..0882acbb74ed844134742ba087ca86cbeec4ec30 100644 --- a/arch/arm/src/stm32l4/stm32l4_sdmmc.h +++ b/arch/arm/src/stm32l4/stm32l4_sdmmc.h @@ -73,7 +73,7 @@ extern "C" * Input Parameters: * slotno - Not used. * - * Returned Values: + * Returned Value: * A reference to an SDIO interface structure. NULL is returned on failures. * ****************************************************************************/ @@ -95,7 +95,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno); * card has been removed from the slot. Only transitions * (inserted->removed or removed->inserted should be reported) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -113,7 +113,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); * dev - An instance of the SDIO driver device state structure. * wrprotect - true is a card is writeprotected. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4_serial.c b/arch/arm/src/stm32l4/stm32l4_serial.c index 67602e3c16909467c7a246bb0efc6dae47a97bfe..1cc67bb148f548095ddbb1f566559e208dfb570c 100644 --- a/arch/arm/src/stm32l4/stm32l4_serial.c +++ b/arch/arm/src/stm32l4/stm32l4_serial.c @@ -1218,7 +1218,7 @@ void stm32l4serial_pm_setsuspend(bool suspend) * Description: * Enable or disable APB clock for the USART peripheral * - * Input parameters: + * Input Parameters: * dev - A reference to the UART driver state structure * on - Enable clock if 'on' is 'true' and disable if 'false' * @@ -2100,7 +2100,7 @@ static bool stm32l4serial_rxavailable(FAR struct uart_dev_s *dev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is diff --git a/arch/arm/src/stm32l4/stm32l4_spi.c b/arch/arm/src/stm32l4/stm32l4_spi.c index 7f5d1543a1c7c0191a3cc1fb6e0d95ca5bb10a17..b98bd793e299b389ce49533f06dfba994d1bda04 100644 --- a/arch/arm/src/stm32l4/stm32l4_spi.c +++ b/arch/arm/src/stm32l4/stm32l4_spi.c @@ -1481,7 +1481,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t * Description: * Initialize the selected SPI bus in its default state (Master, 8-bit, mode 0, etc.) * - * Input Parameter: + * Input Parameters: * priv - private SPI device structure * * Returned Value: @@ -1571,7 +1571,7 @@ static void spi_bus_initialize(FAR struct stm32l4_spidev_s *priv) * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_spi.h b/arch/arm/src/stm32l4/stm32l4_spi.h index 7f5390f34778aa5636688698f0307cefa948de92..5d9f74db704f63e42b8b86a44da5deec156179f2 100644 --- a/arch/arm/src/stm32l4/stm32l4_spi.h +++ b/arch/arm/src/stm32l4/stm32l4_spi.h @@ -76,7 +76,7 @@ struct spi_dev_s; * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * bus number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/stm32l4/stm32l4_tim.h b/arch/arm/src/stm32l4/stm32l4_tim.h index 8362ef13875d1abe30384886dd8777065dcc7111..fa88892d3ad0006e4a5cccdca8a5fc9df5b9906a 100644 --- a/arch/arm/src/stm32l4/stm32l4_tim.h +++ b/arch/arm/src/stm32l4/stm32l4_tim.h @@ -204,7 +204,7 @@ int stm32l4_tim_deinit(FAR struct stm32l4_tim_dev_s *dev); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - the timer number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c b/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c index 59918c81ba9292ad26e2fa9e6ea98d336dc26af4..76f5bff364807f9d395e85d1bbe08809dc642fc7 100644 --- a/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c +++ b/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c @@ -231,7 +231,7 @@ static struct stm32l4_lowerhalf_s g_tim17_lowerhalf = * * Input Parameters: * - * Returned Values: + * Returned Value: * ****************************************************************************/ @@ -267,7 +267,7 @@ static int stm32l4_timer_handler(int irq, void *context, void *arg) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -305,7 +305,7 @@ static int stm32l4_start(FAR struct timer_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -339,7 +339,7 @@ static int stm32l4_stop(FAR struct timer_lowerhalf_s *lower) * driver state structure. * timeout - The new timeout value in microseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -385,7 +385,7 @@ static int stm32l4_settimeout(FAR struct timer_lowerhalf_s *lower, * behavior is restored, * arg - Argument that will be provided in the callback * - * Returned Values: + * Returned Value: * The previous timer expiration function pointer or NULL is there was * no previous function pointer. * @@ -432,7 +432,7 @@ static void stm32l4_setcallback(FAR struct timer_lowerhalf_s *lower, * form /dev/timer0 * timer - the timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/stm32l4/stm32l4_wdg.h b/arch/arm/src/stm32l4/stm32l4_wdg.h index 794c5e2aef83e3f4a73233171a47a4e93989c33c..0d2b0032538257bad6685d2a0feed1c6a42ccb6e 100644 --- a/arch/arm/src/stm32l4/stm32l4_wdg.h +++ b/arch/arm/src/stm32l4/stm32l4_wdg.h @@ -79,7 +79,7 @@ extern "C" * /dev/watchdog0 * lsifreq - The calibrated LSI clock frequency * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -100,7 +100,7 @@ void stm32l4_iwdginitialize(FAR const char *devpath, uint32_t lsifreq); * devpath - The full path to the watchdog. This should be of the form * /dev/watchdog0 * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/stm32l4/stm32l4x6xx_dma.c b/arch/arm/src/stm32l4/stm32l4x6xx_dma.c index cd194b2cba0b362c3f7a7773d7b404948ecf97b5..d727be752b8bd0deac4500a7d96afea6c53e03f4 100644 --- a/arch/arm/src/stm32l4/stm32l4x6xx_dma.c +++ b/arch/arm/src/stm32l4/stm32l4x6xx_dma.c @@ -394,7 +394,7 @@ void weak_function up_dmainitialize(void) * Hmm.. I suppose this interface could be extended to make a non-blocking * version. Feel free to do that if that is what you need. * - * Input parameter: + * Input Parameters: * chan - Identifies the stream/channel resource * This is a bit encoded value as provided by the DMACHAN_* definitions * in chip/stm32l4x6xx_dma.h @@ -642,7 +642,7 @@ size_t stm32l4_dmaresidual(DMA_HANDLE handle) * of the processor. Note that this only applies to memory addresses, it * will return false for any peripheral address. * - * Returned value: + * Returned Value: * True, if transfer is possible. * ****************************************************************************/ diff --git a/arch/arm/src/str71x/str71x.h b/arch/arm/src/str71x/str71x.h index 7b3bedf1df34e28e851cdd6044d976859cf4d7af..aea504fe89b7f867976f9135051977e2da53483f 100644 --- a/arch/arm/src/str71x/str71x.h +++ b/arch/arm/src/str71x/str71x.h @@ -162,7 +162,7 @@ struct spi_dev_s; /* Forward reference */ * Initialize the selected SPI port. This function could get called * multiple times for each STR7 devices that needs an SPI reference. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/str71x/str71x_head.S b/arch/arm/src/str71x/str71x_head.S index c35715e02d21e5010ca74a170e2a5b8803573420..934fd7fdfd181080e5723eb50b32013bcef1fe5d 100644 --- a/arch/arm/src/str71x/str71x_head.S +++ b/arch/arm/src/str71x/str71x_head.S @@ -346,7 +346,7 @@ eicloop: /***************************************************************************** * Name: periphinit * - * Description" + * Description: * Disable all perfipherals (except EIC) * *****************************************************************************/ diff --git a/arch/arm/src/tiva/Make.defs b/arch/arm/src/tiva/Make.defs index d65294d6c51984cac4bf41096183eb6a86c3f2b5..6e5c862d96e6136d1e19059d0cd73ab5fb15e751 100644 --- a/arch/arm/src/tiva/Make.defs +++ b/arch/arm/src/tiva/Make.defs @@ -36,7 +36,7 @@ HEAD_ASRC = tiva_vectors.S CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_idle.c up_initialize.c diff --git a/arch/arm/src/tiva/tiva_adc.h b/arch/arm/src/tiva/tiva_adc.h index 7f6edd4f9d8b741146a22623f2c3f6fe06c3d9d3..a717ad72f12fbe5a9b8a7d41e3976dfeb3ee03a1 100644 --- a/arch/arm/src/tiva/tiva_adc.h +++ b/arch/arm/src/tiva/tiva_adc.h @@ -405,7 +405,7 @@ void tiva_adc_sample_rate(uint8_t rate); * to the FIFO. This is only required when the trigger source is set to the * processor. * - * Input parameters: + * Input Parameters: * adc - which ADC peripherals' sample sequencers to trigger * sse_mask - sample sequencer bitmask, each sse is 1 shifted by the sse * number. e.g. @@ -424,7 +424,7 @@ void tiva_adc_proc_trig(uint8_t adc, uint8_t sse_mask); * Description: * Returns raw interrupt status for the input ADC * - * Input parameters: + * Input Parameters: * adc - which ADC peripherals' interrupt status to retrieve * ****************************************************************************/ @@ -440,12 +440,12 @@ uint32_t tiva_adc_int_status(uint8_t adc); * Sets the operation state of an ADC's sample sequencer (SSE). SSEs must * be configured before being enabled. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * state - sample sequencer enable/disable state * - * Return value: + * Returned Value: * Actual state of the ACTSS register. * ****************************************************************************/ @@ -466,7 +466,7 @@ uint8_t tiva_adc_sse_enable(uint8_t adc, uint8_t sse, bool state); * - Always * - !!UNSUPPORTED: Comparators * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * trigger - interrupt trigger @@ -482,7 +482,7 @@ void tiva_adc_sse_trigger(uint8_t adc, uint8_t sse, uint32_t trigger); * Additional triggering configuration for PWM. Sets which PWM and which * generator. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * cfg - which PWM modulator and generator to use, use TIVA_ADC_PWM_TRIG @@ -501,7 +501,7 @@ void tiva_adc_sse_pwm_trig(uint8_t adc, uint8_t sse, uint32_t cfg); * Sets the interrupt state of an ADC's sample sequencer (SSE). SSEs must * be enabled before setting interrupt state. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * state - sample sequencer enable/disable interrupt state @@ -516,7 +516,7 @@ void tiva_adc_sse_int_enable(uint8_t adc, uint8_t sse, bool state); * Description: * Returns interrupt status for the specificed SSE * - * Input parameters: + * Input Parameters: * adc - which ADC peripherals' interrupt status to retrieve * sse - which SSE interrupt status to retrieve * @@ -530,7 +530,7 @@ bool tiva_adc_sse_int_status(uint8_t adc, uint8_t sse); * Description: * Clears the interrupt bit for the SSE. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * state - sample sequencer @@ -547,11 +547,11 @@ void tiva_adc_sse_clear_int(uint8_t adc, uint8_t sse); * The input data buffer MUST be as large or larger than the sample sequencer. * otherwise * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * - * Return value: + * Returned Value: * number of steps read from FIFO. * ****************************************************************************/ @@ -566,7 +566,7 @@ uint8_t tiva_adc_sse_data(uint8_t adc, uint8_t sse, int32_t *buf); * priority value ranges from 0 to 3, 0 being the highest priority, 3 being * the lowest. There can be no duplicate values. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * priority - conversion priority @@ -585,7 +585,7 @@ void tiva_adc_sse_priority(uint8_t adc, uint8_t sse, uint8_t priority); * * *SSEMUX only supported on TM4C129 devices * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer step @@ -601,7 +601,7 @@ void tiva_adc_sse_register_chn(uint8_t adc, uint8_t sse, uint8_t chn, uint32_t a * Description: * Sets the differential capability for a SSE. !! UNSUPPORTED * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer channel @@ -620,7 +620,7 @@ void tiva_adc_sse_differential(uint8_t adc, uint8_t sse, uint8_t chn, uint32_t d * This is not available on all devices, however on devices that do not * support this feature these reserved bits are ignored on write access. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer channel @@ -652,7 +652,7 @@ void tiva_adc_sse_sample_hold_time(uint8_t adc, uint8_t sse, uint8_t chn, uint32 * * *Comparator/Differential functionality is unsupported and ignored. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer channel @@ -669,7 +669,7 @@ void tiva_adc_sse_step_cfg(uint8_t adc, uint8_t sse, uint8_t chn, uint8_t cfg); * Dump all configured registers for the given ADC and SSE. This should * only be used to verify that configuration routines were accurate. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * diff --git a/arch/arm/src/tiva/tiva_adclib.c b/arch/arm/src/tiva/tiva_adclib.c index dc2768fc16300c4b831e15e2bff9a01cef62afc1..8d55333a026950c355446c007c2b4822f668c929 100644 --- a/arch/arm/src/tiva/tiva_adclib.c +++ b/arch/arm/src/tiva/tiva_adclib.c @@ -624,7 +624,7 @@ void tiva_adc_sample_rate(uint8_t rate) * to the FIFO. This is only required when the trigger source is set to the * processor. * - * Input parameters: + * Input Parameters: * adc - which ADC peripherals' sample sequencers to trigger * sse_mask - sample sequencer bitmask, each sse is 1 shifted by the sse * number. e.g. @@ -650,7 +650,7 @@ void tiva_adc_proc_trig(uint8_t adc, uint8_t sse_mask) * Description: * Returns raw interrupt status for the input ADC * - * Input parameters: + * Input Parameters: * adc - which ADC peripherals' interrupt status to retrieve * ****************************************************************************/ @@ -670,12 +670,12 @@ uint32_t tiva_adc_int_status(uint8_t adc) * Sets the operation state of an ADC's sample sequencer (SSE). SSEs must * be configured before being enabled. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * state - sample sequencer enable/disable state * - * Return value: + * Returned Value: * Actual state of the ACTSS register. * ****************************************************************************/ @@ -711,7 +711,7 @@ uint8_t tiva_adc_sse_enable(uint8_t adc, uint8_t sse, bool state) * - Always * - !!UNSUPPORTED: Comparators * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * trigger - interrupt trigger @@ -736,7 +736,7 @@ void tiva_adc_sse_trigger(uint8_t adc, uint8_t sse, uint32_t trigger) * Additional triggering configuration for PWM. Sets which PWM and which * generator. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * cfg - which PWM modulator and generator to use, use TIVA_ADC_PWM_TRIG @@ -762,7 +762,7 @@ void tiva_adc_sse_pwm_trig(uint8_t adc, uint8_t sse, uint32_t cfg) * Sets the interrupt state of an ADC's sample sequencer (SSE). SSEs must * be enabled before setting interrupt state. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * state - sample sequencer enable/disable interrupt state @@ -799,7 +799,7 @@ void tiva_adc_sse_int_enable(uint8_t adc, uint8_t sse, bool state) * Description: * Returns interrupt status for the specificed SSE * - * Input parameters: + * Input Parameters: * adc - which ADC peripherals' interrupt status to retrieve * sse - which SSE interrupt status to retrieve * @@ -818,7 +818,7 @@ bool tiva_adc_sse_int_status(uint8_t adc, uint8_t sse) * Description: * Clears the interrupt bit for the SSE. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * state - sample sequencer @@ -839,11 +839,11 @@ void tiva_adc_sse_clear_int(uint8_t adc, uint8_t sse) * The input data buffer MUST be as large or larger than the sample sequencer. * otherwise * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * - * Return value: + * Returned Value: * number of steps read from FIFO. * ****************************************************************************/ @@ -880,7 +880,7 @@ uint8_t tiva_adc_sse_data(uint8_t adc, uint8_t sse, int32_t *buf) * priority value ranges from 0 to 3, 0 being the highest priority, 3 being * the lowest. There can be no duplicate values. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * priority - conversion priority @@ -906,7 +906,7 @@ void tiva_adc_sse_priority(uint8_t adc, uint8_t sse, uint8_t priority) * * *SSEMUX only supported on TM4C129 devices * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer step @@ -940,7 +940,7 @@ void tiva_adc_sse_register_chn(uint8_t adc, uint8_t sse, uint8_t chn, * Description: * Sets the differential capability for a SSE. !! UNSUPPORTED * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer channel @@ -970,7 +970,7 @@ void tiva_adc_sse_differential(uint8_t adc, uint8_t sse, uint8_t chn, uint32_t d * This is not available on all devices, however on devices that do not * support this feature these reserved bits are ignored on write access. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer channel @@ -1007,7 +1007,7 @@ void tiva_adc_sse_sample_hold_time(uint8_t adc, uint8_t sse, * * *Comparator/Differential functionality is unsupported and ignored. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * chn - sample sequencer channel @@ -1029,7 +1029,7 @@ void tiva_adc_sse_step_cfg(uint8_t adc, uint8_t sse, uint8_t chn, uint8_t cfg) * Dump all configured registers for the given ADC and SSE. This should * only be used to verify that configuration routines were accurate. * - * Input parameters: + * Input Parameters: * adc - peripheral state * sse - sample sequencer * diff --git a/arch/arm/src/tiva/tiva_adclow.c b/arch/arm/src/tiva/tiva_adclow.c index 577a430d2f59103922cf151946322917e6837a43..3d7262b0153c62b1855f698f227698807aa20c3c 100644 --- a/arch/arm/src/tiva/tiva_adclow.c +++ b/arch/arm/src/tiva/tiva_adclow.c @@ -655,7 +655,7 @@ static int tiva_adc_ioctl(struct adc_dev_s *dev, int cmd, unsigned long arg) * are disabled when this function runs. tiva_adc_read will * re-enable interrupts when it completes processing all pending events. * - * Input Parameters + * Input Parameters: * arg - The ADC SSE data structure cast to (void *) * * Returned Value: diff --git a/arch/arm/src/tiva/tiva_gpioirq.c b/arch/arm/src/tiva/tiva_gpioirq.c index 112887f8bf4bd049717188c797c68affeb835871..a5d0e3dbe3edd6b21de1d1c0216052c157e0824f 100644 --- a/arch/arm/src/tiva/tiva_gpioirq.c +++ b/arch/arm/src/tiva/tiva_gpioirq.c @@ -672,7 +672,7 @@ int tiva_gpioirqinitialize(void) * disabled to stop further interrupts. Otherwise, the new isr is linked * and the pin's interrupt mask is set. * - * Returns: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * return to indicate the nature of the failure. * diff --git a/arch/arm/src/tiva/tiva_i2c.h b/arch/arm/src/tiva/tiva_i2c.h index 33acca1116ca53075dce38f3b3c4a923d53560af..c43e167f8688fe078b2feea51e1591e491303888 100644 --- a/arch/arm/src/tiva/tiva_i2c.h +++ b/arch/arm/src/tiva/tiva_i2c.h @@ -59,7 +59,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -75,7 +75,7 @@ FAR struct i2c_master_s *tiva_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the tiva_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/tiva/tiva_pwm.c b/arch/arm/src/tiva/tiva_pwm.c index 0e882f0f7c11ccfff7b3564d7ebd4babd1a2f1ec..b25e27225560f9a3db2fbf3efeeab9ba8299146d 100644 --- a/arch/arm/src/tiva/tiva_pwm.c +++ b/arch/arm/src/tiva/tiva_pwm.c @@ -421,7 +421,7 @@ static inline void tiva_pwm_putreg(struct tiva_pwm_chan_s *chan, * use. It will not, however, output pulses until the start method is * called. * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -457,7 +457,7 @@ static int tiva_pwm_setup(FAR struct pwm_lowerhalf_s *dev) * stop pulsed output, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -487,7 +487,7 @@ static int tiva_pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) * Description: * (Re-)initialize the timer resources and start the pulsed output * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * handle - This is the handle that was provided to the lower-half @@ -569,7 +569,7 @@ static int tiva_pwm_start(FAR struct pwm_lowerhalf_s *dev, * Description: * Configure PWM registers and start the PWM timer * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * info - A reference to the characteristics of the pulsed output * @@ -659,7 +659,7 @@ static inline int tiva_pwm_timer(FAR struct tiva_pwm_chan_s *chan, * Description: * Stop the pulsed output and reset the timer resources * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * * Returned Value: @@ -692,7 +692,7 @@ static int tiva_pwm_stop(FAR struct pwm_lowerhalf_s *dev) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * dev - A reference to the lower half PWM driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command diff --git a/arch/arm/src/tiva/tiva_qencoder.c b/arch/arm/src/tiva/tiva_qencoder.c index b25f6dce183f4c4896a9edb1b91bdcefde73aa44..a10eb6577d1a93c19dc120d8196e32bec45ca1ea 100644 --- a/arch/arm/src/tiva/tiva_qencoder.c +++ b/arch/arm/src/tiva/tiva_qencoder.c @@ -177,7 +177,7 @@ static inline void tiva_qe_putreg(struct tiva_qe_s *qe, unsigned int offset, * use. It will not, however, output pulses until the start method is * called. * - * Input parameters: + * Input Parameters: * lower - A reference to the lower half QEI driver state structure * * Returned Value: @@ -260,7 +260,7 @@ static int tiva_qe_setup(FAR struct qe_lowerhalf_s *lower) * stop data collection, free any resources, disable the timer hardware, and * put the system into the lowest possible power usage state * - * Input parameters: + * Input Parameters: * lower - A reference to the lower half QEI driver state structure * * Returned Value: @@ -287,7 +287,7 @@ static int tiva_qe_shutdown(FAR struct qe_lowerhalf_s *lower) * Description: * Reset the position measurement to zero. * - * Input parameters: + * Input Parameters: * lower - A reference to the lower half QEI driver state structure * * Returned Value: @@ -312,7 +312,7 @@ static int tiva_qe_reset(FAR struct qe_lowerhalf_s *lower) * Description: * Return the position mesaured by QEI. * - * Input parameters: + * Input Parameters: * lower - A reference to the lower half QEI driver state structure * pos - pointer to the position returned * @@ -338,7 +338,7 @@ static int tiva_qe_position(FAR struct qe_lowerhalf_s *lower, FAR int32_t *pos) * Description: * Lower-half logic may support platform-specific ioctl commands * - * Input parameters: + * Input Parameters: * lower - A reference to the lower half QEI driver state structure * cmd - The ioctl command * arg - The argument accompanying the ioctl command @@ -383,7 +383,7 @@ static int tiva_qe_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, * Description: * Return the direction mesaured by QEI. * - * Input parameters: + * Input Parameters: * qe - A reference to the TIVA QEI structure * dir - pointer to the direction returned * @@ -414,7 +414,7 @@ static int tiva_qe_direction(FAR struct tiva_qe_s *qe, unsigned long *dir) * Description: * Return the velocity (A/B pulses per second) mesaured by QEI. * - * Input parameters: + * Input Parameters: * qe - A reference to the TIVA QEI structure * * Returned Value: @@ -437,7 +437,7 @@ static int tiva_qe_velocity(FAR struct tiva_qe_s *qe, unsigned long *vel) * Description: * Set reset mode as MAXPOS and also set maxpos value * - * Input parameters: + * Input Parameters: * qe - A reference to the TIVA QEI structure * ppr - pulses per round of encoder * diff --git a/arch/arm/src/tiva/tiva_ssi.c b/arch/arm/src/tiva/tiva_ssi.c index bd224363b07fa25a4aee39f00f62e319e1f835bb..d64e4dccddf3a14bfe18bdc7326bdf6add73a225 100644 --- a/arch/arm/src/tiva/tiva_ssi.c +++ b/arch/arm/src/tiva/tiva_ssi.c @@ -1495,7 +1495,7 @@ static void ssi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SSI interfaces) * * Returned Value: diff --git a/arch/arm/src/tiva/tiva_ssi.h b/arch/arm/src/tiva/tiva_ssi.h index d0976c2aee965aa4cb141ff6d018cd24cebd4242..8027ae33664124fb1e1661e4b841e51585fa2369 100644 --- a/arch/arm/src/tiva/tiva_ssi.h +++ b/arch/arm/src/tiva/tiva_ssi.h @@ -70,7 +70,7 @@ extern "C" * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SSI interfaces) * * Returned Value: diff --git a/arch/arm/src/tiva/tiva_timer.h b/arch/arm/src/tiva/tiva_timer.h index 547cd117041737a23e8d420c81cf5226d1638c3a..f5d9c6f9fe1c0b1b70efbcf4202d6c591e08dc0e 100644 --- a/arch/arm/src/tiva/tiva_timer.h +++ b/arch/arm/src/tiva/tiva_timer.h @@ -835,7 +835,7 @@ static inline void tiva_gptm0_synchronize(uint32_t sync) * form /dev/timer0 * config - 32-bit timer configuration values. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/tiva/tiva_timerlow32.c b/arch/arm/src/tiva/tiva_timerlow32.c index 91f44618b00f2d3408d6d3def8ae3c3e98192481..9807588ec265518ed79624b49a50196d71c5f629 100644 --- a/arch/arm/src/tiva/tiva_timerlow32.c +++ b/arch/arm/src/tiva/tiva_timerlow32.c @@ -133,7 +133,7 @@ static const struct timer_ops_s g_timer_ops = * priv - A pointer to a private timer driver lower half instance * usecs - The number of usecs to convert * - * Returned Values: + * Returned Value: * The time converted to clock ticks. * ****************************************************************************/ @@ -161,7 +161,7 @@ static uint32_t tiva_usec2ticks(struct tiva_lowerhalf_s *priv, uint32_t usecs) * priv - A pointer to a private timer driver lower half instance * usecs - The number of ticks to convert * - * Returned Values: + * Returned Value: * The time converted to microseconds. * ****************************************************************************/ @@ -189,7 +189,7 @@ static uint32_t tiva_ticks2usec(struct tiva_lowerhalf_s *priv, uint32_t ticks) * priv - A pointer to a private timer driver lower half instance * timeout - The new timeout value in microseconds. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -224,7 +224,7 @@ static void tiva_timeout(struct tiva_lowerhalf_s *priv, uint32_t timeout) * Input Parameters: * Usual 32-bit timer interrupt handler arguments. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -287,7 +287,7 @@ static void tiva_timer_handler(TIMER_HANDLE handle, void *arg, uint32_t status) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -324,7 +324,7 @@ static int tiva_start(struct timer_lowerhalf_s *lower) * lower - A pointer the publicly visible representation of the "lower-half" * driver state structure. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -362,7 +362,7 @@ static int tiva_stop(struct timer_lowerhalf_s *lower) * driver state structure. * status - The location to return the status information. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -415,7 +415,7 @@ static int tiva_getstatus(struct timer_lowerhalf_s *lower, * driver state structure. * timeout - The new timeout value in microseconds. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -456,7 +456,7 @@ static int tiva_settimeout(struct timer_lowerhalf_s *lower, uint32_t timeout) * function pointer is NULL, then the reset-on-expiration * behavior is restored, * - * Returned Values: + * Returned Value: * The previous timer expiration function pointer or NULL is there was * no previous function pointer. * @@ -496,7 +496,7 @@ static void tiva_setcallback(struct timer_lowerhalf_s *lower, * interpretation of this argument depends on the particular * command. * - * Returned Values: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ @@ -535,7 +535,7 @@ static int tiva_ioctl(struct timer_lowerhalf_s *lower, int cmd, * form /dev/timer0 * config - 32-bit timer configuration values. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/arm/src/tiva/tm4c_ethernet.c b/arch/arm/src/tiva/tm4c_ethernet.c index 3458db363cda53c93fafa766c9eb98be8c5a9ca5..be2dd123502b0d194e60f1e47faedc1431d136b3 100644 --- a/arch/arm/src/tiva/tm4c_ethernet.c +++ b/arch/arm/src/tiva/tm4c_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/tiva/tm4c_ethernet.c * - * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -733,7 +733,7 @@ static int tiva_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int tiva_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int tiva_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2860,59 +2860,61 @@ static void tiva_rxdescinit(FAR struct tiva_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int tiva_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { int ret; switch (cmd) - { -#ifdef CONFIG_TIVA_PHY_INTERRUPTS - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_TIVA_PHY_INTERRUPTS + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - tiva_phy_intenable(true); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + tiva_phy_intenable(true); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = CONFIG_TIVA_PHYADDR; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = CONFIG_TIVA_PHYADDR; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = tiva_phyread(req->phy_id, req->reg_num, &req->val_out); - } - break; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = tiva_phyread(req->phy_id, req->reg_num, &req->val_out); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = tiva_phywrite(req->phy_id, req->reg_num, req->val_in); - } - break; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = tiva_phywrite(req->phy_id, req->reg_num, req->val_in); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: tiva_phy_intenable @@ -4040,7 +4042,7 @@ int tiva_ethinitialize(int intf) priv->dev.d_addmac = tiva_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = tiva_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = tiva_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_tiva_ethmac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/tms570/Make.defs b/arch/arm/src/tms570/Make.defs index 9d1d32f627bcbae1f7cedee949733e3f7f60b49a..c1103a2f012ae7d7ab581e44ccd4aebdf21784b7 100644 --- a/arch/arm/src/tms570/Make.defs +++ b/arch/arm/src/tms570/Make.defs @@ -42,7 +42,7 @@ HEAD_ASRC = arm_vectortab.S CMN_ASRCS += arm_vectors.S arm_head.S arm_fullcontextrestore.S CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S arm_vfork.S -CMN_ASRCS += arm_testset.S +CMN_ASRCS += arm_testset.S arm_fetchadd.S CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S CMN_ASRCS += cp15_invalidate_dcache_all.S diff --git a/arch/arm/src/tms570/tms570_irq.c b/arch/arm/src/tms570/tms570_irq.c index 11d606d637e5cc6a5c26d5cda365e8d9d9e8bd72..33f2890b749f7762d3621921b6fc7f05b02a674b 100644 --- a/arch/arm/src/tms570/tms570_irq.c +++ b/arch/arm/src/tms570/tms570_irq.c @@ -198,7 +198,7 @@ void up_irqinitialize(void) * the irq number of the interrupt and then to call arm_doirq to dispatch * the interrupt. * - * Input parameters: + * Input Parameters: * regs - A pointer to the register save area on the stack. * ****************************************************************************/ @@ -240,7 +240,7 @@ uint32_t *arm_decodeirq(uint32_t *regs) * the irq number of the interrupt and then to call arm_doirq to dispatch * the interrupt. * - * Input parameters: + * Input Parameters: * regs - A pointer to the register save area on the stack. * ****************************************************************************/ diff --git a/arch/arm/src/tms570/tms570_selftest.h b/arch/arm/src/tms570/tms570_selftest.h index 696bc54fe3b1382d3b95321b9fc1f873fe16ad2f..727510fe329c6e1825a5fb8ce8fbd1e0fc19a864 100644 --- a/arch/arm/src/tms570/tms570_selftest.h +++ b/arch/arm/src/tms570/tms570_selftest.h @@ -90,7 +90,7 @@ void tms570_memtest_selftest(void); * Description: * Start the memory test on the selected set of RAMs. * - * Input Paramters: + * Input Parameters: * rinfol - The OR of each RAM grouping bit. See the PBIST_RINFOL* * definitions in chip/tms570_pbist.h * diff --git a/arch/arm/src/xmc4/Make.defs b/arch/arm/src/xmc4/Make.defs index 76ddb95391e3abc6aaeea5b0e97cd213e783a977..2b6fb0c62c3570aab259fdf893eafc5b80efe9a9 100644 --- a/arch/arm/src/xmc4/Make.defs +++ b/arch/arm/src/xmc4/Make.defs @@ -43,7 +43,7 @@ CMN_UASRCS = CMN_UCSRCS = CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S -CMN_ASRCS += up_testset.S vfork.S +CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c up_createstack.c CMN_CSRCS += up_mdelay.c up_udelay.c up_exit.c up_initialize.c up_memfault.c diff --git a/arch/arm/src/xmc4/chip/xmc4_scu.h b/arch/arm/src/xmc4/chip/xmc4_scu.h index 2d22084252de1c253174777c9ad478bf12b2f7ae..afa4d0f8a7f37d3e0ac7b0b7034776c21d8b6bfd 100644 --- a/arch/arm/src/xmc4/chip/xmc4_scu.h +++ b/arch/arm/src/xmc4/chip/xmc4_scu.h @@ -938,7 +938,7 @@ #define SCU_SLEEPCR_SYSSEL (1 << 0) /* Bit 0: System Clock Selection Value */ # define SCU_SLEEPCR_SYSSEL_OFI (0) /* 0=fOFI */ -# define SCU_SLEEPCR_SYSSEL_ PLL (1 << 0) /* 1=fPLL */ +# define SCU_SLEEPCR_SYSSEL_FPLL (1 << 0) /* 1=fPLL */ #define SCU_SLEEPCR_USBCR (1 << 16) /* Bit 6: USB Clock Control in Sleep Mode */ #define SCU_SLEEPCR_MMCCR (1 << 17) /* Bit 17: MMC Clock Control in Sleep Mode */ #define SCU_SLEEPCR_ETH0CR (1 << 18) /* Bit 18: Ethernet Clock Control in Sleep Mode */ diff --git a/arch/arm/src/xmc4/chip/xmc4_usic.h b/arch/arm/src/xmc4/chip/xmc4_usic.h index 0ca992d548f2ca56b7e5f2be40906ba30b7c1319..af43e11f9000661e610466ab07f75eea86e36d03 100644 --- a/arch/arm/src/xmc4/chip/xmc4_usic.h +++ b/arch/arm/src/xmc4/chip/xmc4_usic.h @@ -465,7 +465,12 @@ # define USIC_BRG_PDIV(n) ((uint32_t)(n) << USIC_BRG_PDIV_SHIFT) #define USIC_BRG_SCLKOSEL (1 << 28) /* Bit 28: Shift Clock Output Select */ #define USIC_BRG_MCLKCFG (1 << 29) /* Bit 29: Master Clock Configuration */ -#define USIC_BRG_SCLKCFG (1 << 30) /* Bit 30: Shift Clock Output Configuration */ +#define USIC_BRG_SCLKCFG_SHIFT 30 /* Bits 30-31: Shift Clock Output Configuration */ +#define USIC_BRG_SCLKCFG_MASK (3 << USIC_BRG_SCLKCFG_SHIFT) +# define USIC_BRG_SCLKCFG_NOINVNODLY (0 << USIC_BRG_SCLKCFG_SHIFT) /* No inverted signal and no delay */ +# define USIC_BRG_SCLKCFG_INVNODLY (1 << USIC_BRG_SCLKCFG_SHIFT) /* Inverted signal and no delay */ +# define USIC_BRG_SCLKCFG_NOINVDLY (2 << USIC_BRG_SCLKCFG_SHIFT) /* No inverted signal and 1/2 delay */ +# define USIC_BRG_SCLKCFG_INVDLY (3 << USIC_BRG_SCLKCFG_SHIFT) /* Inverted signal and 1/2 delay */ /* Interrupt Node Pointer Register */ diff --git a/arch/arm/src/xmc4/xmc4_clockconfig.c b/arch/arm/src/xmc4/xmc4_clockconfig.c index eeb71dbe0b476adb8e31ca1c5f268aea7c991cac..9d6cc0621eb93a7a3a31faf7cf04c6466bb82d01 100644 --- a/arch/arm/src/xmc4/xmc4_clockconfig.c +++ b/arch/arm/src/xmc4/xmc4_clockconfig.c @@ -58,6 +58,7 @@ #include "up_arch.h" #include "chip/xmc4_scu.h" #include "xmc4_clockconfig.h" +#include "chip/xmc4_ports.h" #include @@ -105,7 +106,7 @@ #define CLKSET_VALUE (0x00000000) #define USBCLKCR_VALUE (0x00010000) -#if BOARD_PBDIV == 1 +#if BOARD_PLL_PBDIV == 1 # define PBCLKCR_VALUE SCU_PBCLKCR_PBDIV_FCPU #else /* BOARD_PBDIV == 2 */ # define PBCLKCR_VALUE SCU_PBCLKCR_PBDIV_DIV2 @@ -387,8 +388,8 @@ void xmc4_clock_configure(void) /* Setup fSYS clock */ - regval = (BOARD_ENABLE_PLL << SCU_SYSCLKCR_SYSSEL); - regval |= SCU_SYSCLKCR_SYSDIV(BOARD_SYSDIV); + regval = (BOARD_ENABLE_PLL ? SCU_SYSCLKCR_SYSSEL : 0); + regval |= SCU_SYSCLKCR_SYSDIV(BOARD_PLL_SYSDIV); putreg32(regval, XMC4_SCU_SYSCLKCR); /* Setup peripheral clock divider */ @@ -411,7 +412,7 @@ void xmc4_clock_configure(void) /* Setup EBU clock */ - regval = SCU_EBUCLKCR_EBUDIV(BOARD_EBUDIV); + regval = SCU_EBUCLKCR_EBUDIV(BOARD_PLL_EBUDIV); putreg32(regval, XMC4_SCU_EBUCLKCR); #ifdef BOARD_ENABLE_USBPLL @@ -423,7 +424,7 @@ void xmc4_clock_configure(void) /* Setup EXT */ regval = (BOARD_EXT_SOURCE << SCU_EXTCLKCR_ECKSEL_SHIFT); - regval |= SCU_EXTCLKCR_ECKDIV(BOARD_EXTDIV); + regval |= SCU_EXTCLKCR_ECKDIV(BOARD_PLL_ECKDIV); putreg32(regval, XMC4_SCU_EXTCLKCR); #if BOARD_ENABLE_PLL @@ -561,4 +562,30 @@ void xmc4_clock_configure(void) /* Enable selected clocks */ putreg32(CLKSET_VALUE, XMC4_SCU_CLKSET); + +#if BOARD_PLL_CLOCKSRC_XTAL == 1 + regval = SCU_SLEEPCR_SYSSEL_FPLL; + putreg32(regval, XMC4_SCU_SLEEPCR); +#endif /* BOARD_PLL_CLOCKSRC_XTAL == 1 */ + +#if BOARD_EXTCKL_ENABLE +#if BOARD_EXTCLK_PIN == EXTCLK_PIN_P0_8 + /* enable EXTCLK output on P0.8 */ + regval = getreg32(XMC4_PORT0_HWSEL); + regval &= ~PORT_HWSEL_HW8_MASK; + putreg32(regval, XMC4_PORT0_HWSEL); + + regval = getreg32(XMC4_PORT0_PDR1); + regval &= ~PORT_PDR1_PD8_MASK; + putreg32(regval, XMC4_PORT0_PDR1); + + regval = getreg32(XMC4_PORT0_IOCR8); + regval &= ~PORT_IOCR8_PC8_MASK; + regval |= PORT_IOCR8_PC8(0x11); /* push-pull output, alt func 1 */ + putreg32(regval, XMC4_PORT0_IOCR8); +#else + /* enable EXTCLK output on P1.15 */ +# warn "Not yet implemented" +#endif +#endif } diff --git a/arch/arm/src/xmc4/xmc4_i2c.h b/arch/arm/src/xmc4/xmc4_i2c.h index f4a167b713da70f745271b81cd65db2ad073c256..74f8acb1684b8a0280772a6af4f523a3c7ec3834 100644 --- a/arch/arm/src/xmc4/xmc4_i2c.h +++ b/arch/arm/src/xmc4/xmc4_i2c.h @@ -57,7 +57,7 @@ * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -73,7 +73,7 @@ FAR struct i2c_master_s *xmc4_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the lpc43_i2cbus_initialize() * * Returned Value: diff --git a/arch/arm/src/xmc4/xmc4_serial.c b/arch/arm/src/xmc4/xmc4_serial.c index fef3ac077343de3e9ec41c502ed8034652afbdf9..36a23e91d768d4f8632d1a5fd129820eed1f98bd 100644 --- a/arch/arm/src/xmc4/xmc4_serial.c +++ b/arch/arm/src/xmc4/xmc4_serial.c @@ -1073,7 +1073,7 @@ void xmc4_earlyserialinit(void) * Input Parameters: * None * - * Returns Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/arch/arm/src/xmc4/xmc4_spi.h b/arch/arm/src/xmc4/xmc4_spi.h index 5113665eda26e05fd911db8e65c08b63efad90c6..73f4d69d4d92d84da1d6903a4f64238c8c534310 100644 --- a/arch/arm/src/xmc4/xmc4_spi.h +++ b/arch/arm/src/xmc4/xmc4_spi.h @@ -75,7 +75,7 @@ struct spi_dev_s; * Description: * Initialize the selected SPI bus * - * Input Parameter: + * Input Parameters: * bus number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/arm/src/xmc4/xmc4_start.c b/arch/arm/src/xmc4/xmc4_start.c index d1a1b4a1c3f79c6a866ffe67c2794481ec6c4836..5e65aecaac7ca80afe719ddf4b62427cde9627ad 100644 --- a/arch/arm/src/xmc4/xmc4_start.c +++ b/arch/arm/src/xmc4/xmc4_start.c @@ -396,9 +396,17 @@ void __start(void) /* Then start NuttX */ +#ifdef CONFIG_STACK_COLORATION + /* Set the IDLE stack to the coloration value and jump into os_start() */ + + go_os_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE); +#else + /* Call os_start() */ + os_start(); /* Shouldn't get here */ for (; ; ); +#endif } diff --git a/arch/avr/src/at32uc3/at32uc3_gpioirq.c b/arch/avr/src/at32uc3/at32uc3_gpioirq.c index 66e82476554a7ddedcc92b2e395b74a059a30276..03b704e08adf11ca0f70c10b81c2498ddb36c2f7 100644 --- a/arch/avr/src/at32uc3/at32uc3_gpioirq.c +++ b/arch/avr/src/at32uc3/at32uc3_gpioirq.c @@ -81,7 +81,7 @@ static struct g_gpiohandler_s g_gpiohandler[NR_GPIO_IRQS]; /**************************************************************************** * Name: gpio_baseaddress * - * Input: + * Input Parameters: * irq - A IRQ number in the range of 0 to NR_GPIO_IRQS. * * Description: @@ -114,7 +114,7 @@ static inline uint32_t gpio_baseaddress(unsigned int irq) /**************************************************************************** * Name: gpio_pin * - * Input: + * Input Parameters: * irq - A IRQ number in the range of 0 to NR_GPIO_IRQS. * * Description: diff --git a/arch/avr/src/avr/avr.h b/arch/avr/src/avr/avr.h index 0326d6d8488af3b8cf03c68d63afcb6fdae19bda..2e0c72ee38f9dafa6673b8742f6e51994050f764 100644 --- a/arch/avr/src/avr/avr.h +++ b/arch/avr/src/avr/avr.h @@ -144,7 +144,7 @@ uint8_t *up_doirq(uint8_t irq, uint8_t *regs); * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/avr/src/avr/up_blocktask.c b/arch/avr/src/avr/up_blocktask.c index b03b967badadebafc3e5fb5ef845bb3d238e5730..868a517b404cfaef7fb4620b31ecd6e9dbcb1f62 100644 --- a/arch/avr/src/avr/up_blocktask.c +++ b/arch/avr/src/avr/up_blocktask.c @@ -61,7 +61,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/avr/src/avr/up_checkstack.c b/arch/avr/src/avr/up_checkstack.c index 725a234d1a3f482626d927192f4fbf2aa533911d..96152af0d6bb53027d5ae0f5f9b32be5cc15be17 100644 --- a/arch/avr/src/avr/up_checkstack.c +++ b/arch/avr/src/avr/up_checkstack.c @@ -74,7 +74,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size); * alloc - Allocation base address of the stack * size - The size of the stack in bytes * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ @@ -154,7 +154,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * Input Parameters: * None * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ diff --git a/arch/avr/src/avr/up_createstack.c b/arch/avr/src/avr/up_createstack.c index 54efb1a3fb53f917fb55ac1b18116eda1d513715..d54b2049fe63e4008b2903ca820bf376a08118df 100644 --- a/arch/avr/src/avr/up_createstack.c +++ b/arch/avr/src/avr/up_createstack.c @@ -81,7 +81,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/avr/src/avr/up_reprioritizertr.c b/arch/avr/src/avr/up_reprioritizertr.c index 846b59becf62f3f90196124d25eae4a734d899d8..28323ffbb73f606706f08f400e2982633a39cf44 100644 --- a/arch/avr/src/avr/up_reprioritizertr.c +++ b/arch/avr/src/avr/up_reprioritizertr.c @@ -67,7 +67,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/avr/src/avr/up_spi.c b/arch/avr/src/avr/up_spi.c index 24a4f377cbd09f2932a90e03951ef49adaaf7da7..98742cf4e20a185776a72e12946ae2dcc16311ab 100644 --- a/arch/avr/src/avr/up_spi.c +++ b/arch/avr/src/avr/up_spi.c @@ -440,7 +440,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/avr/src/avr/up_stackframe.c b/arch/avr/src/avr/up_stackframe.c index 0f7d3a87463e1148abbd400b557edd8843fc142f..71c38c8aa441291da17fe40405040771db4f7223 100644 --- a/arch/avr/src/avr/up_stackframe.c +++ b/arch/avr/src/avr/up_stackframe.c @@ -86,7 +86,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/avr/src/avr/up_switchcontext.S b/arch/avr/src/avr/up_switchcontext.S index 3fc1b6ae42e83418d6d2fc069c9f1066530276bb..c5613b9814eda7c59c2d44955c638fe7e37e4bd7 100644 --- a/arch/avr/src/avr/up_switchcontext.S +++ b/arch/avr/src/avr/up_switchcontext.S @@ -74,7 +74,7 @@ * r24-r25: savregs * r22-r23: restoreregs * - * Return: + * Returned Value: * up_switchcontext forces a context switch to the task "canned" in restoreregs. * It does not 'return' in the normal sense, rather, it will context switch back * to the function point. When it does 'return,' it is because the blocked @@ -106,7 +106,7 @@ up_switchcontext: /**************************************************************************** * Name: up_fullcontextrestore * - * Descripion: + * Description: * Restore the full-running context of a thread. * * Input Parameters: diff --git a/arch/avr/src/avr/up_unblocktask.c b/arch/avr/src/avr/up_unblocktask.c index d70b65405cd2af723ba9e307ab329776c5f5b120..cea4c6df79c1c7c68eb4bea6c5af3d5e212fa3e1 100644 --- a/arch/avr/src/avr/up_unblocktask.c +++ b/arch/avr/src/avr/up_unblocktask.c @@ -60,7 +60,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/avr/src/avr/up_usestack.c b/arch/avr/src/avr/up_usestack.c index 0546d8c770ad85b02b724717dfb79d93919349f0..1e451d883c24fa3a425411b5ca3d38684c6ba868 100644 --- a/arch/avr/src/avr/up_usestack.c +++ b/arch/avr/src/avr/up_usestack.c @@ -79,7 +79,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/avr/src/avr32/up_blocktask.c b/arch/avr/src/avr32/up_blocktask.c index 8449d82cbe0e49331f09abae60b32b7530dcffe0..3e9304be28e2961922665ea7ed3e6d7c99efbf8b 100644 --- a/arch/avr/src/avr32/up_blocktask.c +++ b/arch/avr/src/avr32/up_blocktask.c @@ -62,7 +62,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/avr/src/avr32/up_createstack.c b/arch/avr/src/avr32/up_createstack.c index 6bc17519bc26127bace92f63bb728a02f03f1971..2244e9ba4e4860ca716a3789b5ad5546b207f7dd 100644 --- a/arch/avr/src/avr32/up_createstack.c +++ b/arch/avr/src/avr32/up_createstack.c @@ -81,7 +81,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/avr/src/avr32/up_fullcontextrestore.S b/arch/avr/src/avr32/up_fullcontextrestore.S index 8b0910998347d03e07e228a86879143577ddf3c5..45019c424bf8ff5fb2b62adce55c63d1a4dcb1dc 100644 --- a/arch/avr/src/avr32/up_fullcontextrestore.S +++ b/arch/avr/src/avr32/up_fullcontextrestore.S @@ -53,7 +53,7 @@ /**************************************************************************** * Name: up_fullcontextrestore * - * Descripion: + * Description: * Restore the full-running contex of a thread. * * NOTE: Thus function must handle one very strange case. That is when diff --git a/arch/avr/src/avr32/up_reprioritizertr.c b/arch/avr/src/avr32/up_reprioritizertr.c index 1ce7a4c406e1a9c8e2ee83dcf4ff0d760169bd49..eb8023d72082f8929d97c9fc0cabe39f7aab6de7 100644 --- a/arch/avr/src/avr32/up_reprioritizertr.c +++ b/arch/avr/src/avr32/up_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/avr/src/avr32/up_stackframe.c b/arch/avr/src/avr32/up_stackframe.c index acd10d9216f658b7fcab260564d8fc01f6bb7c57..dfcf12800184d97fcc498ad22e521f2c57c730ef 100644 --- a/arch/avr/src/avr32/up_stackframe.c +++ b/arch/avr/src/avr32/up_stackframe.c @@ -98,7 +98,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/avr/src/avr32/up_switchcontext.S b/arch/avr/src/avr32/up_switchcontext.S index 8820427e69ba999e7464345e88633e981d5271a2..1542a645784a698d68f41386b7e19d7b7daa4684 100644 --- a/arch/avr/src/avr32/up_switchcontext.S +++ b/arch/avr/src/avr32/up_switchcontext.S @@ -68,7 +68,7 @@ * * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); * - * Return: + * Returned Value: * up_switchcontext forces a context switch to the task "canned" in restoreregs. * It does not 'return' in the normal sense, rather, it will context switch back * to the function point. When it does 'return,' it is because the blocked diff --git a/arch/avr/src/avr32/up_unblocktask.c b/arch/avr/src/avr32/up_unblocktask.c index d8181344fdd56291cc6839f0a3766c6af357e6e5..c77c5dbdbb2dce8869701b2cc407a36717a5fafd 100644 --- a/arch/avr/src/avr32/up_unblocktask.c +++ b/arch/avr/src/avr32/up_unblocktask.c @@ -61,7 +61,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/avr/src/avr32/up_usestack.c b/arch/avr/src/avr32/up_usestack.c index 533c82a16ca887849b6563fccf87bd328697d4d0..4e6de52de83b55abd776bf3a2835891f249b0266 100644 --- a/arch/avr/src/avr32/up_usestack.c +++ b/arch/avr/src/avr32/up_usestack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/avr/src/common/up_releasestack.c b/arch/avr/src/common/up_releasestack.c index 9cda128cabf0d7ebe85e959e80e7d89af68046c7..f1abcd15d90c93469a20eb4846a4138c5946569a 100644 --- a/arch/avr/src/common/up_releasestack.c +++ b/arch/avr/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/hc/src/common/up_blocktask.c b/arch/hc/src/common/up_blocktask.c index f6308cb729056e30f3eae9666ef392e2e4f968fa..9c69ac43db0f410fc7f42e6712861e1f99e54bb5 100644 --- a/arch/hc/src/common/up_blocktask.c +++ b/arch/hc/src/common/up_blocktask.c @@ -62,7 +62,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/hc/src/common/up_createstack.c b/arch/hc/src/common/up_createstack.c index f09b98a87a20ad4e710e60609c96a882c2b89e23..5f954588f3cad51f7dd829375706310ad63be86e 100644 --- a/arch/hc/src/common/up_createstack.c +++ b/arch/hc/src/common/up_createstack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/hc/src/common/up_releasestack.c b/arch/hc/src/common/up_releasestack.c index 03d50098e12dd80ebc952bbb4d952600b22314a2..5280674c99a524f31e877510a86bba6dbb2a88a3 100644 --- a/arch/hc/src/common/up_releasestack.c +++ b/arch/hc/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/hc/src/common/up_reprioritizertr.c b/arch/hc/src/common/up_reprioritizertr.c index 0b0d400d9a536692f9d7b23e657b9e221cc7d2bc..757f2ad05cdfde526768ee63afa89c8ac7c4be7a 100644 --- a/arch/hc/src/common/up_reprioritizertr.c +++ b/arch/hc/src/common/up_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/hc/src/common/up_stackframe.c b/arch/hc/src/common/up_stackframe.c index d712bb7d3b473ef1ade1db3ffa5e602906c0dc09..57d899f08e3ec786529eb1208b0c3cf1c09672a3 100644 --- a/arch/hc/src/common/up_stackframe.c +++ b/arch/hc/src/common/up_stackframe.c @@ -98,7 +98,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/hc/src/common/up_unblocktask.c b/arch/hc/src/common/up_unblocktask.c index c2ed818ac3092f90c73d7e605b5d6cafb5abea86..6ab177ecf1969700211a6bccbc2b8f05f16063cb 100644 --- a/arch/hc/src/common/up_unblocktask.c +++ b/arch/hc/src/common/up_unblocktask.c @@ -61,7 +61,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/hc/src/common/up_usestack.c b/arch/hc/src/common/up_usestack.c index 6160e92b5eb1d2ce6cb23d393347c9c22582a7c2..4ecf5351f7ba07b5875fa9dec384d72cff247c23 100644 --- a/arch/hc/src/common/up_usestack.c +++ b/arch/hc/src/common/up_usestack.c @@ -77,7 +77,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/hc/src/m9s12/m9s12.h b/arch/hc/src/m9s12/m9s12.h index 53da6a772679331310bea74b06696e18e26e5931..48a09dde8863a1775a0879913995b8fa7dd52163 100644 --- a/arch/hc/src/m9s12/m9s12.h +++ b/arch/hc/src/m9s12/m9s12.h @@ -329,7 +329,7 @@ int hcs12_ethinitialize(int intf); * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/hc/src/m9s12/m9s12_ethernet.c b/arch/hc/src/m9s12/m9s12_ethernet.c index 3b3fcf0d74180e4d230f4e02e11cfba7b0b89740..a56a267c9104e8351185a719ab1cbf9d622c3992 100644 --- a/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/arch/hc/src/m9s12/m9s12_ethernet.c @@ -772,7 +772,7 @@ int emac_initialize(int intf) #endif priv->d_dev.d_private = (void*)g_emac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->d_txpoll = wd_create(); /* Create periodic poll timer */ priv->d_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/mips/src/common/up_createstack.c b/arch/mips/src/common/up_createstack.c index 69d5ff04869639cda3aa6e90a9ee77f871a2ef7a..715bf8151e3b01c28cd69e78e1dde5a2bde7daf6 100644 --- a/arch/mips/src/common/up_createstack.c +++ b/arch/mips/src/common/up_createstack.c @@ -99,7 +99,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/mips/src/common/up_idle.c b/arch/mips/src/common/up_idle.c index bee134392f85ca6953786c5766daddd268bf86c3..601a0cd5e3a2dd4d1b30d93b2014550e029c8b9d 100644 --- a/arch/mips/src/common/up_idle.c +++ b/arch/mips/src/common/up_idle.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/common/up_idle.c * - * Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -69,27 +69,23 @@ void up_idle(void) sched_process_timer(); #else + irqstate_t flags; /* This would be an appropriate place to put some MCU-specific logic to * sleep in a reduced power mode until an interrupt occurs to save power */ - /* This is a kludge that I still don't understand. The call to kmm_trysemaphore() - * in the os_start.c IDLE loop seems necessary for the good health of the IDLE - * loop. When the work queue is enabled, this logic is removed from the IDLE - * loop and it appears that we are somehow left idling with interrupts non- - * functional. The following should be no-op, it just disables then re-enables - * interrupts. But it fixes the problem and will stay here until I understand - * the problem/fix better. + /* This is a kludge that I still don't understand. It appears that we are + * somehow left idling with interrupts non-functional. The following should + * be no-op, it just disables then re-enables interrupts. But it fixes the + * problem and will stay here until I understand the problem/fix better. * - * And no, the contents of the CP0 status register are not incorrect. But for - * some reason the status register needs to be re-written again on this thread - * for it to take effect. This might be a PIC32-only issue? + * And no, the contents of the CP0 status register are not incorrect. But + * for some reason the status register needs to be re-written again on this + * thread for it to take effect. This might be a PIC32-only issue? */ -#ifdef CONFIG_SCHED_WORKQUEUE - irqstate_t flags = enter_critical_section(); - leave_critical_section(flags); -#endif + flags = up_irq_save(); + up_irq_restore(flags); #endif } diff --git a/arch/mips/src/common/up_releasestack.c b/arch/mips/src/common/up_releasestack.c index a322f4c24c8dddfa34b8aed60bbb43794546011e..d08bc2e6d91d7bb8e49afc3d8b035e6287d3fcf8 100644 --- a/arch/mips/src/common/up_releasestack.c +++ b/arch/mips/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/mips/src/common/up_stackframe.c b/arch/mips/src/common/up_stackframe.c index 6c631f3e1fc383b8b45b93baa1941d36a92e5fe1..45c8c05908802318c2c7c4128d3d37540df00201 100644 --- a/arch/mips/src/common/up_stackframe.c +++ b/arch/mips/src/common/up_stackframe.c @@ -100,7 +100,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/mips/src/common/up_usestack.c b/arch/mips/src/common/up_usestack.c index b4e3098fc47af5dcd9cba7649d1746352dc0b87a..041057a40e36ca3ba447deefee8c61a45057b0c1 100644 --- a/arch/mips/src/common/up_usestack.c +++ b/arch/mips/src/common/up_usestack.c @@ -98,7 +98,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/mips/src/mips32/up_blocktask.c b/arch/mips/src/mips32/up_blocktask.c index 1ad66ce9db6ef2b3eb266560e84c4b37d6c44604..6ee466611de4a21b132375f67a8872593273e598 100644 --- a/arch/mips/src/mips32/up_blocktask.c +++ b/arch/mips/src/mips32/up_blocktask.c @@ -63,7 +63,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/mips/src/mips32/up_reprioritizertr.c b/arch/mips/src/mips32/up_reprioritizertr.c index 22a204d58bafd42d472bfbe288d13475e5836f01..cae6ed3af5ea985d9fec647d0d40dee06d6c1a8b 100644 --- a/arch/mips/src/mips32/up_reprioritizertr.c +++ b/arch/mips/src/mips32/up_reprioritizertr.c @@ -70,7 +70,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/mips/src/mips32/up_unblocktask.c b/arch/mips/src/mips32/up_unblocktask.c index 9e72ef17a6a811d2019248bce4fe03dae586cb2b..8400b1f7cf3412cfce79ae247b2cc0b12a5b43da 100644 --- a/arch/mips/src/mips32/up_unblocktask.c +++ b/arch/mips/src/mips32/up_unblocktask.c @@ -63,7 +63,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/mips/src/mips32/up_vfork.c b/arch/mips/src/mips32/up_vfork.c index 06b79f7bb13743527e02a91b7ccaa3378aa338e6..d62c2dd62323c1427cc3180a0381f02dac6e9a5d 100644 --- a/arch/mips/src/mips32/up_vfork.c +++ b/arch/mips/src/mips32/up_vfork.c @@ -100,10 +100,10 @@ * * task_vforkabort() may be called if an error occurs between steps 3 and 6. * - * Input Paremeters: + * Input Parameters: * context - Caller context information saved by vfork() * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and * returns the process ID of the child process to the parent process. * Otherwise, -1 is returned to the parent, no child process is created, diff --git a/arch/mips/src/mips32/vfork.S b/arch/mips/src/mips32/vfork.S index 7012b45a41d53c4dc297ddbd0385c46232571343..bfcd9e51f490212202bcb3eec4c89541ac79a01a 100644 --- a/arch/mips/src/mips32/vfork.S +++ b/arch/mips/src/mips32/vfork.S @@ -86,10 +86,10 @@ * 5) up_vfork() then calls task_vforkstart() * 6) task_vforkstart() then executes the child thread. * - * Input Paremeters: + * Input Parameters: * None * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and returns * the process ID of the child process to the parent process. Otherwise, -1 is * returned to the parent, no child process is created, and errno is set to diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index f436b298b6ac16d37c36db4409cdcaa86704911f..d772a8ba14b36aac096975852d94bbe2646e4ae5 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -3348,7 +3348,7 @@ static inline int pic32mx_ethinitialize(int intf) priv->pd_irqsrc = ??; /* Ethernet controller IRQ source number */ #endif - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->pd_txpoll = wd_create(); /* Create periodic poll timer */ priv->pd_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/mips/src/pic32mx/pic32mx-spi.c b/arch/mips/src/pic32mx/pic32mx-spi.c index e09688e42c5ee4745729cee8bf9e41dc73fc10cd..ed3e8bae41b6b517ffa099c029ea5cce38cdcbd0 100644 --- a/arch/mips/src/pic32mx/pic32mx-spi.c +++ b/arch/mips/src/pic32mx/pic32mx-spi.c @@ -842,7 +842,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/mips/src/pic32mx/pic32mx-usbdev.c b/arch/mips/src/pic32mx/pic32mx-usbdev.c index b184ff41ecd4221ebc17f5b2a51b73431cb4a2ce..82b3185181496d7dd85ebe08b4fd54b32be5ab24 100644 --- a/arch/mips/src/pic32mx/pic32mx-usbdev.c +++ b/arch/mips/src/pic32mx/pic32mx-usbdev.c @@ -1031,7 +1031,8 @@ static void pic32mx_delayedrestart(struct pic32mx_usbdev_s *priv, uint8_t epno) /* And start (or re-start) the watchdog timer */ - wd_start(priv->wdog, RESTART_DELAY, pic32mx_rqrestart, 1, (uint32_t)priv); + (void)wd_start(priv->wdog, RESTART_DELAY, pic32mx_rqrestart, 1, + (uint32_t)priv); } /**************************************************************************** diff --git a/arch/mips/src/pic32mx/pic32mx.h b/arch/mips/src/pic32mx/pic32mx.h index 480ff80fb8099fa0d6da9a8dd52f68cd619bcb9f..e76f02c8719c0a16f91deace5666dbad15d26723 100644 --- a/arch/mips/src/pic32mx/pic32mx.h +++ b/arch/mips/src/pic32mx/pic32mx.h @@ -391,7 +391,7 @@ void pic32mx_dumpgpio(uint32_t pinset, const char *msg); * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/mips/src/pic32mz/chip/pic32mz-spi.h b/arch/mips/src/pic32mz/chip/pic32mz-spi.h index d4f5fe42a501d4fb96e099a7f2223e082cb92f39..c2359c0ae44b59487e8a078bb0a839ecf95e1ce5 100644 --- a/arch/mips/src/pic32mz/chip/pic32mz-spi.h +++ b/arch/mips/src/pic32mz/chip/pic32mz-spi.h @@ -110,7 +110,7 @@ #define PIC32MZ_SPI1_CON2SET (PIC32MZ_SPI1_K1BASE+PIC32MZ_SPI_CON2SET_OFFSET) #define PIC32MZ_SPI1_CON2INV (PIC32MZ_SPI1_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET) -#if PIC32MZ_NSPI > 1 +#if CHIP_NSPI > 1 # define PIC32MZ_SPI2_CON (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CON_OFFSET) # define PIC32MZ_SPI2_CONCLR (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET) # define PIC32MZ_SPI2_CONSET (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CONSET_OFFSET) @@ -128,7 +128,7 @@ # define PIC32MZ_SPI2_CON2INV (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET) #endif -#if PIC32MZ_NSPI > 2 +#if CHIP_NSPI > 2 # define PIC32MZ_SPI3_CON (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CON_OFFSET) # define PIC32MZ_SPI3_CONCLR (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET) # define PIC32MZ_SPI3_CONSET (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CONSET_OFFSET) @@ -145,7 +145,7 @@ # define PIC32MZ_SPI3_CON2INV (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET) #endif -#if PIC32MZ_NSPI > 3 +#if CHIP_NSPI > 3 # define PIC32MZ_SPI4_CON (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CON_OFFSET) # define PIC32MZ_SPI4_CONCLR (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET) # define PIC32MZ_SPI4_CONSET (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CONSET_OFFSET) @@ -162,7 +162,7 @@ # define PIC32MZ_SPI4_CON2INV (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET) #endif -#if PIC32MZ_NSPI > 4 +#if CHIP_NSPI > 4 # define PIC32MZ_SPI5_CON (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CON_OFFSET) # define PIC32MZ_SPI5_CONCLR (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET) # define PIC32MZ_SPI5_CONSET (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CONSET_OFFSET) @@ -179,7 +179,7 @@ # define PIC32MZ_SPI5_CON2INV (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET) #endif -#if PIC32MZ_NSPI > 5 +#if CHIP_NSPI > 5 # define PIC32MZ_SPI6_CON (PIC32MZ_SPI6_K1BASE+PIC32MZ_SPI_CON_OFFSET) # define PIC32MZ_SPI6_CONCLR (PIC32MZ_SPI6_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET) # define PIC32MZ_SPI6_CONSET (PIC32MZ_SPI6_K1BASE+PIC32MZ_SPI_CONSET_OFFSET) @@ -275,6 +275,7 @@ #define SPI_STAT_SPIRBF (1 << 0) /* Bit 0: SPI receive buffer full status */ #define SPI_STAT_SPITBF (1 << 1) /* Bit 1: SPI transmit buffer full status */ + /* Bit 2: Reserved */ #define SPI_STAT_SPITBE (1 << 3) /* Bit 3: SPI transmit buffer empty status */ /* Bit 4: Reserved */ #define SPI_STAT_SPIRBE (1 << 5) /* Bit 5: RX FIFO Empty */ diff --git a/arch/mips/src/pic32mz/pic32mz-ethernet.c b/arch/mips/src/pic32mz/pic32mz-ethernet.c index 5e1b2f5e0467af3a0f188ea8aa564164ad4f3d65..046b2861e93f4d3d9baebee7c9db62467f0dffd2 100644 --- a/arch/mips/src/pic32mz/pic32mz-ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz-ethernet.c @@ -3384,7 +3384,7 @@ static inline int pic32mz_ethinitialize(int intf) priv->pd_irqsrc = ??; /* Ethernet controller IRQ source number */ #endif - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->pd_txpoll = wd_create(); /* Create periodic poll timer */ priv->pd_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/mips/src/pic32mz/pic32mz-gpio.c b/arch/mips/src/pic32mz/pic32mz-gpio.c index 3d247edc5b33b5e183d7ece4c0bf3efde38b63af..0ec2c44fecdd47b53a594ecdaedf0f9783c145b0 100644 --- a/arch/mips/src/pic32mz/pic32mz-gpio.c +++ b/arch/mips/src/pic32mz/pic32mz-gpio.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/pic32mz/pic32mz-gpio.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -332,10 +332,10 @@ void pic32mz_dumpgpio(uint32_t pinset, const char *msg) getreg32(base + PIC32MZ_IOPORT_PORT_OFFSET), getreg32(base + PIC32MZ_IOPORT_LAT_OFFSET), getreg32(base + PIC32MZ_IOPORT_ODC_OFFSET)); - gpioinfo(" CNCON: %08x CNEN: %08x CNPUE: %08x\n", - getreg32(PIC32MZ_IOPORT_CNCON), - getreg32(PIC32MZ_IOPORT_CNEN), - getreg32(PIC32MZ_IOPORT_CNPUE)); + gpioinfo(" CNCON: %08x CNEN: %08x CNPU: %08x\n", + getreg32(base + PIC32MZ_IOPORT_CNCON_OFFSET), + getreg32(base + PIC32MZ_IOPORT_CNEN_OFFSET), + getreg32(base + PIC32MZ_IOPORT_CNPU_OFFSET)); sched_unlock(); } } diff --git a/arch/mips/src/pic32mz/pic32mz-serial.c b/arch/mips/src/pic32mz/pic32mz-serial.c index cfce690614e62494ed24fbfd85847564d0d0ea29..b4d6e8e791d0aae25b776c2131d5fa40f5a4eb9b 100644 --- a/arch/mips/src/pic32mz/pic32mz-serial.c +++ b/arch/mips/src/pic32mz/pic32mz-serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/pic32mz/pic32mz-serial.c * - * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -96,10 +96,10 @@ # define CONSOLE_DEV g_uart4port /* UART4 is console */ # define TTYS0_DEV g_uart4port /* UART4 is ttyS0 */ # define UART4_ASSIGNED 1 -#elif defined(CONFIG_UART4_SERIAL_CONSOLE) -# define CONSOLE_DEV g_uart5port /* UART4 is console */ -# define TTYS0_DEV g_uart5port /* UART4 is ttyS0 */ -# define UART4_ASSIGNED 1 +#elif defined(CONFIG_UART5_SERIAL_CONSOLE) +# define CONSOLE_DEV g_uart5port /* UART5 is console */ +# define TTYS0_DEV g_uart5port /* UART5 is ttyS0 */ +# define UART5_ASSIGNED 1 #elif defined(CONFIG_UART6_SERIAL_CONSOLE) # define CONSOLE_DEV g_uart6port /* UART6 is console */ # define TTYS5_DEV g_uart6port /* UART6 is ttyS0 */ @@ -118,9 +118,9 @@ # elif defined(CONFIG_PIC32MZ_UART4) # define TTYS0_DEV g_uart4port /* UART4 is ttyS0 */ # define UART4_ASSIGNED 1 -# elif defined(CONFIG_PIC32MZ_UART4) -# define TTYS0_DEV g_uart5port /* UART4 is ttyS0 */ -# define UART4_ASSIGNED 1 +# elif defined(CONFIG_PIC32MZ_UART5) +# define TTYS0_DEV g_uart5port /* UART5 is ttyS0 */ +# define UART5_ASSIGNED 1 # elif defined(CONFIG_PIC32MZ_UART6) # define TTYS0_DEV g_uart6port /* UART6 is ttyS0 */ # define UART6_ASSIGNED 1 diff --git a/arch/mips/src/pic32mz/pic32mz-spi.c b/arch/mips/src/pic32mz/pic32mz-spi.c index 287c538b7d03c3a74a682f8022fd681d623be3db..ea2f906cb918a2af03f74f0d6460b55cc168063a 100644 --- a/arch/mips/src/pic32mz/pic32mz-spi.c +++ b/arch/mips/src/pic32mz/pic32mz-spi.c @@ -1199,7 +1199,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/mips/src/pic32mz/pic32mz-spi.h b/arch/mips/src/pic32mz/pic32mz-spi.h index ce4d772e0a64de925edbf20d9b183f10b076e655..e8a11d3f04c1cf7a715b13c7441bb3cfb491ed11 100644 --- a/arch/mips/src/pic32mz/pic32mz-spi.h +++ b/arch/mips/src/pic32mz/pic32mz-spi.h @@ -78,7 +78,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: @@ -170,6 +170,58 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif +/**************************************************************************** + * Name: pic32mz_spi1/2/...register + * + * Description: + * If the board supports a card detect callback to inform the SPI-based + * MMC/SD driver when an SD card is inserted or removed, then + * CONFIG_SPI_CALLBACK should be defined and the following function(s) + * must be implemented. These functions implements the registercallback + * method of the SPI interface (see include/nuttx/spi/spi.h for details) + * + * Input Parameters: + * dev - Device-specific state data + * callback - The function to call on the media change + * arg - A caller provided value to return with the callback + * + * Returned Value: + * 0 on success; negated errno on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_SPI_CALLBACK +#ifdef CONFIG_PIC32MZ_SPI1 +int pic32mz_spi1register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg); +#endif + +#ifdef CONFIG_PIC32MZ_SPI2 +int pic32mz_spi2register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg); +#endif + +#ifdef CONFIG_PIC32MZ_SPI3 +int pic32mz_spi3register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg); +#endif + +#ifdef CONFIG_PIC32MZ_SPI4 +int pic32mz_spi4register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg); +#endif + +#ifdef CONFIG_PIC32MZ_SPI5 +int pic32mz_spi5register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg); +#endif + +#ifdef CONFIG_PIC32MZ_SPI6 +int pic32mz_spi6register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg); +#endif +#endif /* CONFIG_SPI_CALLBACK */ + #undef EXTERN #if defined(__cplusplus) } diff --git a/arch/misoc/src/common/misoc_net.c b/arch/misoc/src/common/misoc_net.c index a7df3654352d7b99c8af4dc27016a32d9379ba0a..595cbbbcff2c8804454d690db1afbb10c6f0a422 100644 --- a/arch/misoc/src/common/misoc_net.c +++ b/arch/misoc/src/common/misoc_net.c @@ -1172,7 +1172,7 @@ int misoc_net_initialize(int intf) #endif priv->misoc_net_dev.d_private = (FAR void *)g_misoc_net; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->misoc_net_txpoll = wd_create(); /* Create periodic poll timer */ priv->misoc_net_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/misoc/src/lm32/lm32_blocktask.c b/arch/misoc/src/lm32/lm32_blocktask.c index f313da11cca3f3ad37f01a814c2d89b198e85e0b..7bc951cfbf475b6407ebd14df046be68b71336b9 100644 --- a/arch/misoc/src/lm32/lm32_blocktask.c +++ b/arch/misoc/src/lm32/lm32_blocktask.c @@ -64,7 +64,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/misoc/src/lm32/lm32_createstack.c b/arch/misoc/src/lm32/lm32_createstack.c index 31c7f2422616526e3d2d03c1ddd678a1518a9f11..a9aa3143a1003f0534a4a42bfd5ec8e0e00f3175 100644 --- a/arch/misoc/src/lm32/lm32_createstack.c +++ b/arch/misoc/src/lm32/lm32_createstack.c @@ -99,7 +99,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/misoc/src/lm32/lm32_releasestack.c b/arch/misoc/src/lm32/lm32_releasestack.c index fa88500bf9d04beff9cfea29695be2db3357d557..63f4ab8f993fe6abd2bc641d452d558ad77ced3c 100644 --- a/arch/misoc/src/lm32/lm32_releasestack.c +++ b/arch/misoc/src/lm32/lm32_releasestack.c @@ -59,7 +59,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/misoc/src/lm32/lm32_reprioritizertr.c b/arch/misoc/src/lm32/lm32_reprioritizertr.c index e6b42611018b928e66eca1b246c1489d6710f721..735b69ced743639e8b0de5e8dd3545d7c6fd213e 100644 --- a/arch/misoc/src/lm32/lm32_reprioritizertr.c +++ b/arch/misoc/src/lm32/lm32_reprioritizertr.c @@ -70,7 +70,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/misoc/src/lm32/lm32_stackframe.c b/arch/misoc/src/lm32/lm32_stackframe.c index 981c655f81f1c5873b4c8ba431a52ba3970ea3cb..0791201b4e8dfa45be58ae2a7202b7af89c59be5 100644 --- a/arch/misoc/src/lm32/lm32_stackframe.c +++ b/arch/misoc/src/lm32/lm32_stackframe.c @@ -94,7 +94,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/misoc/src/lm32/lm32_unblocktask.c b/arch/misoc/src/lm32/lm32_unblocktask.c index 74b1d92472c890453bebf57fbba8725ce48732b3..8dedd5299325d89c10481ff497b13f33c097208b 100644 --- a/arch/misoc/src/lm32/lm32_unblocktask.c +++ b/arch/misoc/src/lm32/lm32_unblocktask.c @@ -64,7 +64,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/renesas/src/common/up_blocktask.c b/arch/renesas/src/common/up_blocktask.c index 9e8ba57db75b6d0b4c030cd42f7aa0db2267b9bb..9ceda2e1e2f1f793cfba5ad525803243e3a5536d 100644 --- a/arch/renesas/src/common/up_blocktask.c +++ b/arch/renesas/src/common/up_blocktask.c @@ -61,7 +61,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/renesas/src/common/up_createstack.c b/arch/renesas/src/common/up_createstack.c index 1bbf3cc8e0f20b89b60c820861ba8855c425bdb4..f4461a08b3dd923fdb7c5993cd1a0b45ab00208b 100644 --- a/arch/renesas/src/common/up_createstack.c +++ b/arch/renesas/src/common/up_createstack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/renesas/src/common/up_releasestack.c b/arch/renesas/src/common/up_releasestack.c index e2b5948b142fb84272ab588875403528e17dcefc..5b309bde16de376ab45399b212a6dde0ffcbd462 100644 --- a/arch/renesas/src/common/up_releasestack.c +++ b/arch/renesas/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/renesas/src/common/up_reprioritizertr.c b/arch/renesas/src/common/up_reprioritizertr.c index c476dbad376420d5ff9fc712764c9bdb3d754c0b..2733ecb8d971a4fa8426ab2665bdc20aca692913 100644 --- a/arch/renesas/src/common/up_reprioritizertr.c +++ b/arch/renesas/src/common/up_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/renesas/src/common/up_stackframe.c b/arch/renesas/src/common/up_stackframe.c index 811fcd4aad1b007466f7258b522b4dd4a4e8afeb..d3512ec9c95ecba0c5f3e7eba21bc0e68ac67f17 100644 --- a/arch/renesas/src/common/up_stackframe.c +++ b/arch/renesas/src/common/up_stackframe.c @@ -96,7 +96,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/renesas/src/common/up_unblocktask.c b/arch/renesas/src/common/up_unblocktask.c index de3008f98a00bb11ee11c698d95c9d61b94f1c28..30a9b4af9cb1621ce9a698f74e10bea9cd4fec15 100644 --- a/arch/renesas/src/common/up_unblocktask.c +++ b/arch/renesas/src/common/up_unblocktask.c @@ -61,7 +61,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/renesas/src/common/up_usestack.c b/arch/renesas/src/common/up_usestack.c index de4c4aca95f7cdcf5e21539a6badc85171bb01c6..9fce7d59653724620fd0c4a4b822fe8525700d73 100644 --- a/arch/renesas/src/common/up_usestack.c +++ b/arch/renesas/src/common/up_usestack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/risc-v/src/common/up_createstack.c b/arch/risc-v/src/common/up_createstack.c index 494d54e4abcb3fe16b5809f51dd6a902acd3132d..1861707685a4e98fe8b8c5840a7cad75b8814fc9 100644 --- a/arch/risc-v/src/common/up_createstack.c +++ b/arch/risc-v/src/common/up_createstack.c @@ -99,7 +99,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/risc-v/src/common/up_releasestack.c b/arch/risc-v/src/common/up_releasestack.c index 15301c49d2704a17134c257572df806930f73511..dac7cea0d6ded0aece92e0171233d40464e04415 100644 --- a/arch/risc-v/src/common/up_releasestack.c +++ b/arch/risc-v/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/risc-v/src/common/up_stackframe.c b/arch/risc-v/src/common/up_stackframe.c index b3cb9801d4d2bdb09c73f01b627aa0168b291662..be7b797d2c2bd2a9d34f2687d37a181425a781d0 100644 --- a/arch/risc-v/src/common/up_stackframe.c +++ b/arch/risc-v/src/common/up_stackframe.c @@ -100,7 +100,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/risc-v/src/common/up_usestack.c b/arch/risc-v/src/common/up_usestack.c index 605bb79b045ee06b3a29dc9b50571d252cd8aaac..49333a5a12218b9d4e86b9dad7dabd4f4f111b8c 100644 --- a/arch/risc-v/src/common/up_usestack.c +++ b/arch/risc-v/src/common/up_usestack.c @@ -98,7 +98,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/risc-v/src/nr5m100/nr5_allocateheap.c b/arch/risc-v/src/nr5m100/nr5_allocateheap.c index 3467cee05cbf4262f0fac6ebb4cef0820c747ee0..38fb84c162c4ec6dc5e1295534e02298da3cf96a 100644 --- a/arch/risc-v/src/nr5m100/nr5_allocateheap.c +++ b/arch/risc-v/src/nr5m100/nr5_allocateheap.c @@ -51,7 +51,7 @@ /************************************************************************************ * Name: up_addregion * - * Descripton: + * Description: * RAM may be added in non-contiguous chunks. This routine adds all chunks * that may be used for heap. * diff --git a/arch/risc-v/src/nr5m100/nr5_timer.h b/arch/risc-v/src/nr5m100/nr5_timer.h index 2a6d15c3e3d874a00aa8b718dc0bfffd28050692..5994df9bee110b9d8c7771bfccf2dab97d9727fa 100644 --- a/arch/risc-v/src/nr5m100/nr5_timer.h +++ b/arch/risc-v/src/nr5m100/nr5_timer.h @@ -148,7 +148,7 @@ int nr5_timer_deinit(FAR struct nr5_timer_dev_s *dev); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - the timer number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/arch/risc-v/src/rv32im/up_blocktask.c b/arch/risc-v/src/rv32im/up_blocktask.c index 530797da2b189fee6e7843c5925bc7c72e266d9a..0ac7327e120ef2c9485311758a65d0608bc0df55 100644 --- a/arch/risc-v/src/rv32im/up_blocktask.c +++ b/arch/risc-v/src/rv32im/up_blocktask.c @@ -63,7 +63,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/risc-v/src/rv32im/up_reprioritizertr.c b/arch/risc-v/src/rv32im/up_reprioritizertr.c index 26ed4ab2d10a3f62c6a4a16806004f28b5cb4ae0..e286d5026ec2e97fb35408fb554781930f47ebda 100644 --- a/arch/risc-v/src/rv32im/up_reprioritizertr.c +++ b/arch/risc-v/src/rv32im/up_reprioritizertr.c @@ -70,7 +70,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/risc-v/src/rv32im/up_unblocktask.c b/arch/risc-v/src/rv32im/up_unblocktask.c index 1b7350e05b1ced91addcd74d8175b14f6ffddf25..3bb71380dde102ea80e4f76b7f3c6eb6406ede1d 100644 --- a/arch/risc-v/src/rv32im/up_unblocktask.c +++ b/arch/risc-v/src/rv32im/up_unblocktask.c @@ -63,7 +63,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/risc-v/src/rv32im/up_vfork.c b/arch/risc-v/src/rv32im/up_vfork.c index f2f5332beceb8417ff9261836ccacd6563e9dc7a..d38d29c158fe7faeb2bd38ccfa9040449d5954fa 100644 --- a/arch/risc-v/src/rv32im/up_vfork.c +++ b/arch/risc-v/src/rv32im/up_vfork.c @@ -100,10 +100,10 @@ * * task_vforkabort() may be called if an error occurs between steps 3 and 6. * - * Input Paremeters: + * Input Parameters: * context - Caller context information saved by vfork() * - * Return: + * Returned Value: * Upon successful completion, vfork() returns 0 to the child process and * returns the process ID of the child process to the parent process. * Otherwise, -1 is returned to the parent, no child process is created, diff --git a/arch/sim/include/spinlock.h b/arch/sim/include/spinlock.h index 85333276b12cbe4edf8977bf290674292b21c816..9bfc5f40a87f1b35997278305abec8a2bfe439de 100644 --- a/arch/sim/include/spinlock.h +++ b/arch/sim/include/spinlock.h @@ -69,7 +69,7 @@ typedef bool spinlock_t; * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/sim/src/up_blocktask.c b/arch/sim/src/up_blocktask.c index 27223b19c3bc902fbb2758f8a7bc16aa114b6785..86a46453ecf8f7580fdd36101997b0d3fdeb8bf4 100644 --- a/arch/sim/src/up_blocktask.c +++ b/arch/sim/src/up_blocktask.c @@ -61,7 +61,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/sim/src/up_cpuidlestack.c b/arch/sim/src/up_cpuidlestack.c index c11d14e4a9905ff23c15487871d726b6646cbe2d..4a237c1b6bb6290a9f5c0bd476fec0965b3cc2ea 100644 --- a/arch/sim/src/up_cpuidlestack.c +++ b/arch/sim/src/up_cpuidlestack.c @@ -85,7 +85,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - cpu: CPU index that indicates which CPU the IDLE task is * being created for. * - tcb: The TCB of new CPU IDLE task diff --git a/arch/sim/src/up_createstack.c b/arch/sim/src/up_createstack.c index 96a4097a234cfc6444e23b4cd6af7d988ac14d51..2d511ba6c552a968620ca68a9cce8edfeac8bee4 100644 --- a/arch/sim/src/up_createstack.c +++ b/arch/sim/src/up_createstack.c @@ -84,7 +84,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/sim/src/up_framebuffer.c b/arch/sim/src/up_framebuffer.c index 195eadd6a461b3740f4291c0fdcf705095e1bcdf..8178c3994d954937804ee5f197545b58daf5c95d 100644 --- a/arch/sim/src/up_framebuffer.c +++ b/arch/sim/src/up_framebuffer.c @@ -308,7 +308,7 @@ static int up_getcursor(FAR struct fb_vtable_s *vtable, #endif /**************************************************************************** - * Name: + * Name: up_setcursor ****************************************************************************/ #ifdef CONFIG_FB_HWCURSOR @@ -356,7 +356,7 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -384,7 +384,7 @@ int up_fbinitialize(int display) * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/arch/sim/src/up_qspiflash.c b/arch/sim/src/up_qspiflash.c index c94986b3d388537d3e71afc2eaa689f5461452cb..f01002d7fe973bca19bf618d9c49cbb3b3857ef1 100644 --- a/arch/sim/src/up_qspiflash.c +++ b/arch/sim/src/up_qspiflash.c @@ -577,7 +577,7 @@ static int qspiflash_command(FAR struct qspi_dev_s *dev, FAR struct qspi_cmdinfo * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/sim/src/up_releasestack.c b/arch/sim/src/up_releasestack.c index e62cf2adf81123fdbc901945b48aec03bffcddf0..87a30261264587d5736e4a574501132d4694ac22 100644 --- a/arch/sim/src/up_releasestack.c +++ b/arch/sim/src/up_releasestack.c @@ -57,7 +57,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/sim/src/up_reprioritizertr.c b/arch/sim/src/up_reprioritizertr.c index 048c311559607353625a2e62729997eb22b7ed5a..36e34230477ef54cca7587e939a7538e66e1a717 100644 --- a/arch/sim/src/up_reprioritizertr.c +++ b/arch/sim/src/up_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/sim/src/up_spiflash.c b/arch/sim/src/up_spiflash.c index 677bdafd969271bb0adde863b65eb4d952d9f7e7..a75cb82948b0b83a10a9f2943927bca415d56656 100644 --- a/arch/sim/src/up_spiflash.c +++ b/arch/sim/src/up_spiflash.c @@ -897,7 +897,7 @@ static uint16_t spiflash_readword(FAR struct sim_spiflashdev_s *priv) * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/sim/src/up_stackframe.c b/arch/sim/src/up_stackframe.c index 3e5b8a089deb7798ccf432dff3a125f568b4a325..624520dc208f6f517f80d133cc310eeef0e4bd97 100644 --- a/arch/sim/src/up_stackframe.c +++ b/arch/sim/src/up_stackframe.c @@ -90,7 +90,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/sim/src/up_testset.c b/arch/sim/src/up_testset.c index d1b754bca066c9085d07fbd8daa02d6dc3d383ca..1f825e64154e355868b8becf37a3c07d108b7b16 100644 --- a/arch/sim/src/up_testset.c +++ b/arch/sim/src/up_testset.c @@ -73,7 +73,7 @@ static pthread_mutex_t g_tsmutex = PTHREAD_MUTEX_INITIALIZER; * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/sim/src/up_touchscreen.c b/arch/sim/src/up_touchscreen.c index 49e0954b5c3e9c1424fe8a10b07105468b1413bd..7e5d4a255d85efc74ac5bec8d32e37531f58839a 100644 --- a/arch/sim/src/up_touchscreen.c +++ b/arch/sim/src/up_touchscreen.c @@ -486,7 +486,7 @@ errout: } /**************************************************************************** - * Name:up_ioctl + * Name: up_ioctl ****************************************************************************/ static int up_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/arch/sim/src/up_unblocktask.c b/arch/sim/src/up_unblocktask.c index 5217efeb8fbe8e4db28d9292b9c712f5788377bd..03e8e847f9eba31afab9e4ea6c2fdfdacf29fa5c 100644 --- a/arch/sim/src/up_unblocktask.c +++ b/arch/sim/src/up_unblocktask.c @@ -60,7 +60,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/sim/src/up_usestack.c b/arch/sim/src/up_usestack.c index 3b428d8222cce23f9de39f2a7f7176abf39dd1bd..f31ed5aae3bf42778055f2078bc523051c473701 100644 --- a/arch/sim/src/up_usestack.c +++ b/arch/sim/src/up_usestack.c @@ -85,7 +85,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/x86/src/common/up_blocktask.c b/arch/x86/src/common/up_blocktask.c index e5a4845e2444f80581581da527e5392ee4b2a633..34f7f9fa26e76e916e791416700a9f9cf99cfc60 100644 --- a/arch/x86/src/common/up_blocktask.c +++ b/arch/x86/src/common/up_blocktask.c @@ -62,7 +62,7 @@ * be stopped. Save its context and move it to the inactive list specified * by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally the task at the * head of the list). It most be stopped, its context saved and moved * into one of the waiting task lists. It it was the task at the head diff --git a/arch/x86/src/common/up_reprioritizertr.c b/arch/x86/src/common/up_reprioritizertr.c index 110d26a6717924603532138d56d5843e410b851b..75428b84c98b9de1a4fd102def0a392ea941c09d 100644 --- a/arch/x86/src/common/up_reprioritizertr.c +++ b/arch/x86/src/common/up_reprioritizertr.c @@ -68,7 +68,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/x86/src/common/up_unblocktask.c b/arch/x86/src/common/up_unblocktask.c index 706d36808c841d76ae1854a5aabd9a13b5782151..8b3b4b3f2496edab122a4af443f59e8938420bb0 100644 --- a/arch/x86/src/common/up_unblocktask.c +++ b/arch/x86/src/common/up_unblocktask.c @@ -61,7 +61,7 @@ * execute. Move the TCB to the ready-to-run list, restore its context, * and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is in one of the * waiting tasks lists. It must be moved to the ready-to-run list and, * if it is the highest priority ready to run task, executed. diff --git a/arch/x86/src/i486/up_createstack.c b/arch/x86/src/i486/up_createstack.c index f51d6f2ca2b29e9c31d47b29cd7d79c769e79755..8173457e80a0913dd3f4b18871ecb5c52b77af90 100644 --- a/arch/x86/src/i486/up_createstack.c +++ b/arch/x86/src/i486/up_createstack.c @@ -80,7 +80,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/x86/src/i486/up_irq.c b/arch/x86/src/i486/up_irq.c index b216a24a719170da4e910c8fb539788c4be1e283..8689769ead586d15bb84316bfad910fb586dacb9 100644 --- a/arch/x86/src/i486/up_irq.c +++ b/arch/x86/src/i486/up_irq.c @@ -81,7 +81,7 @@ static struct idt_entry_s idt_entries[256]; ****************************************************************************/ /**************************************************************************** - * Name idt_outb + * Name: idt_outb * * Description: * A slightly slower version of outb @@ -94,7 +94,7 @@ static void idt_outb(uint8_t val, uint16_t addr) } /**************************************************************************** - * Name up_remappic + * Name: up_remappic * * Description: * Remap the PIC. The Programmable Interrupt Controller (PIC) is used to @@ -142,7 +142,7 @@ static void up_remappic(void) } /**************************************************************************** - * Name up_idtentry + * Name: up_idtentry * * Description: * Initialize one IDT entry. @@ -168,7 +168,7 @@ static void up_idtentry(unsigned int index, uint32_t base, uint16_t sel, } /**************************************************************************** - * Name up_idtinit + * Name: up_idtinit * * Description: * Initialize the IDT. The Interrupt Descriptor Table (IDT) is a data diff --git a/arch/x86/src/i486/up_releasestack.c b/arch/x86/src/i486/up_releasestack.c index 0f23cd3fb7541639a3d05e7d2125001ad2bc6f2c..e83434024ee123ebcd6ea572721a7f112b7f25d6 100644 --- a/arch/x86/src/i486/up_releasestack.c +++ b/arch/x86/src/i486/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/x86/src/i486/up_stackframe.c b/arch/x86/src/i486/up_stackframe.c index fab05bff9c079bbe3e17e4e703f22084a487faf5..62bd968a0f7625a0be3f77f8a43fd8588ba28fbe 100644 --- a/arch/x86/src/i486/up_stackframe.c +++ b/arch/x86/src/i486/up_stackframe.c @@ -99,7 +99,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/x86/src/i486/up_usestack.c b/arch/x86/src/i486/up_usestack.c index b2005fe2de857a4e3c1f78abba2f10945e2ff677..59221bedd6b5f3a5d8ccb939df9e0c8587ce0df8 100644 --- a/arch/x86/src/i486/up_usestack.c +++ b/arch/x86/src/i486/up_usestack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/x86/src/qemu/qemu.h b/arch/x86/src/qemu/qemu.h index 561c68da4427af6baead48357cef4bb4f7312469..80eceb18b301a4af75b98146a9c1b8384f48d356 100644 --- a/arch/x86/src/qemu/qemu.h +++ b/arch/x86/src/qemu/qemu.h @@ -201,7 +201,7 @@ int i486_dumpgpio(uint16_t pinset, const char *msg); * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple SPI interfaces) * * Returned Value: diff --git a/arch/x86/src/qemu/qemu_handlers.c b/arch/x86/src/qemu/qemu_handlers.c index 0f84efb31354ee3a87fc0eb6e405e081fdb8e7d5..610e4b2ee86843c55b3d042275f2c2291419d6d8 100644 --- a/arch/x86/src/qemu/qemu_handlers.c +++ b/arch/x86/src/qemu/qemu_handlers.c @@ -65,7 +65,7 @@ static void idt_outb(uint8_t val, uint16_t addr) noinline_function; ****************************************************************************/ /**************************************************************************** - * Name idt_outb + * Name: idt_outb * * Description: * A slightly slower version of outb diff --git a/arch/x86/src/qemu/qemu_vga.c b/arch/x86/src/qemu/qemu_vga.c index 151333933207087d0f941465338f757958c862fa..f29b74abc425bbcb77d0073aa522006fad249dc6 100644 --- a/arch/x86/src/qemu/qemu_vga.c +++ b/arch/x86/src/qemu/qemu_vga.c @@ -183,7 +183,8 @@ static const struct file_operations g_vgaops = * you'll need to switch planes to access the whole screen but * that allows you using any resolution, up to 400x600 * - * Returns 0=ok, -n=fail + * Returned Value: + * 0=ok, -n=fail */ static int init_graph_vga(int width, int height,int chain4) diff --git a/arch/xtensa/include/spinlock.h b/arch/xtensa/include/spinlock.h index 9d0ef213d01b15e9c3865cfc1e020a34765ab799..644253f85433f93de5bb2b523cd30dbb377b34da 100644 --- a/arch/xtensa/include/spinlock.h +++ b/arch/xtensa/include/spinlock.h @@ -79,7 +79,7 @@ typedef uint32_t spinlock_t; * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/xtensa/src/common/xtensa_assert.c b/arch/xtensa/src/common/xtensa_assert.c index 24b7fd7e23b70761a06b0ffa71cf32ccef61ec04..e290be637f9d87251d5efe9817a252ea22eabd3c 100644 --- a/arch/xtensa/src/common/xtensa_assert.c +++ b/arch/xtensa/src/common/xtensa_assert.c @@ -180,7 +180,7 @@ void up_assert(const uint8_t *filename, int lineno) * - Co-processor exception * - High priority level2-6 Exception. * - * Input parameters: + * Input Parameters: * xcptcode - Identifies the unhandled exception (see include/esp32/irq.h) * regs - The register save are at the time of the interrupt. * @@ -280,7 +280,7 @@ void xtensa_panic(int xptcode, uint32_t *regs) * cause varies 32..39. * 40..63 Reserved * - * Input parameters: + * Input Parameters: * exccause - Identifies the EXCCAUSE of the user exception * regs - The register save are at the time of the interrupt. * diff --git a/arch/xtensa/src/common/xtensa_blocktask.c b/arch/xtensa/src/common/xtensa_blocktask.c index fb1c0f910bb1fb8993753da2b643df287c209d1d..592da9a3f7e67068c5974048a142c8ffa14b4f2b 100644 --- a/arch/xtensa/src/common/xtensa_blocktask.c +++ b/arch/xtensa/src/common/xtensa_blocktask.c @@ -63,7 +63,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c index 4853513905721cc9b8242c6eb550ed6cc28ec9a7..bcfbece0d4adc7235e10401da15d41afdf43e2d3 100644 --- a/arch/xtensa/src/common/xtensa_checkstack.c +++ b/arch/xtensa/src/common/xtensa_checkstack.c @@ -72,7 +72,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size); * alloc - Allocation base address of the stack * size - The size of the stack in bytes * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ @@ -174,7 +174,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * Input Parameters: * None * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c index 68308fb527e2316f18cd32847bd177f2de460a4a..1632ac445fc6d1e299db163bfb080df71f629d86 100644 --- a/arch/xtensa/src/common/xtensa_createstack.c +++ b/arch/xtensa/src/common/xtensa_createstack.c @@ -91,7 +91,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/xtensa/src/common/xtensa_releasestack.c b/arch/xtensa/src/common/xtensa_releasestack.c index 94bb2d8cd8ad91c7164b3871c48525b49766e4cc..738da79284a5c9678331f1f395a1322a58a1ce80 100644 --- a/arch/xtensa/src/common/xtensa_releasestack.c +++ b/arch/xtensa/src/common/xtensa_releasestack.c @@ -58,7 +58,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/xtensa/src/common/xtensa_reprioritizertr.c b/arch/xtensa/src/common/xtensa_reprioritizertr.c index 0226d18f7250ca3bb09143ca126358f6df17ec6e..617bb50c619b385de745f8bf2a1e368673c256e3 100644 --- a/arch/xtensa/src/common/xtensa_reprioritizertr.c +++ b/arch/xtensa/src/common/xtensa_reprioritizertr.c @@ -70,7 +70,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/xtensa/src/common/xtensa_schedsigaction.c b/arch/xtensa/src/common/xtensa_schedsigaction.c index 2dd39913351909eadf1a93a5a0c0c4c363b40f5b..9747d201d343632d7745d1e94850276c206ddae3 100644 --- a/arch/xtensa/src/common/xtensa_schedsigaction.c +++ b/arch/xtensa/src/common/xtensa_schedsigaction.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/xtensa/src/common/arm_schedulesigaction.c * - * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -114,7 +114,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is - * signalling itself for some reason. + * signaling itself for some reason. */ if (!CURRENT_REGS) @@ -131,7 +131,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * * Hmmm... there looks like a latent bug here: The following logic * would fail in the strange case where we are in an interrupt - * handler, the thread is signalling itself, but a context switch + * handler, the thread is signaling itself, but a context switch * to another task has occurred so that CURRENT_REGS does not * refer to the thread of this_task()! */ @@ -169,7 +169,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Otherwise, we are (1) signaling a task is not running from an * interrupt handler or (2) we are not in an interrupt handler and the - * running task is signalling some non-running task. + * running task is signaling some non-running task. */ else @@ -230,7 +230,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) cpu = tcb->cpu; /* CASE 1: We are not in an interrupt handler and a task is - * signalling itself for some reason. + * signaling itself for some reason. */ if (cpu == me && !CURRENT_REGS) @@ -246,61 +246,63 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * CPU. In the former case, we will have to PAUSE the other CPU * first. But in either case, we will have to modify the return * state as well as the state in the TCB. - * - * Hmmm... there looks like a latent bug here: The following logic - * would fail in the strange case where we are in an interrupt - * handler, the thread is signalling itself, but a context switch - * to another task has occurred so that CURRENT_REGS does not - * refer to the thread of this_task()! */ else { - /* If we signalling a task running on the other CPU, we have + /* If we signaling a task running on the other CPU, we have * to PAUSE the other CPU. */ if (cpu != me) { + /* Pause the CPU */ + up_cpu_pause(cpu); - } - /* Save the return pc and ps. These will be restored by the - * signal trampoline after the signals have been delivered. - * - * NOTE: that hi-priority interrupts are not disabled. - */ + /* Wait while the pause request is pending */ - tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; - tcb->xcp.saved_ps = CURRENT_REGS[REG_PS]; + while (up_cpu_pausereq(cpu)) + { + } - /* Increment the IRQ lock count so that when the task is restarted, - * it will hold the IRQ spinlock. - */ + /* Now tcb on the other CPU can be accessed safely */ - DEBUGASSERT(tcb->irqcount < INT16_MAX); - tcb->irqcount++; + /* Copy tcb->xcp.regs to tcp.xcp.saved. These will be restored + * by the signal trampoline after the signal has been delivered. + * + * NOTE: that hi-priority interrupts are not disabled. + */ - /* Handle a possible race condition where the TCB was suspended - * just before we paused the other CPU. The critical section - * established above will prevent new threads from running on - * that CPU, but it will not guarantee that the running thread - * did not suspend itself (allowing any threads "assigned" to - * the CPU to run). - */ + tcb->xcp.sigdeliver = sigdeliver; + tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; + tcb->xcp.saved_ps = tcb->xcp.regs[REG_PS]; - if (tcb->task_state != TSTATE_TASK_RUNNING) - { - tcb->xcp.regs[REG_PC] = (uint32_t)_xtensa_sig_trampoline; + /* Then set up to vector to the trampoline with interrupts + * disabled + */ + + CURRENT_REGS[REG_PC] = (uint32_t)_xtensa_sig_trampoline; #ifdef __XTENSA_CALL0_ABI__ - tcb->xcp.regs[REG_PS] = (uint32_t)(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM); + CURRENT_REGS[REG_PS] = (uint32_t)(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM); #else - tcb->xcp.regs[REG_PS] = (uint32_t)(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE); + CURRENT_REGS[REG_PS] = (uint32_t)(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE); #endif } else { + /* tcb is running on the same CPU */ + + /* Copy tcb->xcp.regs to tcp.xcp.saved. These will be restored + * by the signal trampoline after the signal has been delivered. + * + * NOTE: that hi-priority interrupts are not disabled. + */ + + tcb->xcp.sigdeliver = sigdeliver; + tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; + tcb->xcp.saved_ps = CURRENT_REGS[REG_PS]; + /* Then set up to vector to the trampoline with interrupts * disabled */ @@ -311,16 +313,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) #else CURRENT_REGS[REG_PS] = (uint32_t)(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE); #endif - /* In an SMP configuration, the interrupt disable logic also - * involves spinlocks that are configured per the TCB irqcount - * field. This is logically equivalent to enter_critical_section(). - * The matching call to leave_critical_section() will be - * performed in up_sigdeliver(). - */ - - spin_setbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, - &g_cpu_irqlock); - /* And make sure that the saved context in the TCB is the same * as the interrupt return context. */ @@ -328,6 +320,23 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) xtensa_savestate(tcb->xcp.regs); } + /* Increment the IRQ lock count so that when the task is restarted, + * it will hold the IRQ spinlock. + */ + + DEBUGASSERT(tcb->irqcount < INT16_MAX); + tcb->irqcount++; + + /* In an SMP configuration, the interrupt disable logic also + * involves spinlocks that are configured per the TCB irqcount + * field. This is logically equivalent to enter_critical_section(). + * The matching call to leave_critical_section() will be + * performed in up_sigdeliver(). + */ + + spin_setbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, + &g_cpu_irqlock); + /* RESUME the other CPU if it was PAUSED */ if (cpu != me) @@ -339,7 +348,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Otherwise, we are (1) signaling a task is not running from an * interrupt handler or (2) we are not in an interrupt handler and the - * running task is signalling some other non-running task. + * running task is signaling some other non-running task. */ else diff --git a/arch/xtensa/src/common/xtensa_stackframe.c b/arch/xtensa/src/common/xtensa_stackframe.c index 388238d8de342597a4dfaa962aef5d31f8da488d..884225d69a768c2f24a607c7f3fc9dddf95b1cea 100644 --- a/arch/xtensa/src/common/xtensa_stackframe.c +++ b/arch/xtensa/src/common/xtensa_stackframe.c @@ -92,7 +92,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/xtensa/src/common/xtensa_testset.c b/arch/xtensa/src/common/xtensa_testset.c index d8fdec3c00b6b06b0a0da2147b803cef6797df25..480a61052f556ce5fc778861ac72ee48ebbb68b4 100644 --- a/arch/xtensa/src/common/xtensa_testset.c +++ b/arch/xtensa/src/common/xtensa_testset.c @@ -91,7 +91,7 @@ static inline uint32_t xtensa_compareset(FAR volatile uint32_t *addr, * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. diff --git a/arch/xtensa/src/common/xtensa_unblocktask.c b/arch/xtensa/src/common/xtensa_unblocktask.c index 40ecf73c56b8dbaaf6c1318c84ffe958f6760243..e7fb168ba7a4714a6bc7e49d406e3d3f5ace732b 100644 --- a/arch/xtensa/src/common/xtensa_unblocktask.c +++ b/arch/xtensa/src/common/xtensa_unblocktask.c @@ -63,7 +63,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/xtensa/src/common/xtensa_usestack.c b/arch/xtensa/src/common/xtensa_usestack.c index 0b5db031e91d93d942f11ab484edadb36b066072..4faff7341b2a4ff11fdbfd717e438b731f15758c 100644 --- a/arch/xtensa/src/common/xtensa_usestack.c +++ b/arch/xtensa/src/common/xtensa_usestack.c @@ -90,7 +90,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/xtensa/src/esp32/esp32_cpuidlestack.c b/arch/xtensa/src/esp32/esp32_cpuidlestack.c index ea475b79b3f6f21036565f6730bd32d29e9a6acb..8239acb96d0dc74c273fddb1a19a94c5789ec884 100644 --- a/arch/xtensa/src/esp32/esp32_cpuidlestack.c +++ b/arch/xtensa/src/esp32/esp32_cpuidlestack.c @@ -83,7 +83,7 @@ uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS] * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - cpu: CPU index that indicates which CPU the IDLE task is * being created for. * - tcb: The TCB of new CPU IDLE task diff --git a/arch/xtensa/src/esp32/rom/esp32_gpio.h b/arch/xtensa/src/esp32/rom/esp32_gpio.h index c29d21ee46236273d0486cb4fc2ef4afe9aa1a6f..38eae27c80ad5d9c27773698a3bac6312ffc0086 100644 --- a/arch/xtensa/src/esp32/rom/esp32_gpio.h +++ b/arch/xtensa/src/esp32/rom/esp32_gpio.h @@ -329,7 +329,7 @@ void gpio_matrix_out(uint32_t gpio, uint32_t signal_idx, bool out_inv, bool oen_inv); /**************************************************************************** - * Name: + * Name: gpio_pad_select_gpio * * Description: * Select pad as a gpio function from IOMUX. diff --git a/arch/z16/src/common/up_blocktask.c b/arch/z16/src/common/up_blocktask.c index 8328086de622b75e53dbc2e6b9fde822e465520a..0893c933e636ce02bd71662317d75423ef610b9e 100644 --- a/arch/z16/src/common/up_blocktask.c +++ b/arch/z16/src/common/up_blocktask.c @@ -61,7 +61,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/z16/src/common/up_createstack.c b/arch/z16/src/common/up_createstack.c index 2c35e68aef8e40c9bf28c181542b4a2874e44220..0bab2d3ab3621902a33c5948bb3e30265f823469 100644 --- a/arch/z16/src/common/up_createstack.c +++ b/arch/z16/src/common/up_createstack.c @@ -79,7 +79,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/z16/src/common/up_releasestack.c b/arch/z16/src/common/up_releasestack.c index e0f4c4b27fe33a9a0a836ac8ac6af289298029f1..8d0698ecfdc9343869609413a93788c9100b89c9 100644 --- a/arch/z16/src/common/up_releasestack.c +++ b/arch/z16/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/z16/src/common/up_reprioritizertr.c b/arch/z16/src/common/up_reprioritizertr.c index d4fde47f31d7a94150486ed4db78c776c79c9c69..588ec4d68fd6414682b28659b5f3c081ba44ad2d 100644 --- a/arch/z16/src/common/up_reprioritizertr.c +++ b/arch/z16/src/common/up_reprioritizertr.c @@ -69,7 +69,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/z16/src/common/up_stackframe.c b/arch/z16/src/common/up_stackframe.c index 6a2fe6d3476cdb9cdfad44943c85df7b22107051..1bed013d99590e313f0ef41e676a9f7d3af24ac6 100644 --- a/arch/z16/src/common/up_stackframe.c +++ b/arch/z16/src/common/up_stackframe.c @@ -97,7 +97,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/z16/src/common/up_unblocktask.c b/arch/z16/src/common/up_unblocktask.c index d9de4e43b95030761a314d7869f5ffea4f033f25..2b09dbc301ca0b9e757e76ef526e79fc36be32f2 100644 --- a/arch/z16/src/common/up_unblocktask.c +++ b/arch/z16/src/common/up_unblocktask.c @@ -62,7 +62,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/z16/src/common/up_usestack.c b/arch/z16/src/common/up_usestack.c index d65609a67d0cae50da5ce0f309f0b998c26694b3..044ecdc3474924c8c6c545e6417c7a93553bf8f7 100644 --- a/arch/z16/src/common/up_usestack.c +++ b/arch/z16/src/common/up_usestack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/z16/src/z16f/z16f_espi.c b/arch/z16/src/z16f/z16f_espi.c index da5b88611ee4d22fb3eb8feb7603d5dc2f5be3eb..2a590d96133defc15ca8b0cb28d7f9404095a60e 100644 --- a/arch/z16/src/z16f/z16f_espi.c +++ b/arch/z16/src/z16f/z16f_espi.c @@ -788,7 +788,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * port - Identifies the "logical" SPI port. Must be zero in this case. * * Returned Value: diff --git a/arch/z16/src/z16f/z16f_lowuart.S b/arch/z16/src/z16f/z16f_lowuart.S index ef7c31a6ca4872f4d48be3cee53911625baab5f9..0a893d758583dce81db6aaf5a8397483d2520bc0 100644 --- a/arch/z16/src/z16f/z16f_lowuart.S +++ b/arch/z16/src/z16f/z16f_lowuart.S @@ -191,7 +191,7 @@ _up_lowputc: * Parameters: * r1 = character * - * Return: + * Returned Value: * None * * Modifies r0 @@ -230,7 +230,7 @@ _z16f_xmitc1: * Parmeters: * None * - * Return + * Returned Value: * R0 = Character read * *************************************************************************/ diff --git a/arch/z80/src/common/up_blocktask.c b/arch/z80/src/common/up_blocktask.c index a4aa7b8ed507c28b6f84b03dd56cd6e9445ea59a..6910c87b08edb829efa201610ed85fa93db1f7dd 100644 --- a/arch/z80/src/common/up_blocktask.c +++ b/arch/z80/src/common/up_blocktask.c @@ -63,7 +63,7 @@ * the ready to run list must be stopped. Save its context * and move it to the inactive list specified by task_state. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the diff --git a/arch/z80/src/common/up_createstack.c b/arch/z80/src/common/up_createstack.c index a0a2bc2507d029d3a0fd996d2736c10e2b466171..388cfb184d3e8e616d667891d763f7df385d42ee 100644 --- a/arch/z80/src/common/up_createstack.c +++ b/arch/z80/src/common/up_createstack.c @@ -78,7 +78,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. diff --git a/arch/z80/src/common/up_releasestack.c b/arch/z80/src/common/up_releasestack.c index 31237a3ee669a3750855fb37b1a6e5bbd2b36be3..5862240d1f9ab48d04ce6c22d73c0033ba1c459e 100644 --- a/arch/z80/src/common/up_releasestack.c +++ b/arch/z80/src/common/up_releasestack.c @@ -66,7 +66,7 @@ * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): diff --git a/arch/z80/src/common/up_reprioritizertr.c b/arch/z80/src/common/up_reprioritizertr.c index 04675918fdb2933ffe2bd9ed636d818c2d83b254..118ed179c5d329a43836f88ccafaeb44ec68aa01 100644 --- a/arch/z80/src/common/up_reprioritizertr.c +++ b/arch/z80/src/common/up_reprioritizertr.c @@ -71,7 +71,7 @@ * the priority of the current, running task and it now has the * priority. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * diff --git a/arch/z80/src/common/up_stackframe.c b/arch/z80/src/common/up_stackframe.c index 8f4a0f180623672827930602707ca523647bce2a..60ad0851ce5378f1bf51bc07b19303613ad59044 100644 --- a/arch/z80/src/common/up_stackframe.c +++ b/arch/z80/src/common/up_stackframe.c @@ -88,7 +88,7 @@ * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * diff --git a/arch/z80/src/common/up_unblocktask.c b/arch/z80/src/common/up_unblocktask.c index a27a8e1ddd0c9c38e600581856baa268968477f7..66f7337dc6408fbc7806c61771079cf14ca28708 100644 --- a/arch/z80/src/common/up_unblocktask.c +++ b/arch/z80/src/common/up_unblocktask.c @@ -64,7 +64,7 @@ * but has been prepped to execute. Move the TCB to the * ready-to-run list, restore its context, and start execution. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority diff --git a/arch/z80/src/common/up_usestack.c b/arch/z80/src/common/up_usestack.c index dd82424d33fc22e0b348906a85f89b2d85f0c713..7c75a14419c7e46b96ff1fb4f0c052ddbada3827 100644 --- a/arch/z80/src/common/up_usestack.c +++ b/arch/z80/src/common/up_usestack.c @@ -77,7 +77,7 @@ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The allocated stack size. * diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index 55896c08ff6013b3b5a2d7f13469ba20bbeb122c..7ef110f8112e79fc302bfaea8157a1b2d0110732 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -2537,7 +2537,7 @@ int up_netinitialize(void) #endif priv->dev.d_private = (FAR void*)&g_emac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/z80/src/ez80/ez80_i2c.c b/arch/z80/src/ez80/ez80_i2c.c index 6413a39d4b6bd860f28b1e44ce4a545cc9cd6c18..a7b7403e672038ece6846095850f675b78a9d5dd 100644 --- a/arch/z80/src/ez80/ez80_i2c.c +++ b/arch/z80/src/ez80/ez80_i2c.c @@ -929,7 +929,7 @@ static int ez80_i2c_transfer(FAR struct i2c_master_s *dev, * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple I2C interfaces) * * Returned Value: diff --git a/arch/z80/src/ez80/ez80_spi.c b/arch/z80/src/ez80/ez80_spi.c index d7f14c7e015056ea0f14b28b7cc157b2eaaf4e6f..5f337d441ab2f7dfaa685b951e297bcdf2861f8f 100644 --- a/arch/z80/src/ez80/ez80_spi.c +++ b/arch/z80/src/ez80/ez80_spi.c @@ -438,7 +438,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t bu * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/z80/src/ez80/ez80f91_i2c.h b/arch/z80/src/ez80/ez80f91_i2c.h index b59d4ffc7b157d164e43d204dd6440f59461d1ba..a296eeab7089a745313e1b55a4e9710c543fc26e 100644 --- a/arch/z80/src/ez80/ez80f91_i2c.h +++ b/arch/z80/src/ez80/ez80f91_i2c.h @@ -150,7 +150,7 @@ extern "C" * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: @@ -166,7 +166,7 @@ FAR struct i2c_master_s *ez80_i2cbus_initialize(int port); * Description: * De-initialize the selected I2C port, and power down the device. * - * Input Parameter: + * Input Parameters: * Device structure as returned by the ez80_i2cbus_initialize() * * Returned Value: diff --git a/arch/z80/src/ez80/ez80f91_spi.h b/arch/z80/src/ez80/ez80f91_spi.h index fe7c34bb7e49e3566de06cdbd8f743046f372e8f..0c49cad1d7b699209d1d93fbf58f1c57e97d894d 100644 --- a/arch/z80/src/ez80/ez80f91_spi.h +++ b/arch/z80/src/ez80/ez80f91_spi.h @@ -114,7 +114,7 @@ extern "C" * required. Theregore, all GPIO chip management is deferred to board- * specific logic. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/arch/z80/src/z8/z8_i2c.c b/arch/z80/src/z8/z8_i2c.c index 465debc4037eb5812b51660a4f407a97ab84c982..599e6adb323bea81e23fd48eb664964d6fbea5ff 100644 --- a/arch/z80/src/z8/z8_i2c.c +++ b/arch/z80/src/z8/z8_i2c.c @@ -638,7 +638,7 @@ static int z8_i2c_reset(FAR struct i2c_master_s * dev) * instances of the interface, each of which may be set up with a * different frequency and slave address. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple I2C interfaces) * * Returned Value: diff --git a/audio/audio.c b/audio/audio.c index e4acb10b895e70a0bcfb1e310ecdd1919abc993b..1dde458efd51f4f70415c0da43d7f187981c158a 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -233,9 +233,9 @@ static int audio_close(FAR struct file *filep) lower->ops->shutdown(lower); } + ret = OK; -//errout_with_sem: nxsem_post(&upper->exclsem); errout: @@ -680,7 +680,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * to enqueue additional buffers and "wake them up" for further * processing. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was provided to the lower-half * start() method. * apb - A pointer to the previsously enqueued ap_buffer_s @@ -767,7 +767,7 @@ static inline void audio_complete(FAR struct audio_upperhalf_s *upper, * Provides a callback interface for lower-half drivers to call to the * upper-half for buffer dequeueing, error reporting, etc. * - * Input parameters: + * Input Parameters: * priv - Private context data owned by the upper-half * reason - The reason code for the callback * apb - A pointer to the previsously enqueued ap_buffer_s @@ -854,7 +854,7 @@ static void audio_callback(FAR void *handle, uint16_t reason, * When this function is called, the "lower half" driver should be in the * reset state (as if the shutdown() method had already been called). * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name Audio drivers * based on the function they provide, such as "/dev/pcm0", "/dev/mp31", diff --git a/binfmt/binfmt.h b/binfmt/binfmt.h index cfde554d4e453f3262db9bed85b9e01685fd4a36..84775cfbd9f4391a30571e208676dd86e79d948a 100644 --- a/binfmt/binfmt.h +++ b/binfmt/binfmt.h @@ -78,7 +78,7 @@ EXTERN FAR struct binfmt_s *g_binfmts; * Description: * Dump the contents of struct binary_s. * - * Input Parameter: + * Input Parameters: * bin - Load structure * * Returned Value: @@ -101,7 +101,7 @@ int dump_module(FAR const struct binary_s *bin); * address environment of the new process address environment. So we * do not have any real option other than to copy the callers argv[] list. * - * Input Parameter: + * Input Parameters: * bin - Load structure * argv - Argument list * @@ -118,7 +118,7 @@ int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv); * Description: * Release the copied argv[] list. * - * Input Parameter: + * Input Parameters: * bin - Load structure * * Returned Value: diff --git a/binfmt/binfmt_copyargv.c b/binfmt/binfmt_copyargv.c index f0a594f5a6d20e2408aad0874d1a207852373aa5..c3f3dbcc083a772d562b25c34825933405b6c8f5 100644 --- a/binfmt/binfmt_copyargv.c +++ b/binfmt/binfmt_copyargv.c @@ -72,7 +72,7 @@ * address environment of the new process address environment. So we * do not have any real option other than to copy the callers argv[] list. * - * Input Parameter: + * Input Parameters: * bin - Load structure * argv - Argument list * @@ -167,7 +167,7 @@ int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv) * Description: * Release the copied argv[] list. * - * Input Parameter: + * Input Parameters: * binp - Load structure * * Returned Value: diff --git a/binfmt/binfmt_loadmodule.c b/binfmt/binfmt_loadmodule.c index 375616203a41b8ea1d2a3e572aec4b543d0bdda8..ea5def2acbaf09c5e74ae524cb1c4d42a30a4c1a 100644 --- a/binfmt/binfmt_loadmodule.c +++ b/binfmt/binfmt_loadmodule.c @@ -1,7 +1,7 @@ /**************************************************************************** * binfmt/binfmt_loadmodule.c * - * Copyright (C) 2009, 2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2014, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -88,11 +89,10 @@ static int load_default_priority(FAR struct binary_s *bin) /* Get the priority of this thread */ - ret = sched_getparam(0, ¶m); + ret = nxsched_getparam(0, ¶m); if (ret < 0) { - ret = -get_errno(); - berr("ERROR: sched_getparam failed: %d\n", ret); + berr("ERROR: nxsched_getparam failed: %d\n", ret); return ret; } diff --git a/binfmt/binfmt_schedunload.c b/binfmt/binfmt_schedunload.c index f742b49396257607b0c946ee2607eaf4ead292c5..1996acd107544e0d27cad04f8ea978f4005cbd09 100644 --- a/binfmt/binfmt_schedunload.c +++ b/binfmt/binfmt_schedunload.c @@ -52,14 +52,6 @@ #if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_SCHED_HAVE_PARENT) -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Private Data ****************************************************************************/ @@ -82,7 +74,7 @@ FAR struct binary_s *g_unloadhead; * * This function will add one structure to the linked list * - * Input Parameter: + * Input Parameters: * pid - The task ID of the child task * bin - This structure must have been allocated with kmm_malloc() and must * persist until the task unloads @@ -125,7 +117,7 @@ static void unload_list_add(pid_t pid, FAR struct binary_s *bin) * * This function will remove one structure to the linked list * - * Input Parameter: + * Input Parameters: * pid - The task ID of the child task * * Returned Value: @@ -192,7 +184,7 @@ static FAR struct binary_s *unload_list_remove(pid_t pid) * bin was allocated with kmm_malloc() or friends and will also automatically * free the structure with kmm_free() when the task exists. * - * Input Parameter: + * Input Parameters: * pid - The ID of the task that just exited * arg - A reference to the load structure cast to FAR void * * @@ -251,7 +243,7 @@ static void unload_callback(int signo, siginfo_t *info, void *ucontext) * or friends. It will also automatically free the structure with kmm_free() * after unloading the module. * - * Input Parameter: + * Input Parameters: * pid - The task ID of the child task * bin - This structure must have been allocated with kmm_malloc() and must * persist until the task unloads diff --git a/binfmt/binfmt_unregister.c b/binfmt/binfmt_unregister.c index f97b06ff2da702ee26af72c61d1b9015d3fbe095..e0a6fe80e649a5c71bb517ae72b230c92fee07aa 100644 --- a/binfmt/binfmt_unregister.c +++ b/binfmt/binfmt_unregister.c @@ -50,22 +50,6 @@ #ifndef CONFIG_BINFMT_DISABLE -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/binfmt/builtin.c b/binfmt/builtin.c index 88ad846c7fc21031d826d79cabb4dcfbb2bef721..fda996429f22f9c088991a4568d8ad76167d7392 100644 --- a/binfmt/builtin.c +++ b/binfmt/builtin.c @@ -195,7 +195,7 @@ int builtin_initialize(void) void builtin_uninitialize(void) { - unregister_binfmt(&g_builtin_binfmt); + (void)unregister_binfmt(&g_builtin_binfmt); } #endif /* CONFIG_BUILTIN */ diff --git a/binfmt/elf.c b/binfmt/elf.c index 37b1e117cd4f4271fe461921ff9318de47a0cc0a..d4e227c26c33ddfe61456674d7be142c6907719e 100644 --- a/binfmt/elf.c +++ b/binfmt/elf.c @@ -362,7 +362,7 @@ int elf_initialize(void) void elf_uninitialize(void) { - unregister_binfmt(&g_elfbinfmt); + (void)unregister_binfmt(&g_elfbinfmt); } #endif /* CONFIG_ELF */ diff --git a/binfmt/libelf/libelf_init.c b/binfmt/libelf/libelf_init.c index 7307261df623eedaec37ecfde97ef1922c96a9d7..3e09a6676aa95cd1187f535f17b3d4846b24f7a8 100644 --- a/binfmt/libelf/libelf_init.c +++ b/binfmt/libelf/libelf_init.c @@ -101,7 +101,7 @@ static inline int elf_filelen(FAR struct elf_loadinfo_s *loadinfo, ret = stat(filename, &buf); if (ret < 0) { - int errval = errno; + int errval = get_errno(); berr("Failed to stat file: %d\n", errval); return -errval; } @@ -165,7 +165,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo) loadinfo->filfd = open(filename, O_RDONLY); if (loadinfo->filfd < 0) { - int errval = errno; + int errval = get_errno(); berr("Failed to open ELF binary %s: %d\n", filename, errval); return -errval; } diff --git a/binfmt/libelf/libelf_read.c b/binfmt/libelf/libelf_read.c index 490ba1fdd9029d6bdf112ed33a1189ba3817b136..a240e107fbcc6553916d121dd273f669e553b5f7 100644 --- a/binfmt/libelf/libelf_read.c +++ b/binfmt/libelf/libelf_read.c @@ -127,7 +127,7 @@ int elf_read(FAR struct elf_loadinfo_s *loadinfo, FAR uint8_t *buffer, rpos = lseek(loadinfo->filfd, offset, SEEK_SET); if (rpos != offset) { - int errval = errno; + int errval = get_errno(); berr("Failed to seek to position %lu: %d\n", (unsigned long)offset, errval); return -errval; diff --git a/binfmt/libnxflat/libnxflat_init.c b/binfmt/libnxflat/libnxflat_init.c index eff6cd8b29dad8065a2e190cdb41b62edafd352f..d3f48c0073b0d3558d920e4907c0bd60d911f86c 100644 --- a/binfmt/libnxflat/libnxflat_init.c +++ b/binfmt/libnxflat/libnxflat_init.c @@ -111,7 +111,7 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo) loadinfo->filfd = open(filename, O_RDONLY); if (loadinfo->filfd < 0) { - int errval = errno; + int errval = get_errno(); berr("Failed to open NXFLAT binary %s: %d\n", filename, errval); return -errval; } diff --git a/binfmt/libnxflat/libnxflat_read.c b/binfmt/libnxflat/libnxflat_read.c index 720f7256796d6674b76bc2099b76c9c3acb5de8c..09016f5d3da6027949ba4be60629b2ec48aef704 100644 --- a/binfmt/libnxflat/libnxflat_read.c +++ b/binfmt/libnxflat/libnxflat_read.c @@ -131,7 +131,7 @@ int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer, rpos = lseek(loadinfo->filfd, offset, SEEK_SET); if (rpos != offset) { - int errval = errno; + int errval = get_errno(); berr("Failed to seek to position %d: %d\n", offset, errval); return -errval; } diff --git a/binfmt/nxflat.c b/binfmt/nxflat.c index c2f1c06f78b0f0385f73ea9f33f2317d480ee4b7..16fdc17e181f353630a275f97bf2b61e1e085f93 100644 --- a/binfmt/nxflat.c +++ b/binfmt/nxflat.c @@ -274,7 +274,7 @@ int nxflat_initialize(void) void nxflat_uninitialize(void) { - unregister_binfmt(&g_nxflatbinfmt); + (void)unregister_binfmt(&g_nxflatbinfmt); } #endif /* CONFIG_NXFLAT */ diff --git a/binfmt/pcode.c b/binfmt/pcode.c index 7e38c14e9b2d981fb78ab41052d1b16f0596dc5a..b8fc5aaf09197b5e0b6bf7fd71c342212c221e5e 100644 --- a/binfmt/pcode.c +++ b/binfmt/pcode.c @@ -583,11 +583,7 @@ void pcode_uninitialize(void) ret = unregister_binfmt(&g_pcode_binfmt); if (ret < 0) { - int errval = get_errno(); - DEBUGASSERT(errval > 0); - - berr("ERROR: unregister_binfmt() failed: %d\n", errval); - UNUSED(errval); + berr("ERROR: unregister_binfmt() failed: %d\n", ret); } #ifdef CONFIG_BINFMT_PCODE_TEST_FS diff --git a/configs/Kconfig b/configs/Kconfig index c278ece1e8d677905c752aac7acc422be220f7eb..bf770edd1dcc0ed827fc230179cbdc451de18f6c 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -2351,15 +2351,6 @@ config BOARDCTL_USBDEVCTRL ---help--- Enables support for the BOARDIOC_USBDEV_CONTROL boardctl() command. -config BOARDCTL_TSCTEST - bool "Enable touchscreen test interfaces" - default n - ---help--- - Enables support for the BOARDIOC_TSCTEST_SETUP and - BOARDIOC_TSCTEST_TEARDOWN boardctl() commands. Architecture - specific logic must provide board_tsc_setup() and - board_tsc_teardown() interfaces. - config BOARDCTL_IOCTL bool "Board-specific boardctl() commands" default n diff --git a/configs/arduino-due/README.txt b/configs/arduino-due/README.txt index bb6d7f08aa8ad1197ce4e99a1fc82938a624040b..0de6bcb4d22b2fb73a3bbc9b88d8156ddd9fe194 100644 --- a/configs/arduino-due/README.txt +++ b/configs/arduino-due/README.txt @@ -330,6 +330,12 @@ Serial Consoles Loading Code ============ + [NOTE: I believe that there have been significant changes to the more + recent tool environment such that Bossac may no longer be usable. I + don't know that for certain and perhaps someone with more knowledge of + the tools than I could make this work. See the Flip'n'Clip SAM3X README + file for additional information.] + Installing the Arduino USB Driver under Windows: ------------------------------------------------ diff --git a/configs/arduino-due/nsh/defconfig b/configs/arduino-due/nsh/defconfig index 15814e72310a2dd88fe34e517bf6d0aee79c1235..a791c14a5b1b925e76d932a398e098f6f269bba7 100644 --- a/configs/arduino-due/nsh/defconfig +++ b/configs/arduino-due/nsh/defconfig @@ -11,9 +11,6 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_BOARD_LOOPSPERMSEC=6965 CONFIG_BUILTIN=y CONFIG_CXX_NEWLONG=y -CONFIG_DISABLE_ENVIRON=y -CONFIG_DISABLE_MOUNTPOINT=y -CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y CONFIG_FS_PROCFS=y @@ -24,6 +21,7 @@ CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=3 CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_DISABLE_IFUPDOWN=y CONFIG_NSH_FILEIOSIZE=512 @@ -40,7 +38,7 @@ CONFIG_SDCLONE_DISABLE=y CONFIG_START_DAY=28 CONFIG_START_MONTH=6 CONFIG_START_YEAR=2013 -CONFIG_TASK_NAME_SIZE=0 +CONFIG_TASK_NAME_SIZE=32 CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/arduino-due/src/arduino-due.h b/configs/arduino-due/src/arduino-due.h index 0e2b6736b347bd156fb3c25fd49247146ab77108..01768855d7601d5bfef8f3aca188df5dc4a31a59 100644 --- a/configs/arduino-due/src/arduino-due.h +++ b/configs/arduino-due/src/arduino-due.h @@ -166,7 +166,7 @@ * and the SD card. * 2. UART0 cannot be used. USARTs on the COMM connector should be available. * 3. Parallel data is not contiguous in the PIO register - * 4. Touchcontroller /CS pin is connected to ground (always selected). + * 4. Touch controller /CS pin is connected to ground (always selected). * 5. Either PA28 or PC29 may drive PWM10 */ @@ -308,7 +308,7 @@ * Public Functions ************************************************************************************/ -/**************************************************************************** +/************************************************************************************ * Name: sam_bringup * * Description: @@ -320,23 +320,44 @@ * CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y : * Called from the NSH library * - ****************************************************************************/ + ************************************************************************************/ int sam_bringup(void); -/**************************************************************************** +/************************************************************************************ * Name: sam_sdinitialize * * Description: * Initialize the SPI-based SD card. * - ****************************************************************************/ + ************************************************************************************/ #if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \ defined(CONFIG_MMCSD_SPI) int sam_sdinitialize(int minor); #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \ + defined(CONFIG_INPUT_ADS7843E) +int sam_tsc_setup(int minor); +#endif #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_ARDUINO_DUE_SRC_ARDUNO_DUE_H */ diff --git a/configs/arduino-due/src/sam_bringup.c b/configs/arduino-due/src/sam_bringup.c index 298a5b0dbb9704828450ed394b3629a041c9ed73..50dc141500b6377b56d241c0bf4e8f41d2b02b91 100644 --- a/configs/arduino-due/src/sam_bringup.c +++ b/configs/arduino-due/src/sam_bringup.c @@ -118,6 +118,17 @@ int sam_bringup(void) } #endif +#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \ + defined(CONFIG_INPUT_ADS7843E) + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + UNUSED(ret); return OK; } diff --git a/configs/arduino-due/src/sam_touchscreen.c b/configs/arduino-due/src/sam_touchscreen.c index 4e78c9376a161598eca7b0a1097862bc9c8d166f..48dae4c1625653ff823bcff3dc61efc62d02bb1f 100644 --- a/configs/arduino-due/src/sam_touchscreen.c +++ b/configs/arduino-due/src/sam_touchscreen.c @@ -336,13 +336,12 @@ static FAR struct spi_dev_s *sam_tsc_spiinitialize(void) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -353,79 +352,42 @@ static FAR struct spi_dev_s *sam_tsc_spiinitialize(void) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ + /* Configure and enable the XPT2046 interrupt pin as an input */ - if (!initialized) - { - /* Configure and enable the XPT2046 interrupt pin as an input */ - - (void)sam_configgpio(GPIO_TSC_IRQ); - - /* Configure the PIO interrupt */ + (void)sam_configgpio(GPIO_TSC_IRQ); - sam_gpioirq(SAM_TSC_IRQ); + /* Configure the PIO interrupt */ - /* Get an instance of the SPI interface for the touchscreen chip select */ + sam_gpioirq(SAM_TSC_IRQ); - dev = sam_tsc_spiinitialize(); - if (!dev) - { - ierr("ERROR: Failed to initialize bit bang SPI\n"); - return -ENODEV; - } + /* Get an instance of the SPI interface for the touchscreen chip select */ - /* Initialize and register the SPI touschscreen device */ - - ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - /* up_spiuninitialize(dev); */ - return -ENODEV; - } + dev = sam_tsc_spiinitialize(); + if (!dev) + { + ierr("ERROR: Failed to initialize bit bang SPI\n"); + return -ENODEV; + } - /* Now we are initialized */ + /* Initialize and register the SPI touschscreen device */ - initialized = true; + ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + /* up_spiuninitialize(dev); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen XPT2046 device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* CONFIG_ARDUINO_ITHEAD_TFT && CONFIG_SPI_BITBANG && CONFIG_INPUT_ADS7843E */ diff --git a/configs/boardctl.c b/configs/boardctl.c index d5404711354126b8a5cf3eac2d57a17ef17fa677..d7e6d3c4ee6f8d0f5bb279f058d2f5f556cca9f6 100644 --- a/configs/boardctl.c +++ b/configs/boardctl.c @@ -401,35 +401,6 @@ int boardctl(unsigned int cmd, uintptr_t arg) break; #endif -#ifdef CONFIG_BOARDCTL_TSCTEST - /* CMD: BOARDIOC_TSCTEST_SETUP - * DESCRIPTION: Touchscreen controller test configuration - * ARG: Touch controller device minor number - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_setup() - */ - - case BOARDIOC_TSCTEST_SETUP: - { - ret = board_tsc_setup((int)arg); - } - break; - - /* CMD: BOARDIOC_TSCTEST_TEARDOWN - * DESCRIPTION: Touchscreen controller test configuration - * ARG: None - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_teardown() - */ - - case BOARDIOC_TSCTEST_TEARDOWN: - { - board_tsc_teardown(); - ret = OK; - } - break; -#endif - default: { #ifdef CONFIG_BOARDCTL_IOCTL diff --git a/configs/cloudctrl/src/stm32_usb.c b/configs/cloudctrl/src/stm32_usb.c index 955377a5dd8cc1d85baa2fe985b427b7653804f2..bf13400a5b804ca8dffb8d10ffdafb2e837ceb70 100644 --- a/configs/cloudctrl/src/stm32_usb.c +++ b/configs/cloudctrl/src/stm32_usb.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -209,9 +210,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -272,11 +273,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/dk-tm4c129x/include/board.h b/configs/dk-tm4c129x/include/board.h index 5279f43cf3264bd6efca01e6bd4c172eef5b179e..c52a8f3b3ef29ce94ebb15a0e841948fd2b14e05 100644 --- a/configs/dk-tm4c129x/include/board.h +++ b/configs/dk-tm4c129x/include/board.h @@ -255,7 +255,7 @@ * Description: * Initialize and register the TMP-100 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: diff --git a/configs/dk-tm4c129x/src/tm4c_tmp100.c b/configs/dk-tm4c129x/src/tm4c_tmp100.c index 29ab1a9aeb1362723c7fcdb7ed4a4c34e96d0af2..0238c62bb5e0b88eb3e70343d976ead17728decc 100644 --- a/configs/dk-tm4c129x/src/tm4c_tmp100.c +++ b/configs/dk-tm4c129x/src/tm4c_tmp100.c @@ -68,7 +68,7 @@ * Description: * Initialize and register the LM-75 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: diff --git a/configs/ea3131/src/lpc31_usbhost.c b/configs/ea3131/src/lpc31_usbhost.c index fe16aa16378afecbe9ba8e50d414af6da84060ff..eee4f004decde2e6faec9f919920bb97a97e39e8 100644 --- a/configs/ea3131/src/lpc31_usbhost.c +++ b/configs/ea3131/src/lpc31_usbhost.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -225,8 +226,9 @@ int lpc31_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, - (main_t)ehci_waiter, (FAR char * const *)NULL); + pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); @@ -284,11 +286,11 @@ void lpc31_usbhost_vbusdrive(int rhport, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument that will accompany the interrupt * - * Returned value: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on failure. * ************************************************************************************/ diff --git a/configs/flipnclick-pic32mz/Kconfig b/configs/flipnclick-pic32mz/Kconfig index 109d9a47f37b61662703e7d75d7ddb838b2dfb4a..befce845ba996418745e0bebebb8a58f72429174 100644 --- a/configs/flipnclick-pic32mz/Kconfig +++ b/configs/flipnclick-pic32mz/Kconfig @@ -4,4 +4,30 @@ # if ARCH_BOARD_FLIPNCLICK_PIC32MZ -endif + +config FLIPNCLICK_PIC32MZ_SSD1306 + bool "SSD1306 Click Present" + default n + depends on LCD_SSD1306 + select NXSTART_EXTERNINIT if NX + +choice + prompt "SSD1306 mikroBUS" + default FLIPNCLICK_PIC32MZ_SSD1306_MBA + depends on FLIPNCLICK_PIC32MZ_SSD1306 + +config FLIPNCLICK_PIC32MZ_SSD1306_MBA + bool "mikroBUS A" + +config FLIPNCLICK_PIC32MZ_SSD1306_MBB + bool "mikroBUS B" + +config FLIPNCLICK_PIC32MZ_SSD1306_MBC + bool "mikroBUS C" + +config FLIPNCLICK_PIC32MZ_SSD1306_MBD + bool "mikroBUS D" + +endchoice # SSD1306 mikroBUS + +endif # ARCH_BOARD_FLIPNCLICK_PIC32MZ diff --git a/configs/flipnclick-pic32mz/README.txt b/configs/flipnclick-pic32mz/README.txt index 000cda2fcc0b43686d5a2493a023704476bb045f..5707bd1569a2853180a1815fa54f632232810b48 100644 --- a/configs/flipnclick-pic32mz/README.txt +++ b/configs/flipnclick-pic32mz/README.txt @@ -11,10 +11,13 @@ Contents Port Status On Board Debug Support + Using the mikroProg Creating Compatible NuttX HEX files Tool Issues Serial Console + SPI LEDs + SSD1306 OLED Configurations Port Status @@ -25,8 +28,20 @@ Port Status 2018-01-08: Created the basic board configuration for the Mikroe Flip&Click PIC32MZ board. No testing has yet been performed. At this point, I have not even figured out how I am going to load and debug - new firmware. I need understand how the memory map is set up when used - with the mikroBootloader. + new firmware. + 2018-02-08: I received a mikroProg PIC32 debugger (Thanks go to John Legg + of the Debug Shop!). + 2018-02-09: The NSH configuration is now functional, but only with the + RS-232 Click in mikroBUS slot B. There is, apparently, some mis- + information about how UART4 RX is connected in mikroBUS slot A; I + cannot receive serial there. But life is good in slot B. + 2018-02-10: Added the nxlines configuration to test the custom HiletGo + OLED on a Click proto board. Debug output indicates that the example is + running error free yet nothing appears on the OLED in mikroBUS slot A. + I tried slot D with same result. I also ported the configuration to + the Flip&Click SAM3X and got the same result. There could be SPI issues + on the PIC32MX, but more likely that there is an error in my custom + HiletGo Click. Damn! On Board Debug Support ====================== @@ -46,7 +61,8 @@ On Board Debug Support There is a simple application available at Mikroe that will allow you to write .hex files via the USB HID bootloader. However, in order to use the bootloader, you will have to control the memory map so that the - downloaded code does not clobber the bootloader. + downloaded code does not clobber the bootloader code FLASH, data + memory, exception vectors, etc. At this point, I have found no documentation describing how to build the code outside of the Mikroe toolchain for use with the Mikroe @@ -62,6 +78,66 @@ On Board Debug Support would, most likely, clobber the USB HID bootloader (and possibly the Arduino support as well). +Using the mikroProg +=================== + + WARNINGS: + + 1. Following there steps will most certainly overwrite the bootloader + that was factory installed in FLASH! + + 2. Due to the position and orientation of the mikroProg connector you + may lose functionality: If you attach mikroProg to the red side of + the board, you will not be able to use the Arduino Shield Connector + while the mikroProg connected. If you attach mikroProg to the white + side of the board, you will similarly lose access to mikroBUS + connectors A and D. + + Hindsight is 20/20 and in retrospect I would look for a right handler + header to priven the mikroProg connector from interfering with the + Arduino connection. + + Hardware setup + -------------- + + You will need to add a five pin header to the mikroProg connector between + the A and D mikroBUS sockets. + + Connect the mikroProg to the outer 5 pins of the mikroProg's 10-pin + connector to the 5-pin header, respecting the pin 1 position: The + colored wire on the ribbon cable should be on the same side as the tiny + arrow on the board indicating pin 1. + + Connect the mikroProg to your computer with the provided USB cable; also + power the Flip'n'Clip board with another USB cable connected to the + computer. Either USB port will provide power. + + Installing the Software + ----------------------- + + From the mikroProg website https://www.mikroe.com/mikroprog-pic-dspic-pic32 + Download: + + Drivers for mikroProg Suite + https://download.mikroe.com/setups/drivers/mikroprog/pic-dspic-pic32/mikroprog-pic-dspic-pic32-drivers.zip + + mikroProg Suite for PIC, dsPIC, PIC32 v260 + https://download.mikroe.com/setups/programming-software/mikroprog/pic-dspic-pic32/mikroprog-suite-pic-dspic-pic32-programming-software-setup-v260.zip + + Install the mikroProg Suite. From things I have read, I gather that you + must be Administrator when installing the tool The instructions say that + it will automatically install the drivers. It did not for me. + + To install the drivers... You will find several directories under + mikroprog-pic-dspic-pic32-drivers/. Select the correct directory and run + the .EXE file you find there. + + When I started the mikroProg suite, it could not find the USB driver. + After a few frustrating hours of struggling with the drivers, I found + that if I start the mikroProg suite as a normal user, it does not find + the driver. But if I instead start the mikroProg suite as Administrator... + There it is! A little awkward but works just fine. + Creating Compatible NuttX HEX files =================================== @@ -90,7 +166,8 @@ Creating Compatible NuttX HEX files cd tools/pic32mx make - Now you will have an excecutable file call mkpichex (or mkpichex.exe on + Now you will have an executable + file call mkpichex (or mkpichex.exe on Cygwin). This program will take the nutt.hex file as an input, it will convert all of the KSEG0 and KSEG1 addresses to physical address, and it will write the modified file, replacing the original nuttx.hex. @@ -100,7 +177,7 @@ Creating Compatible NuttX HEX files export PATH=??? # Add the NuttX tools/pic32mx directory to your # PATH variable make # Build nuttx and nuttx.hex - mkpichex $PWD # Convert addresses in nuttx.hex. $PWD is the path + mkpichex $PWD # Convert addresses in nuttx.hex. $PWD is the path # to the top-level build directory. It is the only # required input to mkpichex. @@ -142,8 +219,49 @@ Serial Console will leave that as an exercise for the interested reader. The outputs from these pins is 3.3V. You will need to connect RS232 - transceiver to get the signals to RS232 levels (or connect to the - USB virtual COM port in the case of UART0). + transceiver to get the signals to RS-232 levels. The simplest options are + an expensive Arduino RS-232 shield or a Mikroe RS-232 Click board. + + STATUS: I have been unable to get the RS-232 Click to work in the mikroBUS + A slot. The PIC32MZ did not receive serial input. It appears that there + is an error in the some documentation: Either RG9 is not connected to + UART4_RX or the PPS bit definitions are documented incorrectly for UART4. + + Switching to UART3 eliminates the problem and the serial console is fully + functional. I have not tried the other options of UART1, 2, or 5. + +SPI +=== + + SPI3 is available on pins D10-D13 of the Arduino Shield connectors where + you would expect then. The SPI connector is configured as follows: + + Pin J1 Board Signal PIC32MZ + --- -- ------------ ------- + D10 8 SPI3_SCK RB14 + D11 7 SPI3_MISO RB9 + D12 6 SPI3_MOSI RB10 + D13 5 SPI3_SS RB9 + + SPI1 and SPI2 are also available on the mikroBUS Click connectors (in + addition to 5V and GND). The connectivity between connectors A and B and + between C and D differs only in the chip select pin: + + MikroBUS A: MikroBUS B: + Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + ---- ------------ ------- ---- ------------ ------- + CS SPI2_SS1 RA0 CS SPI2_SS0 RE4 + SCK SPI2_SCK RG6 SCK SPI2_SCK RG6 + MISO SPI2_MISO RC4 MISO SPI2_MISO RC4 + MOSI SPI2_MOSI RB5 MOSI SPI2_MOSI RB5 + + MikroBUS C: MikroBUS D: + Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + ---- ------------ ------- ---- ------------ ------- + CS SPI1_SS0 RD12 CS SPI1_SS1 RD13 + SCK SPI1_SCK RD1 SCK SPI1_SCK RD1 + MISO SPI1_MISO RD2 MISO SPI1_MISO RD2 + MOSI SPI1_MOSI RD3 MOSI SPI1_MOSI RD3 LEDs and Buttons ================ @@ -183,8 +301,8 @@ LEDs and Buttons LED_PANIC The system has crashed 2Hz N/C N/C N/C N/C LED_IDLE MCU is is sleep mode ---- Not used ----- - Thus if LED L is glowing on and all other LEDs are off (except LED D which - was left on but is no longer controlled by NuttX and so may be in any + Thus if LED L is glowing faintly and all other LEDs are off (except LED D + which was left on but is no longer controlled by NuttX and so may be in any state), NuttX has successfully booted and is, apparently, running normally and taking interrupts. If any of LEDs A-D are statically set, then NuttX failed to boot and the LED indicates the initialization phase where the @@ -208,6 +326,27 @@ LEDs and Buttons The switches have external pull-up resistors. The switches are pulled high (+3.3V) and grounded when pressed. +SSD1306 OLED +============ + + Hardware + -------- + The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI + is the default and is what is used here). I have mounted the OLED on a + proto click board. The OLED is connected as follows: + + OLED ALIAS DESCRIPTION PROTO CLICK + ----- ----------- ------------- ----------------- + GND Ground GND + VCC Power Supply 5V (3-5V) + D0 SCL,CLK,SCK Clock SCK + D1 SDA,MOSI Data MOSI,SDI + RES RST,RESET Reset RST (GPIO OUTPUT) + DC AO Data/Command INT (GPIO OUTPUT) + CS Chip Select CS (GPIO OUTPUT) + + NOTE that this is a write-only display (MOSI only)! + Configurations ============== @@ -257,9 +396,9 @@ Where is one of the following: NOTES: - 1. Serial Console. UART 4 is configured as the Serial Console. This + 1. Serial Console. UART3 is configured as the Serial Console. This assumes that you will be using a Mikroe RS-232 Click card in the - mikroBUS A slot. Other serial consoles may be selected by re- + mikroBUS B slot. Other serial consoles may be selected by re- configuring (see the section "Serial Consoles" above). 2. Toolchain @@ -273,3 +412,28 @@ Where is one of the following: CONFIG_PIC32MZ_DEBUGGER_ENABLE=n : Debugger is disabled CONFIG_PIC32MZ_TRACE_ENABLE=n : Trace is disabled CONFIG_PIC32MZ_JTAG_ENABLE=n : JTAG is disabled + + nxlines + + This is an NSH configuration that supports the NX graphics example at + apps/examples/nxlines as a built-in application. + + NOTES: + + 1. This configuration derives from the nsh configuration. All of the + notes there apply here as well. + + 2. The default configuration assumes there is the custom HiletGo OLED + in the mikroBUS A slot (and a Mikroe RS-232 Click card in the + mikroBUS B slot). That is easily changed by reconfiguring, however. + See the section entitled "HiletGo OLED" for information about this + custom click card. + + STATUS: + + 2018-02-10: The debug output indicates that the nxlines example is + running with no errors, however, nothing appears on the OLED display. + I tried slot D with same result. I also ported the configuration to + the Flip&Click SAM3X and got the same result. There could be SPI issues + on the PIC32MX, but more likely that there is an error in my custom + HiletGo Click. Damn! diff --git a/configs/flipnclick-pic32mz/include/board.h b/configs/flipnclick-pic32mz/include/board.h index 490a8cde3fb6d9cc02630a7fb4d5d7ee14f6ff52..9fa460dd5d3e008af93a7d7c6858794aa2ff94cf 100644 --- a/configs/flipnclick-pic32mz/include/board.h +++ b/configs/flipnclick-pic32mz/include/board.h @@ -240,7 +240,7 @@ #define LED_PANIC 4 /* The system has crashed 2Hz N/C N/C N/C N/C */ #undef LED_IDLE /* MCU is is sleep mode ---- Not used ----- */ -/* Thus if LED L is glowing on and all other LEDs are off (except LED D which +/* Thus if LED L is faintly glowing and all other LEDs are off (except LED D which * was left on but is no longer controlled by NuttX and so may be in any state), * NuttX has successfully booted and is, apparently, running normally and taking * interrupts. If any of LEDs A-D are statically set, then NuttX failed to boot @@ -303,6 +303,52 @@ #define BOARD_U5RX_PPS U5RXR_RPD14 #define BOARD_U5TX_PPS U5TX_RPD15R +/* SPI **********************************************************************/ +/* SPI3 is available on pins D10-D13 of the Arduino Shield connectors where + * you would expect then. The SPI connector is configured as follows: + * + * Pin J1 Board Signal PIC32MZ + * --- -- ------------ ------- + * D10 8 SPI3_SCK RB14 + * D11 7 SPI3_MISO RB9 + * D12 6 SPI3_MOSI RB10 + * D13 5 SPI3_SS RB9 + * + * SPI1 and SPI2 are also available on the mikroBUS Click connectors (in + * addition to 5V and GND). The connectivity between connectors A and B and + * between C and D differs only in the chip select pin: + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + * ---- ------------ ------- ---- ------------ ------- + * CS SPI2_SS1 RA0 CS SPI2_SS0 RE4 + * SCK SPI2_SCK RG6 SCK SPI2_SCK RG6 + * MISO SPI2_MISO RC4 MISO SPI2_MISO RC4 + * MOSI SPI2_MOSI RB5 MOSI SPI2_MOSI RB5 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + * ---- ------------ ------- ---- ------------ ------- + * CS SPI1_SS0 RD12 CS SPI1_SS1 RD13 + * SCK SPI1_SCK RD1 SCK SPI1_SCK RD1 + * MISO SPI1_MISO RD2 MISO SPI1_MISO RD2 + * MOSI SPI1_MOSI RD3 MOSI SPI1_MOSI RD3 + * + * Chip select pin definitions are provided in + * configs/flipnclick-pic32mz/src/flipnclick-pic32mz.h. + * + * CLK (output) pins have no alternative pin configurations. + */ + +#define BOARD_SDI1_PPS SDI1R_RPD2 +#define BOARD_SDO1_PPS SDO1_RPD3R + +#define BOARD_SDI2_PPS SDI2R_RPC4 +#define BOARD_SDO2_PPS SDO2_RPB5R + +#define BOARD_SDI3_PPS SDI3R_RPB9 +#define BOARD_SDO3_PPS SDO3_RPB9R + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/configs/flipnclick-pic32mz/nsh/defconfig b/configs/flipnclick-pic32mz/nsh/defconfig index 93cfe3849c628a9988761ba8a67255c2525f8647..7087220d9fc84cf8bd28b81ed42adc9f2f8dc29e 100644 --- a/configs/flipnclick-pic32mz/nsh/defconfig +++ b/configs/flipnclick-pic32mz/nsh/defconfig @@ -1,6 +1,6 @@ # CONFIG_ARCH_RAMFUNCS is not set -# CONFIG_NSH_DISABLE_IFCONFIG is not set -# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_PIC32MZ_DEBUGGER_ENABLE is not set +# CONFIG_PIC32MZ_TRACE_ENABLE is not set CONFIG_ARCH_BOARD_FLIPNCLICK_PIC32MZ=y CONFIG_ARCH_BOARD="flipnclick-pic32mz" CONFIG_ARCH_CHIP_PIC32MZ=y @@ -11,11 +11,11 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="mips" CONFIG_BOARD_LOOPSPERMSEC=7245 CONFIG_BUILTIN=y -CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y CONFIG_HOST_WINDOWS=y CONFIG_IDLETHREAD_STACKSIZE=2048 CONFIG_INTELHEX_BINARY=y @@ -29,11 +29,12 @@ CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_STREAMS=8 CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_LINELEN=64 CONFIG_NSH_READLINE=y CONFIG_PIC32MZ_ICESEL_CH2=y -CONFIG_PIC32MZ_UART4=y +CONFIG_PIC32MZ_UART3=y CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_PREALLOC_TIMERS=4 CONFIG_PREALLOC_WDOGS=8 @@ -45,7 +46,6 @@ CONFIG_SDCLONE_DISABLE=y CONFIG_START_DAY=7 CONFIG_START_MONTH=3 CONFIG_START_YEAR=2012 -CONFIG_TASK_NAME_SIZE=0 -CONFIG_UART4_SERIAL_CONSOLE=y +CONFIG_UART3_SERIAL_CONSOLE=y CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_WDOG_INTRESERVE=1 diff --git a/configs/flipnclick-pic32mz/nxlines/defconfig b/configs/flipnclick-pic32mz/nxlines/defconfig new file mode 100644 index 0000000000000000000000000000000000000000..bf09c0b9ac4d99ce1b0791b02c0d568099ca2361 --- /dev/null +++ b/configs/flipnclick-pic32mz/nxlines/defconfig @@ -0,0 +1,62 @@ +# CONFIG_ARCH_RAMFUNCS is not set +# CONFIG_NX_DISABLE_1BPP is not set +# CONFIG_PIC32MZ_DEBUGGER_ENABLE is not set +# CONFIG_PIC32MZ_TRACE_ENABLE is not set +CONFIG_ARCH_BOARD_FLIPNCLICK_PIC32MZ=y +CONFIG_ARCH_BOARD="flipnclick-pic32mz" +CONFIG_ARCH_CHIP_PIC32MZ=y +CONFIG_ARCH_CHIP_PIC32MZ2048EFH=y +CONFIG_ARCH_CHIP_PIC32MZEF=y +CONFIG_ARCH_MIPS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH="mips" +CONFIG_BOARD_LOOPSPERMSEC=7245 +CONFIG_BUILTIN=y +CONFIG_EXAMPLES_NSH=y +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4 +CONFIG_EXAMPLES_NXLINES_BPP=1 +CONFIG_EXAMPLES_NXLINES_LINEWIDTH=4 +CONFIG_EXAMPLES_NXLINES=y +CONFIG_FLIPNCLICK_PIC32MZ_SSD1306=y +CONFIG_FS_PROCFS=y +CONFIG_HOST_WINDOWS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INTELHEX_BINARY=y +CONFIG_LCD_HILETGO=y +CONFIG_LCD_MAXCONTRAST=255 +CONFIG_LCD=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MIPS_MICROMIPS=y +CONFIG_MIPS32_TOOLCHAIN_PINGUINOW=y +CONFIG_MMCSD=y +CONFIG_MQ_MAXMSGSIZE=64 +CONFIG_MTD=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_NX_BLOCKING=y +CONFIG_NX=y +CONFIG_NXFONT_TOM_THUMB_4X6=y +CONFIG_NXTK_BORDERWIDTH=2 +CONFIG_PIC32MZ_ICESEL_CH2=y +CONFIG_PIC32MZ_SPI2=y +CONFIG_PIC32MZ_UART3=y +CONFIG_PREALLOC_MQ_MSGS=8 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=8 +CONFIG_RAM_SIZE=131072 +CONFIG_RAM_START=0xa0000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=10 +CONFIG_START_MONTH=2 +CONFIG_UART3_SERIAL_CONSOLE=y +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WDOG_INTRESERVE=1 diff --git a/configs/flipnclick-pic32mz/src/Makefile b/configs/flipnclick-pic32mz/src/Makefile index c8226dc95ef47b0b714eed37113e81ecea41b12e..529b5c926ce8d2bb9bbd15c6ae743368bcd66c13 100644 --- a/configs/flipnclick-pic32mz/src/Makefile +++ b/configs/flipnclick-pic32mz/src/Makefile @@ -1,7 +1,7 @@ ############################################################################ # configs/flipnclick-pic32mz/src/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -50,4 +50,8 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += pic32mz_buttons.c endif +ifeq ($(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306),y) +CSRCS += pic32mz_ssd1306.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/flipnclick-pic32mz/src/flipnclick-pic32mz.h b/configs/flipnclick-pic32mz/src/flipnclick-pic32mz.h index a1cbc0a8ebc6a19dc6a2421fda7897b1ba9d8e0f..f349e69f63f3b918f3613a49dd1c90053fcafbe5 100644 --- a/configs/flipnclick-pic32mz/src/flipnclick-pic32mz.h +++ b/configs/flipnclick-pic32mz/src/flipnclick-pic32mz.h @@ -48,6 +48,22 @@ ****************************************************************************/ /* Configuration ************************************************************/ +#define HAVE_SSD1306 1 + +/* The SSD1306 LCD must be selected, installed on the Flip&Click, and must + * be configured to use the SPI interface. + */ + +#if !defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306) || \ + !defined(CONFIG_LCD_SSD1306_SPI) +# undef HAVE_SSD1306 +# undef CONFIG_FLIPNCLICK_PIC32MZ_SSD1306 +# undef CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBA +# undef CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBB +# undef CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBC +# undef CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBD +#endif + /* LEDs *********************************************************************/ /* There are four LEDs on the top, red side of the board. Only one can be * controlled by software: @@ -85,6 +101,119 @@ #define GPIO_T1 (GPIO_INPUT | GPIO_INTERRUPT | GPIO_PORTD | GPIO_PIN10) #define GPIO_T2 (GPIO_INPUT | GPIO_INTERRUPT | GPIO_PORTD | GPIO_PIN11) +/* SPI Chip Selects + * + * SPI3 is available on pins D10-D13 of the Arduino Shield connectors where + * you would expect then. The SPI connector is configured as follows: + * + * Pin J1 Board Signal PIC32MZ + * --- -- ------------ ------- + * D10 8 SPI3_SCK RB14 + * D10 7 SPI3_MISO RB9 + * D11 6 SPI3_MOSI RB10 + * D13 5 SPI3_SS RB9 + */ + +#define GPIO_ARD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTB | GPIO_PIN14) + +/* SPI1 and SPI2 are also available on the mikroBUS Click connectors (in + * addition to 5V and GND). The connectivity between connectors A and B and + * between C and D differs only in the chip select pin: + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + * ---- ------------ ------- ---- ------------ ------- + * CS SPI2_SS1 RA0 CS SPI2_SS0 RE4 + * SCK SPI2_SCK RG6 SCK SPI2_SCK RG6 + * MISO SPI2_MISO RC4 MISO SPI2_MISO RC4 + * MOSI SPI2_MOSI RB5 MOSI SPI2_MOSI RB5 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + * ---- ------------ ------- ---- ------------ ------- + * CS SPI1_SS0 RD12 CS SPI1_SS1 RD13 + * SCK SPI1_SCK RD1 SCK SPI1_SCK RD1 + * MISO SPI1_MISO RD2 MISO SPI1_MISO RD2 + * MOSI SPI1_MOSI RD3 MOSI SPI1_MOSI RD3 + */ + +#define GPIO_MBA_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTA | GPIO_PIN0) +#define GPIO_MBB_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTE | GPIO_PIN4) +#define GPIO_MBC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTD | GPIO_PIN12) +#define GPIO_MBD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTD | GPIO_PIN13) + +/* SSD1306 OLED + * + * The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI + * is the default and is what is used here). I have mounted the OLED on a + * proto click board. The OLED is connected as follows: + * + * OLED ALIAS DESCRIPTION PROTO CLICK + * ----- ----------- ------------- ----------------- + * GND Ground GND + * VCC Power Supply 5V (3-5V) + * D0 SCL,CLK,SCK Clock SCK + * D1 SDA,MOSI Data MOSI,SDI + * RES RST,RESET Reset RST (GPIO OUTPUT) + * DC AO Data/Command INT (GPIO OUTPUT) + * CS Chip Select CS (GPIO OUTPUT) + * + * NOTE that this is a write-only display (MOSI only)! + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + * ---- ------------ ------- ---- ------------ ------- + * RST RST4 RE2 RST RST3 RG13 + * DC INT4 RD9 DC INT3 RG1 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ + * ---- ------------ ------- ---- ------------ ------- + * RST RST1 RG14 RST RST2 RG12 + * DC INT1 RD5 DC INT2 RD4 + */ + +#if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBA) +# ifndef CONFIG_PIC32MZ_SPI2 +# error "The OLED driver requires CONFIG_PIC32MZ_SPI2 in the configuration" +# endif + +# define SSD1306_SPI_BUS 2 +# define GPIO_SSD1306_CS GPIO_MBA_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTE | GPIO_PIN2) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTD | GPIO_PIN9) + +#elif defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBB) +# ifndef CONFIG_PIC32MZ_SPI2 +# error "The OLED driver requires CONFIG_PIC32MZ_SPI2 in the configuration" +# endif + +# define SSD1306_SPI_BUS 2 +# define GPIO_SSD1306_CS GPIO_MBB_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN13) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN1) + +#elif defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBC) +# ifndef CONFIG_PIC32MZ_SPI1 +# error "The OLED driver requires CONFIG_PIC32MZ_SPI1 in the configuration" +# endif + +# define SSD1306_SPI_BUS 1 +# define GPIO_SSD1306_CS GPIO_MBC_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN14) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTD | GPIO_PIN5) + +#elif defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBD) +# ifndef CONFIG_PIC32MZ_SPI1 +# error "The OLED driver requires CONFIG_PIC32MZ_SPI1 in the configuration" +# endif + +# define SSD1306_SPI_BUS 1 +# define GPIO_SSD1306_CS GPIO_MBD_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN12) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTD | GPIO_PIN4) +#endif + /**************************************************************************** * Public Types ****************************************************************************/ @@ -141,6 +270,21 @@ void pic32mz_led_initialize(void); int pic32mz_bringup(void); +/**************************************************************************** + * Name: pic32mz_graphics_setup + * + * Description: + * Called by either NX initialization logic (via board_graphics_setup) or + * directly from the board bring-up logic in order to configure the + * SSD1306 OLED. + * + ****************************************************************************/ + +#ifdef HAVE_SSD1306 +struct lcd_dev_s; /* Forward reference */ +FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/configs/flipnclick-pic32mz/src/pic32mz_autoleds.c b/configs/flipnclick-pic32mz/src/pic32mz_autoleds.c index 01d05ea00d07159628af4bdce10c0a6625642ced..fc229ea532ec5d83ca10f12f2d631586fe58d96d 100644 --- a/configs/flipnclick-pic32mz/src/pic32mz_autoleds.c +++ b/configs/flipnclick-pic32mz/src/pic32mz_autoleds.c @@ -57,6 +57,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* There are four LEDs on the top, red side of the board. Only one can be * controlled by software: * @@ -89,8 +90,8 @@ * LED_PANIC The system has crashed 2Hz N/C N/C N/C N/C * LED_IDLE MCU is is sleep mode ---- Not used ----- * - * Thus if LED L is glowing on and all other LEDs are off (except LED D - * which was left on but is no longer controlled by NuttX and so may be in + * Thus if LED L is faintly glowing and all other LEDs are off (except LED + * D which was left on but is no longer controlled by NuttX and so may be in * any state), NuttX has successfully booted and is, apparently, running * normally and taking interrupts. If any of LEDs A-D are statically set, * then NuttX failed to boot and the LED indicates the initialization phase @@ -122,7 +123,7 @@ static void board_autoled_setone(int ledndx) pic32mz_gpiowrite(GPIO_LED_L, ledon[INDEX_LED_L]); pic32mz_gpiowrite(GPIO_LED_A, ledon[INDEX_LED_A]); pic32mz_gpiowrite(GPIO_LED_B, ledon[INDEX_LED_B]); - pic32mz_gpiowrite(GPIO_LED_C, ledon[INDEX_LED_D]); + pic32mz_gpiowrite(GPIO_LED_C, ledon[INDEX_LED_C]); pic32mz_gpiowrite(GPIO_LED_D, ledon[INDEX_LED_D]); } @@ -175,7 +176,7 @@ void board_autoled_on(int led) board_autoled_setone(INDEX_LED_B); break; - case 2: + case 2: board_autoled_setone(INDEX_LED_C); break; diff --git a/configs/flipnclick-pic32mz/src/pic32mz_bringup.c b/configs/flipnclick-pic32mz/src/pic32mz_bringup.c index 3ce4337fe40b44b7687b6e5cafc3f763b08311ee..c24c4cc9ea09deac2d08c3897c03a907d2210b7d 100644 --- a/configs/flipnclick-pic32mz/src/pic32mz_bringup.c +++ b/configs/flipnclick-pic32mz/src/pic32mz_bringup.c @@ -40,6 +40,8 @@ #include #include +#include +#include #include "flipnclick-pic32mz.h" @@ -59,6 +61,26 @@ int pic32mz_bringup(void) { int ret; +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR,"ERROR: Failed to mount procfs at /proc: %d\n", + ret); + } +#endif + +#if defined(HAVE_SSD1306) && !defined(CONFIG_NXSTART_EXTERNINIT) + /* Configure the SSD1306 OLED */ + + if (pic32mz_graphics_setup(0) == NULL) + { + syslog(LOG_ERR,"ERROR: Failed to configure the SSD1306 OLED\n"); + } +#endif + UNUSED(ret); return OK; } diff --git a/configs/flipnclick-pic32mz/src/pic32mz_spi.c b/configs/flipnclick-pic32mz/src/pic32mz_spi.c index c1387b8054f66efe784516cc7ba8d0e8f65ab772..5817945842e62de6a8873c0330ee51aec4959bed 100644 --- a/configs/flipnclick-pic32mz/src/pic32mz_spi.c +++ b/configs/flipnclick-pic32mz/src/pic32mz_spi.c @@ -43,9 +43,12 @@ #include #include +#include + #include #include "up_arch.h" +#include "pic32mz-gpio.h" #include "flipnclick-pic32mz.h" @@ -65,9 +68,12 @@ void weak_function pic32mz_spidev_initialize(void) { - /* Configure the SPI chip select GPIOs */ +#ifdef HAVE_SSD1306 + /* Configure the SSD1306 chip select and command/data GPIOs */ -#warning "Missing logic" + (void)pic32mz_configgpio(GPIO_SSD1306_CS); + (void)pic32mz_configgpio(GPIO_SSD1306_DC); +#endif } /************************************************************************************ @@ -104,95 +110,130 @@ struct spi_dev_s; void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#warning "Missing logic" + +#if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBC) || \ + defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBD) + if (devid == SPIDEV_DISPLAY(0)) + { + /* Low: the display is selected + * High: the display is deselected + */ + + pic32mz_gpiowrite(GPIO_SSD1306_CS, !selected); + } +#endif } uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); -#warning "Missing logic" return 0; } #ifdef CONFIG_SPI_CMDDATA int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) { -#warning "Missing logic" +#if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBC) || \ + defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBD) + if (devid == SPIDEV_DISPLAY(0)) + { + /* High: the inputs are treated as display data. + * Low: the inputs are transferred to the command registers. + */ + + pic32mz_gpiowrite(GPIO_SSD1306_DC, !cmd); + } +#endif + return 0; } #endif -#endif +#endif /* CONFIG_PIC32MZ_SPI1 */ #ifdef CONFIG_PIC32MZ_SPI2 void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#warning "Missing logic" + +#if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBA) || \ + defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBB) + if (devid == SPIDEV_DISPLAY(0)) + { + /* Low: the display is selected + * High: the display is deselected + */ + + pic32mz_gpiowrite(GPIO_SSD1306_CS, !selected); + } +#endif } uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); -#warning "Missing logic" return 0; } #ifdef CONFIG_SPI_CMDDATA int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) { -#warning "Missing logic" +#if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBA) || \ + defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBB) + if (devid == SPIDEV_DISPLAY(0)) + { + /* High: the inputs are treated as display data. + * Low: the inputs are transferred to the command registers. + */ + + pic32mz_gpiowrite(GPIO_SSD1306_DC, !cmd); + } +#endif + return 0; } #endif -#endif +#endif /* CONFIG_PIC32MZ_SPI2 */ #ifdef CONFIG_PIC32MZ_SPI3 void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#warning "Missing logic" } uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); -#warning "Missing logic" return 0; } #ifdef CONFIG_SPI_CMDDATA int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) { -#warning "Missing logic" return 0; } #endif -#endif +#endif /* CONFIG_PIC32MZ_SPI3 */ #ifdef CONFIG_PIC32MZ_SPI4 void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#warning "Missing logic" } uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); -#warning "Missing logic" return 0; } #ifdef CONFIG_SPI_CMDDATA int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) { -#warning "Missing logic" return 0; } #endif -#endif +#endif /* CONFIG_PIC32MZ_SPI4 */ #ifdef CONFIG_PIC32MZ_SPI5 void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#warning "Missing logic" } uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) @@ -208,7 +249,7 @@ int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) return 0; } #endif -#endif +#endif /* CONFIG_PIC32MZ_SPI5 */ #ifdef CONFIG_PIC32MZ_SPI6 void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) @@ -230,6 +271,82 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) return 0; } #endif -#endif +#endif /* CONFIG_PIC32MZ_SPI6 */ + +/**************************************************************************** + * Name: pic32mz_spi1/2/...register + * + * Description: + * If the board supports a card detect callback to inform the SPI-based + * MMC/SD driver when an SD card is inserted or removed, then + * CONFIG_SPI_CALLBACK should be defined and the following function(s) + * must be implemented. These functions implements the registercallback + * method of the SPI interface (see include/nuttx/spi/spi.h for details) + * + * Input Parameters: + * dev - Device-specific state data + * callback - The function to call on the media change + * arg - A caller provided value to return with the callback + * + * Returned Value: + * 0 on success; negated errno on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_SPI_CALLBACK +#ifdef CONFIG_PIC32MZ_SPI1 +int pic32mz_spi1register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg) +{ +#warning Missing logic + return -ENOSYS; +} +#endif /* CONFIG_PIC32MZ_SPI1 */ + +#ifdef CONFIG_PIC32MZ_SPI2 +int pic32mz_spi2register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg) +{ +#warning Missing logic + return -ENOSYS; +} +#endif /* CONFIG_PIC32MZ_SPI2 */ + +#ifdef CONFIG_PIC32MZ_SPI3 +int pic32mz_spi3register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg) +{ +#warning Missing logic + return -ENOSYS; +} +#endif /* CONFIG_PIC32MZ_SPI3 */ + +#ifdef CONFIG_PIC32MZ_SPI4 +int pic32mz_spi4register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg) +{ +#warning Missing logic + return -ENOSYS; +} +#endif /* CONFIG_PIC32MZ_SPI4 */ + +#ifdef CONFIG_PIC32MZ_SPI5 +int pic32mz_spi5register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg) +{ +#warning Missing logic + return -ENOSYS; +} +#endif /* CONFIG_PIC32MZ_SPI5 */ + +#ifdef CONFIG_PIC32MZ_SPI6 +int pic32mz_spi6register(FAR struct spi_dev_s *dev, spi_mediachange_t callback, + FAR void *arg) +{ +#warning Missing logic + return -ENOSYS; +} +#endif /* CONFIG_PIC32MZ_SPI6 */ +#endif /* CONFIG_SPI_CALLBACK */ #endif /* CONFIG_PIC32MZ_SPI */ diff --git a/configs/flipnclick-pic32mz/src/pic32mz_ssd1306.c b/configs/flipnclick-pic32mz/src/pic32mz_ssd1306.c new file mode 100644 index 0000000000000000000000000000000000000000..47e4b29b6f4970454e89bcf1e14c4d24aaa83efd --- /dev/null +++ b/configs/flipnclick-pic32mz/src/pic32mz_ssd1306.c @@ -0,0 +1,172 @@ +/**************************************************************************** + * config/flipnclick-pic32mz/src/pic32mz_ssd1306.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* SSD1306 OLED + * + * The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI + * is the default and is what is used here). I have mounted the OLED on a + * proto click board. The OLED is connected as follows: + * + * OLED ALIAS DESCRIPTION PROTO CLICK + * ----- ----------- ------------- ----------------- + * GND Ground GND + * VCC Power Supply 5V (3-5V) + * D0 SCL,CLK,SCK Clock SCK + * D1 SDA,MOSI Data MOSI,SDI + * RES RST,RESET Reset RST (GPIO OUTPUT) + * DC AO Data/Command INT (GPIO OUTPUT) + * CS Chip Select CS (GPIO OUTPUT) + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include + +#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER) +# include +#endif + +#include "pic32mz-gpio.h" +#include "pic32mz-spi.h" + +#include "flipnclick-pic32mz.h" + +#ifdef HAVE_SSD1306 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifndef CONFIG_SPI_CMDDATA +# error "The OLED driver requires CONFIG_SPI_CMDDATA in the configuration" +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pic32mz_graphics_setup + * + * Description: + * Called by either NX initialization logic (via board_graphics_setup) or + * directly from the board bring-up logic in order to configure the + * SSD1306 OLED. + * + ****************************************************************************/ + +FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno) +{ + FAR struct spi_dev_s *spi; + FAR struct lcd_dev_s *dev; + + /* Configure the OLED GPIOs. This initial configuration is RESET low, + * putting the OLED into reset state. + */ + + (void)pic32mz_configgpio(GPIO_SSD1306_RST); + + /* Wait a bit then release the OLED from the reset state */ + + up_mdelay(20); + pic32mz_gpiowrite(GPIO_SSD1306_RST, true); + + /* Get the SPI1 port interface */ + + spi = pic32mz_spibus_initialize(SSD1306_SPI_BUS); + if (!spi) + { + lcderr("ERROR: Failed to initialize SPI port 1\n"); + } + else + { + /* Bind the SPI port to the OLED */ + + dev = ssd1306_initialize(spi, NULL, devno); + if (!dev) + { + lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); + } + else + { + lcdinfo("Bound SPI port 1 to OLED %d\n", devno); + + /* And turn the OLED on */ + + (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); + +#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER) + /* Initialize and register the simulated framebuffer driver */ + + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); + } +#endif + + return dev; + } + } + + return NULL; +} + +/**************************************************************************** + * Name: board_graphics_setup + * + * Description: + * Called by NX initialization logic to configure the OLED. + * + ****************************************************************************/ + +#ifdef CONFIG_NXSTART_EXTERNINIT +FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno) +{ + return pic32mz_graphics_setup(devno); +} +#endif + +#endif /* HAVE_SSD1306 */ diff --git a/configs/flipnclick-sam3x/Kconfig b/configs/flipnclick-sam3x/Kconfig index 166b712c2a9d0ca41732341b3702f528896af141..07f939ec79bf177a261ad5520986668da139bdb8 100644 --- a/configs/flipnclick-sam3x/Kconfig +++ b/configs/flipnclick-sam3x/Kconfig @@ -4,4 +4,30 @@ # if ARCH_BOARD_FLIPNCLICK_SAM3X + +config FLIPNCLICK_SAM3X_SSD1306 + bool "SSD1306 Click Present" + default n + depends on LCD_SSD1306 + select NXSTART_EXTERNINIT if NX + +choice + prompt "SSD1306 mikroBUS" + default FLIPNCLICK_SAM3X_SSD1306_MBA + depends on FLIPNCLICK_SAM3X_SSD1306 + +config FLIPNCLICK_SAM3X_SSD1306_MBA + bool "mikroBUS A" + +config FLIPNCLICK_SAM3X_SSD1306_MBB + bool "mikroBUS B" + +config FLIPNCLICK_SAM3X_SSD1306_MBC + bool "mikroBUS C" + +config FLIPNCLICK_SAM3X_SSD1306_MBD + bool "mikroBUS D" + +endchoice # SSD1306 mikroBUS + endif diff --git a/configs/flipnclick-sam3x/README.txt b/configs/flipnclick-sam3x/README.txt index 38c319414f6c9229c69b7f4e343ec884916dee85..c4d154ae4587443f1acf6aa221898499f73ef996 100644 --- a/configs/flipnclick-sam3x/README.txt +++ b/configs/flipnclick-sam3x/README.txt @@ -14,6 +14,9 @@ Contents - STATUS - Buttons and LEDs - Serial Consoles + - SPI + - I2C + - SSD1306 OLED - Loading Code - Flip&Click SAM3X-specific Configuration Options - Configurations @@ -22,23 +25,16 @@ STATUS ====== 2018-01-07: Created the configuration. At present it does not work; I - believe because of tool-related issues. I do the following: - - a) Open TeraTerm, select COM7 at 1200 baud, type a few ENTERs, and - close teraterm. - - b) Execute the following command which claims to have successfully - written to FLASH. - - bossac.exe --info --debug --port COM7 --usb-port=0 --erase --write --verify -b nuttx.bin -R - - But the code does not boot. There is no indication of life. - - c) Repeat a) then - - bossac.exe --info --debug --port COM7 --usb-port=0 --verify -b nuttx.bin - - And it says that the content of the FLASH is not good. + believe because of tool-related issues. See discussion under "Loading + Code" below. + 2018-01-24: I ordered a JTAG connector and soldered that to the Flip'n'Click + and I am now successfully able to load code. The NSH configuration appears + to be fully functional. + 2018-02-11: Added the nxlines configuration to test the custom HiletGo + OLED on a Click proto board. This is the same logic from the Flip&Click + PIC32MZ and the result is the same: No complaints from the software, but + nothing appears on the OLED. There is, most likely, an error in my custom + HiletGo Click. Damn! Buttons and LEDs ================ @@ -81,8 +77,8 @@ Buttons and LEDs LED_PANIC The system has crashed 2Hz N/C N/C N/C N/C LED_IDLE MCU is is sleep mode ---- Not used ----- - Thus if LED L is glowing on and all other LEDs are off (except LED D which - was left on but is no longer controlled by NuttX and so may be in any + Thus if LED L is glowing faintly and all other LEDs are off (except LED D + which was left on but is no longer controlled by NuttX and so may be in any state), NuttX has successfully booted and is, apparently, running normally and taking interrupts. If any of LEDs A-D are statically set, then NuttX failed to boot and the LED indicates the initialization phase where the @@ -99,10 +95,11 @@ Serial Consoles serial chip connected to the first of the MCU (RX0 and TX0 on PA8 and PA9, respectively). The output from that port is visible using the Arduino tool. - Any of UART and USART0-3 may be used as a serial console. By default, - UART0 is used as the serial console in all configurations. But that is - easily changed by modifying the configuration as described under - "Configurations" below. + [NOTE: My experience so far: I get serial output on the virtual COM port + via the UART, but I receive no serial input for keyboard data entered in + the PC serial terminal. I have not investigated this problem. It may + be something as simple as the Rx pin configuration. Instead, I just + switched to USART0.] Other convenient U[S]ARTs that may be used as the Serial console include: @@ -125,9 +122,103 @@ Serial Consoles transceiver to get the signals to RS232 levels (or connect to the USB virtual COM port in the case of UART0). + Any of UART and USART0-3 may be used as a serial console. UART0 would + be the preferred default console setting. However, due to the communication + problems mentioned above, USART0 is used as the default serial console + in all configurations. But that is easily changed by modifying the + configuration as described under "Configurations" below. + +SPI +=== + + SPI0 is available on the Arduino compatible SPI connector (but no SPI is + available on pins D10-D13 of the main Arduino Shield connectors where + you might expect then). The SPI connector is configured as follows: + + Pin Board Signal SAM3X Pin Board Signal SAM3X + --- ------------ ----- --- ------------ ----- + 1 SPI0_MISO PA25 2 VCC-5V N/A + 3 SPI0_SCK PA27 4 SPI0_MOSI PA26 + 5 MRST NRSTB 6 GND N/A + + SPI0 is also available on each of the mikroBUS Click connectors (in + addition to 5V and GND). The connectivity differs only in the chip + select pin: + + MikroBUS A: MikroBUS B: + Pin Board Signal SAM3X Pin Board Signal SAM3X + ---- ------------ ----- ---- ------------ ----- + CS SPI0_CS0 PA28 CS PA29 PA29 + SCK SPI0_SCK PA27 SCK SPI0_SCK PA27 + MISO SPI0_MISO PA25 MISO SPI0_MISO PA25 + MOSI SPI0_MOSI PA26 MOSI SPI0_MOSI PA26 + + MikroBUS C: MikroBUS D: + Pin Board Signal SAM3X Pin Board Signal SAM3X + ---- ------------ ----- ---- ------------ ----- + CS SPI0_CS2 PB21 CS SPI0_CS3 PB23 + SCK SPI0_SCK PA27 SCK SPI0_SCK PA27 + MISO SPI0_MISO PA25 MISO SPI0_MISO PA25 + MOSI SPI0_MOSI PA26 MOSI SPI0_MOSI PA26 + +I2C +=== + + I2C0 is available on pins D16-D17 of the Arduino Shield connectors where + you would expect then. The SPI connector is configured as follows: + + Pin Label J1 Board Signal SAM3X + --- ----- -- ------------ ----- + D16 SCL1 8 I2C0_SCL PA17 + D17 SDA1 7 I2C0_SDA PA18 + + I2C0 and I2C1 are also available on the mikroBUS Click connectors (in + addition to 5V and GND). The connectors A and B share I2C0 with the + Arduino shield connector. Connectors C and D both connect to I2C1: + + MikroBUS A: MikroBUS B: + Pin Board Signal SAM3X Pin Board Signal SAM3X + ---- ------------ ----- ---- ------------ ------- + SCL I2C0_SCL PA17 SCL I2C0_SCL PA17 + SDA I2C0_SDA PA1 SDA I2C0_SDA PA18 + + MikroBUS C: MikroBUS D: + Pin Board Signal SAM3X Pin Board Signal SAM3X + ---- ------------ ----- ---- ------------ ------- + SCL I2C1_SCL PB13 SCL I2C1_SCL PB13 + SDA I2C1_SDA PB12 SDA I2C1_SDA PB12 + +SSD1306 OLED +============ + + Hardware + -------- + The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI + is the default and is what is used here). I have mounted the OLED on a + proto click board. The OLED is connected as follows: + + OLED ALIAS DESCRIPTION PROTO CLICK + ----- ----------- ------------- ----------------- + GND Ground GND + VCC Power Supply 5V (3-5V) + D0 SCL,CLK,SCK Clock SCK + D1 SDA,MOSI Data MOSI,SDI + RES RST,RESET Reset RST (GPIO OUTPUT) + DC AO Data/Command INT (GPIO OUTPUT) + CS Chip Select CS (GPIO OUTPUT) + + NOTE that this is a write-only display (MOSI only)! + Loading Code ============ + [NOTE: This text was mostly copied from the Arduino Due README.txt. I + believe, however, that there have been significant changes to the + tool environment such that Bossac may no longer be usable. I don't + know that for certain and perhaps someone with more knowledge of + the tools than I could make this work. See STATUS below for the + current issues that I see.] + Installing the Arduino USB Driver under Windows ----------------------------------------------- @@ -302,6 +393,25 @@ Loading Code $ bossac.exe --port=COM7 --usb-port=false --boot=1 Set boot flash true + STATUS: + At present this procedure does not work. I do the following: + + a) Open TeraTerm, select COM7 at 1200 baud, type a few ENTERs, and + close teraterm. + + b) Execute the following command which claims to have successfully + written to FLASH. + + bossac.exe --info --debug --port COM7 --usb-port=0 --erase --write --verify -b nuttx.bin -R + + But the code does not boot. There is no indication of life. + + c) Repeat a) then + + bossac.exe --info --debug --port COM7 --usb-port=0 --verify -b nuttx.bin + + And it says that the content of the FLASH is not good. + Uploading NuttX to the Flip&Click Using JTAG -------------------------------------------- @@ -309,24 +419,29 @@ Loading Code PIN SIGNAL JTAG STANDARD NOTES --- -------------- ----------------- -------------------------------- - 1 3.3V VTref + 1 VCC-3.3V VTref 2 JTAG_TMS SWDIO/TMS SAM3X pin 31, Pulled up on board 3 GND GND 4 JTAG_TCK SWDCLK/TCK SAM3X pin 28, Pulled up on board 5 GND GND - 6 JTAG_TDO SWO/EXta/TRACECTL SAM3X pin 30, ulled up on board + 6 JTAG_TDO SWO/EXta/TRACECTL SAM3X pin 30, Pulled up on board 7 N/C Key 8 JTAG_TDI NC/EXTb/TDI SAM3X pin 29, Pulled up on board 9 GND GNDDetect - 10 MASTER-RESET nReset + 10 MRST nReset - NOTE: The 10-pin JTAG connector is not populated on the Flip&Click SAM3X. + NOTE: The 10-pin JTAG connector is not populated on the Flip&Click + SAM3X. This is the part number for the SMD connector recommended by + ARM.com: Samtec FTSH-105-01-L-DV-K. For example: + + https://www.digikey.com/product-detail/en/samtec-inc/FTSH-105-01-L-DV-K/SAM8799-ND/1875039 You should be able to use a 10- to 20-pin adapter to connect a SAM-ICE - debugger to the Flip&Click SAM3X. I have this Olimex adapter: - https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10/ . But so far I - have been unable to get the get the SAM-ICE to communicate with the - Flip&Click. + or J-Link debugger to the Flip&Click SAM3X. I have this Olimex adapter: + https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10/ . I have been + loading code and debugging with no problems using JTAG. + + You can find photos my setup here: http://www.nuttx.org/doku.php?id=wiki:howtos:flipnclick-sam3x Flip&Click SAM3X-specific Configuration Options =============================================== @@ -426,7 +541,7 @@ Flip&Click SAM3X-specific Configuration Options CONFIG_SAM34_GPIOF_IRQ Configurations -^^^^^^^^^^^^^^ +============== Each Flip&Click SAM3X configuration is maintained in a sub-directory and can be selected as follow: @@ -461,15 +576,16 @@ Configurations reconfiguration process. 2. Unless stated otherwise, all configurations generate console - output on UART0 which is available both on the USB virtual COM port - and on the PWML connector (see the section "Serial Consoles" above). + output on USART0 which is available either on the Arduion Shield + connector or on mikroBUS A as described above in the section entitled + "Serial Consoles". 3. Unless otherwise stated, the configurations are setup for Cygwin under Windows: Build Setup: CONFIG_HOST_WINDOWS=y : Microsoft Windows - CONFIG_WINDIWS_CYGWIN=y : Cygwin under Windoes + CONFIG_WINDIWS_CYGWIN=y : Cygwin under Windows 3. All of these configurations are set up to build under Windows using the "GNU Tools for ARM Embedded Processors" that is maintained by ARM @@ -498,3 +614,23 @@ Configuration sub-directories Application Configuration: CONFIG_NSH_BUILTIN_APPS=y : Enable starting apps from NSH command line + + nxlines + + This is an NSH configuration that supports the NX graphics example at + apps/examples/nxlines as a built-in application. + + NOTES: + + 1. This configuration derives from the nsh configuration. All of the + notes there apply here as well. + + 2. The default configuration assumes there is the custom HiletGo OLED + in the mikroBUS B slot (and a Mikroe RS-232 Click card in the + mikroBUS A slot). That is easily changed by reconfiguring, however. + See the section entitled "HiletGo OLED" for information about this + custom click card. + + STATUS: + 2018-02-11: No complaints from the software, but nothing appears on the + OLED. There is, most likely, an error in my custom HiletGo Click. Damn! diff --git a/configs/flipnclick-sam3x/include/board.h b/configs/flipnclick-sam3x/include/board.h index 0e2b42fe5d046c6cd3063da5d8a316bf736282af..2c648e7bcd366d8a46f04eb980b6268debc54ec7 100644 --- a/configs/flipnclick-sam3x/include/board.h +++ b/configs/flipnclick-sam3x/include/board.h @@ -79,7 +79,7 @@ /* PLLA configuration. * * Divider = 1 - * Multipler = 14 + * Multiplier = 14 */ #define BOARD_CKGR_PLLAR_MUL (13 << PMC_CKGR_PLLAR_MUL_SHIFT) @@ -211,7 +211,7 @@ #define LED_PANIC 4 /* The system has crashed 2Hz N/C N/C N/C N/C */ #undef LED_IDLE /* MCU is is sleep mode ---- Not used ----- */ -/* Thus if LED L is glowing on and all other LEDs are off (except LED D which +/* Thus if LED L is faintly glowing and all other LEDs are off (except LED D which * was left on but is no longer controlled by NuttX and so may be in any state), * NuttX has successfully booted and is, apparently, running normally and taking * interrupts. If any of LEDs A-D are statically set, then NuttX failed to boot @@ -255,4 +255,73 @@ * There are no alternatives for these pins. */ +/* SPI: + * + * SPI0 is available on the Arduino compatible SPI connector (but no SPI is + * available on pins D10-D13 of the main Arduino Shield connectors where + * you might expect then). The SPI connector is configured as follows: + * + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * --- ------------ ----- --- ------------ ----- + * 1 SPI0_MISO PA25 2 VCC-5V N/A + * 3 SPI0_SCK PA27 4 SPI0_MOSI PA26 + * 5 MRST NRSTB 6 GND N/A + * + * SPI0 is also available on each of the mikroBUS Click connectors (in + * addition to 5V and GND). The connectivity differs only in the chip + * select pin: + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ----- + * CS SPI0_CS0 PA28 CS PA29 PA29 + * SCK SPI0_SCK PA27 SCK SPI0_SCK PA27 + * MISO SPI0_MISO PA25 MISO SPI0_MISO PA25 + * MOSI SPI0_MOSI PA26 MOSI SPI0_MOSI PA26 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ----- + * CS SPI0_CS2 PB21 CS SPI0_CS3 PB23 + * SCK SPI0_SCK PA27 SCK SPI0_SCK PA27 + * MISO SPI0_MISO PA25 MISO SPI0_MISO PA25 + * MOSI SPI0_MOSI PA26 MOSI SPI0_MOSI PA26 + * + * Chip select pin definitions are provided in + * configs/flipnclick-sam3x/src/flipnclick-3x.h. + * + * There are no alternative pin selections for SPI0_MISO and SPIO_MOSI. + */ + +#define GPIO_SPI0_SPCK GPIO_SPI0_SPCK_1 + +/* I2C (aka TWI): + * + * I2C0 is available on pins D16-D17 of the Arduino Shield connectors where + * you would expect then. The SPI connector is configured as follows: + * + * Pin Label J1 Board Signal SAM3X + * --- ----- -- ------------ ----- + * D16 SCL1 8 I2C0_SCL PA17 + * D17 SDA1 7 I2C0_SDA PA18 + * + * I2C0 and I2C1 are also available on the mikroBUS Click connectors (in + * addition to 5V and GND). The connectors A and B share I2C0 with the + * Arduino shield connector. Connectors C and D both connect to I2C1: + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ------- + * SCL I2C0_SCL PA18 SCL I2C0_SCL PA18 + * SDA I2C0_SDA PA17 SDA I2C0_SDA PA17 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ------- + * SCL I2C1_SCL PB13 SCL I2C1_SCL PB13 + * SDA I2C1_SDA PB12 SDA I2C1_SDA PB12 + * + * There are no alternative pin selections for TWI0 and TWI1. + */ + #endif /* __CONFIGS_FLIPNCLICK_SAM3X_INCLUDE_BOARD_H */ diff --git a/configs/flipnclick-sam3x/nsh/defconfig b/configs/flipnclick-sam3x/nsh/defconfig index 79057461ad69e6838a1c971524cd704d86776fa6..545918a2cf359d9a1be79d020127930f43319310 100644 --- a/configs/flipnclick-sam3x/nsh/defconfig +++ b/configs/flipnclick-sam3x/nsh/defconfig @@ -1,4 +1,5 @@ # CONFIG_ARCH_RAMFUNCS is not set +# CONFIG_SAM34_UART0 is not set CONFIG_ARCH_BOARD_FLIPNCLICK_SAM3X=y CONFIG_ARCH_BOARD="flipnclick-sam3x" CONFIG_ARCH_CHIP_ATSAM3X8E=y @@ -8,9 +9,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_BOARD_LOOPSPERMSEC=6965 CONFIG_BUILTIN=y -CONFIG_DISABLE_ENVIRON=y -CONFIG_DISABLE_MOUNTPOINT=y -CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y CONFIG_FS_PROCFS=y @@ -22,6 +20,7 @@ CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=3 CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_DISABLE_IFUPDOWN=y CONFIG_NSH_FILEIOSIZE=512 @@ -33,12 +32,13 @@ CONFIG_RAM_SIZE=65536 CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 +CONFIG_SAM34_USART0=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_START_DAY=28 CONFIG_START_MONTH=6 CONFIG_START_YEAR=2013 -CONFIG_TASK_NAME_SIZE=0 -CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_TASK_NAME_SIZE=31 +CONFIG_USART0_SERIAL_CONSOLE=y CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/flipnclick-sam3x/nxlines/defconfig b/configs/flipnclick-sam3x/nxlines/defconfig new file mode 100644 index 0000000000000000000000000000000000000000..84685e922c87ca8c6d2c385513370ddeffaa4387 --- /dev/null +++ b/configs/flipnclick-sam3x/nxlines/defconfig @@ -0,0 +1,58 @@ +# CONFIG_ARCH_RAMFUNCS is not set +# CONFIG_NX_DISABLE_1BPP is not set +# CONFIG_SAM34_UART0 is not set +CONFIG_ARCH_BOARD_FLIPNCLICK_SAM3X=y +CONFIG_ARCH_BOARD="flipnclick-sam3x" +CONFIG_ARCH_CHIP_ATSAM3X8E=y +CONFIG_ARCH_CHIP_SAM34=y +CONFIG_ARCH_CHIP_SAM3X=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH="arm" +CONFIG_BOARD_LOOPSPERMSEC=6965 +CONFIG_BUILTIN=y +CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y +CONFIG_EXAMPLES_NSH=y +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4 +CONFIG_EXAMPLES_NXLINES_BPP=1 +CONFIG_EXAMPLES_NXLINES_LINEWIDTH=4 +CONFIG_EXAMPLES_NXLINES=y +CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBB=y +CONFIG_FLIPNCLICK_SAM3X_SSD1306=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_HOST_WINDOWS=y +CONFIG_LCD_HILETGO=y +CONFIG_LCD_MAXCONTRAST=255 +CONFIG_LCD=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=3 +CONFIG_MQ_MAXMSGSIZE=64 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_NX_BLOCKING=y +CONFIG_NX=y +CONFIG_NXFONT_TOM_THUMB_4X6=y +CONFIG_NXTK_BORDERWIDTH=2 +CONFIG_PREALLOC_MQ_MSGS=8 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_RAM_SIZE=65536 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SAM34_SPI0=y +CONFIG_SAM34_USART0=y +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=2 +CONFIG_USART0_SERIAL_CONSOLE=y +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/flipnclick-sam3x/src/Makefile b/configs/flipnclick-sam3x/src/Makefile index b2e781f6a9d42a7b130eadef06ee72fe9aab266e..542654f163eade9750fd81b595634d6283821fbc 100644 --- a/configs/flipnclick-sam3x/src/Makefile +++ b/configs/flipnclick-sam3x/src/Makefile @@ -48,4 +48,12 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += sam_appinit.c endif +ifeq ($(CONFIG_SAM34_SPI0),y) +CSRCS += sam_spi0.c +endif + +ifeq ($(CONFIG_FLIPNCLICK_SAM3X_SSD1306),y) +CSRCS += sam_ssd1306.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/flipnclick-sam3x/src/flipnclick-sam3x.h b/configs/flipnclick-sam3x/src/flipnclick-sam3x.h index e35dacbe6d1e3ceb03915d009ecef366e2c706b3..0bde2f81e52ac0c924262049e0eec54d482bea7b 100644 --- a/configs/flipnclick-sam3x/src/flipnclick-sam3x.h +++ b/configs/flipnclick-sam3x/src/flipnclick-sam3x.h @@ -33,8 +33,8 @@ * ************************************************************************************/ -#ifndef __CONFIGS_FLIPNCLICK_SAM3X_SRC_ARDUNO_DUE_H -#define __CONFIGS_FLIPNCLICK_SAM3X_SRC_ARDUNO_DUE_H +#ifndef __CONFIGS_FLIPNCLICK_SAM3X_SRC_FLIPNCLICK_SAM3X_H +#define __CONFIGS_FLIPNCLICK_SAM3X_SRC_FLIPNCLICK_SAM3X_H /************************************************************************************ * Included Files @@ -53,6 +53,24 @@ /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ +/* Configuration ************************************************************/ + +#define HAVE_SSD1306 1 + +/* The SSD1306 LCD must be selected, installed on the Flip&Click, and must + * be configured to use the SPI interface. + */ + +#if !defined(CONFIG_FLIPNCLICK_SAM3X_SSD1306) || \ + !defined(CONFIG_LCD_SSD1306_SPI) +# undef HAVE_SSD1306 +# undef CONFIG_FLIPNCLICK_SAM3X_SSD1306 +# undef CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBA +# undef CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBB +# undef CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBC +# undef CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBD +#endif + /* There are four LEDs on the top, blue side of the board. Only one can be * controlled by software: * @@ -68,17 +86,150 @@ * A high output value illuminates the LEDs. */ -#define GPIO_LED_L (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \ +#define GPIO_LED_L (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOB | GPIO_PIN27) -#define GPIO_LED_A (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \ +#define GPIO_LED_A (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOC | GPIO_PIN6) -#define GPIO_LED_B (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \ +#define GPIO_LED_B (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOC | GPIO_PIN5) -#define GPIO_LED_C (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \ +#define GPIO_LED_C (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOC | GPIO_PIN7) -#define GPIO_LED_D (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \ +#define GPIO_LED_D (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOC | GPIO_PIN8) +/* SPI chip select pins. + * + * SPI0 is available on the Arduino compatible SPI connector (but no SPI is + * available on pins D10-D13 of the main Arduino Shield connectors where + * you might expect then). The SPI connector is configured as follows: + * + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * --- ------------ ----- --- ------------ ----- + * 1 SPI0_MISO PA25 2 VCC-5V N/A + * 3 SPI0_SCK PA27 4 SPI0_MOSI PA26 + * 5 MRST NRSTB 6 GND N/A + * + * SPI0 is also available on each of the mikroBUS Click connectors (in + * addition to 5V and GND). The connectivity differs only in the chip + * select pin: + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ----- + * CS SPI0_CS0 PA28 CS PA29 PA29 + * SCK SPI0_SCK PA27 SCK SPI0_SCK PA27 + * MISO SPI0_MISO PA25 MISO SPI0_MISO PA25 + * MOSI SPI0_MOSI PA26 MOSI SPI0_MOSI PA26 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ----- + * CS SPI0_CS2 PB21 CS SPI0_CS3 PB23 + * SCK SPI0_SCK PA27 SCK SPI0_SCK PA27 + * MISO SPI0_MISO PA25 MISO SPI0_MISO PA25 + * MOSI SPI0_MOSI PA26 MOSI SPI0_MOSI PA26 + */ + +#define GPIO_MBA_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOA | GPIO_PIN28) +#define MBA_CSNUM 0 + +#define GPIO_MBB_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOA | GPIO_PIN29) +#define MBB_CSNUM 1 + +#define GPIO_MBC_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOB | GPIO_PIN21) +#define MBC_CSNUM 2 + +#define GPIO_MBD_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOB | GPIO_PIN23) +#define MBD_CSNUM 3 + +/* SSD1306 OLED + * + * The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI + * is the default and is what is used here). I have mounted the OLED on a + * proto click board. The OLED is connected as follows: + * + * OLED ALIAS DESCRIPTION PROTO CLICK + * ----- ----------- ------------- ----------------- + * GND Ground GND + * VCC Power Supply 5V (3-5V) + * D0 SCL,CLK,SCK Clock SCK + * D1 SDA,MOSI Data MOSI,SDI + * RES RST,RESET Reset RST (GPIO OUTPUT) + * DC AO Data/Command INT (GPIO OUTPUT) + * CS Chip Select CS (GPIO OUTPUT) + * + * NOTE that this is a write-only display (MOSI only)! + * + * MikroBUS A: MikroBUS B: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ------- + * RST RSTA PC1 RST RSTB PC2 + * DC INTA PD1 DC INTB PD2 + * + * MikroBUS C: MikroBUS D: + * Pin Board Signal SAM3X Pin Board Signal SAM3X + * ---- ------------ ----- ---- ------------ ------- + * RST RSTC PC3 RST RSTD PC4 + * DC INTC PD3 DC INTD PD6 + */ + +#if defined(CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBA) +# ifndef CONFIG_SAM34_SPI0 +# error "The OLED driver requires CONFIG_SAM34_SPI0 in the configuration" +# endif + +# define SSD1306_SPI_BUS 0 +# define SSD1306_CSNUM MBA_CSNUM +# define GPIO_SSD1306_CS GPIO_MBA_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOC | GPIO_PIN1) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN1) + +#elif defined(CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBB) +# ifndef CONFIG_SAM34_SPI0 +# error "The OLED driver requires CONFIG_SAM34_SPI0 in the configuration" +# endif + +# define SSD1306_SPI_BUS 0 +# define SSD1306_CSNUM MBB_CSNUM +# define GPIO_SSD1306_CS GPIO_MBB_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOC | GPIO_PIN2) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN2) + +#elif defined(CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBC) +# ifndef CONFIG_SAM34_SPI0 +# error "The OLED driver requires CONFIG_SAM34_SPI0 in the configuration" +# endif + +# define SSD1306_SPI_BUS 0 +# define SSD1306_CSNUM MBC_CSNUM +# define GPIO_SSD1306_CS GPIO_MBC_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOC | GPIO_PIN3) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN3) + +#elif defined(CONFIG_FLIPNCLICK_SAM3X_SSD1306_MBD) +# ifndef CONFIG_SAM34_SPI0 +# error "The OLED driver requires CONFIG_SAM34_SPI0 in the configuration" +# endif + +# define SSD1306_SPI_BUS 0 +# define SSD1306_CSNUM MBD_CSNUM +# define GPIO_SSD1306_CS GPIO_MBD_CS +# define GPIO_SSD1306_RST (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOC | GPIO_PIN4) +# define GPIO_SSD1306_DC (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN6) +#endif + /************************************************************************************ * Public Types ************************************************************************************/ @@ -109,6 +260,21 @@ int sam_bringup(void); +/**************************************************************************** + * Name: sam_graphics_setup + * + * Description: + * Called by either NX initialization logic (via board_graphics_setup) or + * directly from the board bring-up logic in order to configure the + * SSD1306 OLED. + * + ****************************************************************************/ + +#ifdef HAVE_SSD1306 +struct lcd_dev_s; /* Forward reference */ +FAR struct lcd_dev_s *sam_graphics_setup(unsigned int devno); +#endif + #endif /* __ASSEMBLY__ */ -#endif /* __CONFIGS_FLIPNCLICK_SAM3X_SRC_ARDUNO_DUE_H */ +#endif /* __CONFIGS_FLIPNCLICK_SAM3X_SRC_FLIPNCLICK_SAM3X_H */ diff --git a/configs/flipnclick-sam3x/src/sam_autoleds.c b/configs/flipnclick-sam3x/src/sam_autoleds.c index 3f0b450178d88468c1e0d98d9a68e36cfc1e0b37..ff309be24aa1f115a2d9b0d77ab8ece4919c2b9d 100644 --- a/configs/flipnclick-sam3x/src/sam_autoleds.c +++ b/configs/flipnclick-sam3x/src/sam_autoleds.c @@ -64,8 +64,8 @@ * LED_PANIC The system has crashed 2Hz N/C N/C N/C N/C * LED_IDLE MCU is is sleep mode ---- Not used ----- * - * Thus if LED L is glowing on and all other LEDs are off (except LED D - * which was left on but is no longer controlled by NuttX and so may be in + * Thus if LED L is faintly glowing and all other LEDs are off (except LED + * D which was left on but is no longer controlled by NuttX and so may be in * any state), NuttX has successfully booted and is, apparently, running * normally and taking interrupts. If any of LEDs A-D are statically set, * then NuttX failed to boot and the LED indicates the initialization phase @@ -99,7 +99,7 @@ #ifdef CONFIG_ARCH_LEDS /**************************************************************************** - * Processor Definitinos + * Processor Definitions ****************************************************************************/ /* LED indices */ @@ -123,7 +123,7 @@ static void board_autoled_setone(int ledndx) sam_gpiowrite(GPIO_LED_L, ledon[INDEX_LED_L]); sam_gpiowrite(GPIO_LED_A, ledon[INDEX_LED_A]); sam_gpiowrite(GPIO_LED_B, ledon[INDEX_LED_B]); - sam_gpiowrite(GPIO_LED_C, ledon[INDEX_LED_D]); + sam_gpiowrite(GPIO_LED_C, ledon[INDEX_LED_C]); sam_gpiowrite(GPIO_LED_D, ledon[INDEX_LED_D]); } @@ -176,7 +176,7 @@ void board_autoled_on(int led) board_autoled_setone(INDEX_LED_B); break; - case 2: + case 2: board_autoled_setone(INDEX_LED_C); break; diff --git a/configs/flipnclick-sam3x/src/sam_bringup.c b/configs/flipnclick-sam3x/src/sam_bringup.c index 28a9d427357e4fce8bca49ed72c1b95a54a6b6a9..3d1d229bb13104f516a4778bf762dc6438547b55 100644 --- a/configs/flipnclick-sam3x/src/sam_bringup.c +++ b/configs/flipnclick-sam3x/src/sam_bringup.c @@ -84,6 +84,15 @@ int sam_bringup(void) } #endif +#if defined(HAVE_SSD1306) && !defined(CONFIG_NXSTART_EXTERNINIT) + /* Configure the SSD1306 OLED */ + + if (sam_graphics_setup(0) == NULL) + { + syslog(LOG_ERR,"ERROR: Failed to configure the SSD1306 OLED\n"); + } +#endif + UNUSED(ret); return OK; } diff --git a/configs/flipnclick-sam3x/src/sam_spi0.c b/configs/flipnclick-sam3x/src/sam_spi0.c new file mode 100644 index 0000000000000000000000000000000000000000..40c6bc2fd0a011e2c62814fbef9f7a4279c40813 --- /dev/null +++ b/configs/flipnclick-sam3x/src/sam_spi0.c @@ -0,0 +1,220 @@ +/************************************************************************************ + * configs/flipnclick-sam3x/src/sam_spi0.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "up_arch.h" +#include "chip.h" +#include "sam_gpio.h" +#include "sam_spi.h" + +#include "flipnclick-sam3x.h" + +#ifdef CONFIG_SAM34_SPI0 + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: sam_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the SAM4E-EK board. + * + ************************************************************************************/ + +void weak_function sam_spidev_initialize(void) +{ +#ifdef HAVE_SSD1306 + /* Configure the SSD1306 chip select and command/data GPIOs */ + + sam_configgpio(GPIO_SSD1306_CS); + sam_configgpio(GPIO_SSD1306_DC); +#endif +} + +/**************************************************************************** + * Name: sam_spi0select, sam_spi0status, and sam_spic0mddata + * + * Description: + * These external functions must be provided by board-specific logic. They + * include: + * + * o sam_spi0select is a functions tomanage the board-specific chip selects + * o sam_spi0status and sam_spic0mddata: Implementations of the status + * and cmddata methods of the SPI interface defined by struct spi_ops_ + * (see include/nuttx/spi/spi.h). All other methods including + * sam_spibus_initialize()) are provided by common SAM3/4 logic. + * + * To use this common SPI logic on your board: + * + * 1. Provide logic in sam_boardinitialize() to configure SPI chip select + * pins. + * 2. Provide sam_spi0select() and sam_spi0status() functions in your board- + * specific logic. These functions will perform chip selection and + * status operations using GPIOs in the way your board is configured. + * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide + * sam_spic0mddata() functions in your board-specific logic. This + * function will perform cmd/data selection operations using GPIOs in + * the way your board is configured. + * 3. Add a call to sam_spibus_initialize() in your low level application + * initialization logic + * 4. The handle returned by sam_spibus_initialize() may then be used to bind the + * SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_spi0select + * + * Description: + * PIO chip select pins may be programmed by the board specific logic in + * one of two different ways. First, the pins may be programmed as SPI + * peripherals. In that case, the pins are completely controlled by the + * SPI driver. This method still needs to be provided, but it may be only + * a stub. + * + * An alternative way to program the PIO chip select pins is as a normal + * GPIO output. In that case, the automatic control of the CS pins is + * bypassed and this function must provide control of the chip select. + * NOTE: In this case, the GPIO output pin does *not* have to be the + * same as the NPCS pin normal associated with the chip select number. + * + * Input Parameters: + * devid - Identifies the (logical) device + * selected - TRUE:Select the device, FALSE:De-select the device + * + * Returned Value: + * None + * + ****************************************************************************/ + +void sam_spi0select(uint32_t devid, bool selected) +{ + spiinfo("devid: %08x CS: %s\n", + (unsigned int)devid, selected ? "assert" : "de-assert"); + +#ifdef HAVE_SSD1306 + if (devid == SPIDEV_DISPLAY(0)) + { + /* Low: the display is selected + * High: the display is deselected + */ + + sam_gpiowrite(GPIO_SSD1306_CS, !selected); + } +#endif +} + +/**************************************************************************** + * Name: sam_spi0status + * + * Description: + * Return status information associated with the SPI device. + * + * Input Parameters: + * devid - Identifies the (logical) device + * + * Returned Value: + * Bit-encoded SPI status (see include/nuttx/spi/spi.h. + * + ****************************************************************************/ + +uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + spiinfo("Returning nothing\n"); + return 0; +} +/**************************************************************************** + * Name: sam_spi0cmddata + * + * Description: + * Some SPI devices require an additional control to determine if the SPI + * data being sent is a command or is data. If CONFIG_SPI_CMDDATA then + * this function will be called to different be command and data transfers. + * + * This is often needed, for example, by LCD drivers. Some LCD hardware + * may be configured to use 9-bit data transfers with the 9th bit + * indicating command or data. That same hardware may be configurable, + * instead, to use 8-bit data but to require an additional, board- + * specific PIO control to distinguish command and data. This function + * would be needed in that latter case. + * + * Input Parameters: + * dev - SPI device info + * devid - Identifies the (logical) device + * + * Returned Value: + * Zero on success; a negated errno on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_SPI_CMDDATA +int sam_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + spiinfo("devid: %08x %s\n", (unsigned int)devid, cmd ? "cmd" : "data"); + +#ifdef HAVE_SSD1306 + if (devid == SPIDEV_DISPLAY(0)) + { + /* High: the inputs are treated as display data. + * Low: the inputs are transferred to the command registers. + */ + + sam_gpiowrite(GPIO_SSD1306_DC, !cmd); + } +#endif + + return 0; + +} +#endif + +#endif /* CONFIG_SAM34_SPI0 */ diff --git a/configs/flipnclick-sam3x/src/sam_ssd1306.c b/configs/flipnclick-sam3x/src/sam_ssd1306.c new file mode 100644 index 0000000000000000000000000000000000000000..f6cfa857e2aefcc226cd84ce109c0d8a0e2dcf42 --- /dev/null +++ b/configs/flipnclick-sam3x/src/sam_ssd1306.c @@ -0,0 +1,172 @@ +/**************************************************************************** + * config/flipnclick-sam3x/src/sam_ssd1306.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* SSD1306 OLED + * + * The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI + * is the default and is what is used here). I have mounted the OLED on a + * proto click board. The OLED is connected as follows: + * + * OLED ALIAS DESCRIPTION PROTO CLICK + * ----- ----------- ------------- ----------------- + * GND Ground GND + * VCC Power Supply 5V (3-5V) + * D0 SCL,CLK,SCK Clock SCK + * D1 SDA,MOSI Data MOSI,SDI + * RES RST,RESET Reset RST (GPIO OUTPUT) + * DC AO Data/Command INT (GPIO OUTPUT) + * CS Chip Select CS (GPIO OUTPUT) + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include + +#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER) +# include +#endif + +#include "sam_gpio.h" +#include "sam_spi.h" + +#include "flipnclick-sam3x.h" + +#ifdef HAVE_SSD1306 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifndef CONFIG_SPI_CMDDATA +# error "The OLED driver requires CONFIG_SPI_CMDDATA in the configuration" +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_graphics_setup + * + * Description: + * Called by either NX initialization logic (via board_graphics_setup) or + * directly from the board bring-up logic in order to configure the + * SSD1306 OLED. + * + ****************************************************************************/ + +FAR struct lcd_dev_s *sam_graphics_setup(unsigned int devno) +{ + FAR struct spi_dev_s *spi; + FAR struct lcd_dev_s *dev; + + /* Configure the OLED GPIOs. This initial configuration is RESET low, + * putting the OLED into reset state. + */ + + sam_configgpio(GPIO_SSD1306_RST); + + /* Wait a bit then release the OLED from the reset state */ + + up_mdelay(20); + sam_gpiowrite(GPIO_SSD1306_RST, true); + + /* Get the SPI1 port interface */ + + spi = sam_spibus_initialize(GPIO_SSD1306_CS); + if (!spi) + { + lcderr("ERROR: Failed to initialize SPI port 1\n"); + } + else + { + /* Bind the SPI port to the OLED */ + + dev = ssd1306_initialize(spi, NULL, devno); + if (!dev) + { + lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); + } + else + { + lcdinfo("Bound SPI port 1 to OLED %d\n", devno); + + /* And turn the OLED on */ + + (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); + +#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER) + /* Initialize and register the simulated framebuffer driver */ + + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); + } +#endif + + return dev; + } + } + + return NULL; +} + +/**************************************************************************** + * Name: board_graphics_setup + * + * Description: + * Called by NX initialization logic to configure the OLED. + * + ****************************************************************************/ + +#ifdef CONFIG_NXSTART_EXTERNINIT +FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno) +{ + return sam_graphics_setup(devno); +} +#endif + +#endif /* HAVE_SSD1306 */ diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 5559b2fe5f1363fc99c9ae7fba92f4575446f1fc..a2ce126b7de7b6746e4d25213f7aa77a10ea27a4 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -618,7 +618,7 @@ GNU Toolchain Options ===================== The NuttX make system supports several GNU-based toolchains under Linux, - Cygwin under Windows, and Windoes native. To select a toolchain: + Cygwin under Windows, and Windows native. To select a toolchain: 1. Use 'make menuconfig' and select the toolchain that you are using under the System Type menu. diff --git a/configs/freedom-k66f/README.txt b/configs/freedom-k66f/README.txt index 7f5da7cffaa2a67a14457a2e98600406c73e9e3c..c78a3c4c807884bda0648d58c0f5d9aaa516b758 100644 --- a/configs/freedom-k66f/README.txt +++ b/configs/freedom-k66f/README.txt @@ -621,7 +621,7 @@ GNU Toolchain Options ===================== The NuttX make system supports several GNU-based toolchains under Linux, - Cygwin under Windows, and Windoes native. To select a toolchain: + Cygwin under Windows, and Windows native. To select a toolchain: 1. Use 'make menuconfig' and select the toolchain that you are using under the System Type menu. @@ -972,4 +972,5 @@ Status 2017-02-14: nsh: SDHC DMA is not working yet. Buttons and SDIO with automounter is working. netnsh:Is building but Ehternet is not working yet. TX is called but - not IRQ is issued. \ No newline at end of file + not IRQ is issued. + diff --git a/configs/freedom-kl25z/src/kl_cc3000.c b/configs/freedom-kl25z/src/kl_cc3000.c index e233a64d062f16223ba31159b02be995d4abe089..c446ff870b6956fb33b51f63755917daedc225f3 100644 --- a/configs/freedom-kl25z/src/kl_cc3000.c +++ b/configs/freedom-kl25z/src/kl_cc3000.c @@ -334,7 +334,7 @@ int wireless_archinitialize(size_t max_rx_size) * Warning: This function must be called before ANY other wlan driver * function * - * Input Parmeters: + * Input Parameters: * sWlanCB Asynchronous events callback. * 0 no event call back. * - Call back parameters: diff --git a/configs/freedom-kl25z/src/kl_spi.c b/configs/freedom-kl25z/src/kl_spi.c index e952963d1be54d780787f9685ad40c56e85b2bcf..566af53909b282b95b4fbfb46bb0a76754218d77 100644 --- a/configs/freedom-kl25z/src/kl_spi.c +++ b/configs/freedom-kl25z/src/kl_spi.c @@ -133,7 +133,7 @@ void weak_function kl_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -182,7 +182,7 @@ void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -213,7 +213,7 @@ uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) * devid - Identifies the (logical) device * cmd - Determines where command or data should be selected. * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/freedom-kl26z/src/kl_spi.c b/configs/freedom-kl26z/src/kl_spi.c index 4c94db9fa3098019654161242ccfbb95872b5738..01cb52fc912efa632680851155e5d320226d368d 100644 --- a/configs/freedom-kl26z/src/kl_spi.c +++ b/configs/freedom-kl26z/src/kl_spi.c @@ -124,7 +124,7 @@ void weak_function kl_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -156,7 +156,7 @@ void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -187,7 +187,7 @@ uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) * devid - Identifies the (logical) device * cmd - Determines where command or data should be selected. * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/hymini-stm32v/src/hymini-stm32v.h b/configs/hymini-stm32v/src/hymini-stm32v.h index f821d03465d779b6a762098b1893a3abba7b21cc..cdfd96704a27c0d15ce3c699577169aa23bb71fb 100644 --- a/configs/hymini-stm32v/src/hymini-stm32v.h +++ b/configs/hymini-stm32v/src/hymini-stm32v.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/hymini-stm32v/src/hymini-stm32v.h * - * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Laurent Latil * @@ -122,7 +122,7 @@ * ************************************************************************************/ -extern void weak_function stm32_spidev_initialize(void); +void weak_function stm32_spidev_initialize(void); /************************************************************************************ * Name: stm32_usbinitialize @@ -132,7 +132,28 @@ extern void weak_function stm32_spidev_initialize(void); * ************************************************************************************/ -extern void weak_function stm32_usbinitialize(void); +void weak_function stm32_usbinitialize(void); + +/************************************************************************************ + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef CONFIG_INPUT +int stm32_tsc_setup(int minor); +#endif #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_HYMINI_STM32V_H */ diff --git a/configs/hymini-stm32v/src/stm32_appinit.c b/configs/hymini-stm32v/src/stm32_appinit.c index 5b99c4445b668c38fc53f9278a3291c29c451caf..85be09ecb7dae51fdbdfba2add1bb201ec852dae 100644 --- a/configs/hymini-stm32v/src/stm32_appinit.c +++ b/configs/hymini-stm32v/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/hymini-stm32v/src/stm32_appinit.c * - * Copyright (C) 2009, 2011, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -170,10 +170,11 @@ static int nsh_cdinterrupt(int irq, FAR void *context, FAR void *arg) int board_app_initialize(uintptr_t arg) { -#ifdef NSH_HAVEMMCSD int ret; +#ifdef NSH_HAVEMMCSD /* Card detect */ + bool cd_status; /* Configure the card detect GPIO */ @@ -220,5 +221,17 @@ int board_app_initialize(uintptr_t arg) sdio_mediachange(g_sdiodev, cd_status); #endif + +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + + UNUSED(ret); return OK; } diff --git a/configs/hymini-stm32v/src/stm32_ts.c b/configs/hymini-stm32v/src/stm32_ts.c index 781eafc9f15313bc43eb47b8dc8be52fcf8b77ee..59f7caa0509a7f4374e8149bcef8bcbee31a0b3d 100644 --- a/configs/hymini-stm32v/src/stm32_ts.c +++ b/configs/hymini-stm32v/src/stm32_ts.c @@ -53,7 +53,7 @@ #include "hymini-stm32v.h" /************************************************************************************ - * Pre-processor Defintiions + * Pre-processor Definitions ************************************************************************************/ #if !defined(CONFIG_STM32_SPI1) @@ -136,13 +136,12 @@ static bool hymini_ts_pendown(FAR struct ads7843e_config_s *state) } /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -153,7 +152,7 @@ static bool hymini_ts_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct spi_dev_s *dev; @@ -172,24 +171,3 @@ int board_tsc_setup(int minor) return ads7843e_register(dev, &ts_cfg, minor); } - -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* FIXME What can/should we do here ? */ -} diff --git a/configs/indium-f7/src/stm32_usb.c b/configs/indium-f7/src/stm32_usb.c index 794975f51c33b465e69fa236562bfd42a1a331cd..9089232cec761d2d6510c4e2574e5ceb689b716c 100644 --- a/configs/indium-f7/src/stm32_usb.c +++ b/configs/indium-f7/src/stm32_usb.c @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -240,9 +241,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, - CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -294,11 +295,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/lc823450-xgevk/README.txt b/configs/lc823450-xgevk/README.txt index 63db6a0a3088f93213d7da54f0d04b05745a5265..a152c893e1f74c6a84a2f3e719185f4d46d150d6 100644 --- a/configs/lc823450-xgevk/README.txt +++ b/configs/lc823450-xgevk/README.txt @@ -45,13 +45,33 @@ to set MSP (main stack pointer) as follows. SMP related Status ^^^^^^^^^^^^^^^^^^ -Currently all applications except for ostest work in SMP mode but might stop -due to deadlocks or ASSERT(). - CPU activities are shown at D9 (CPU0) and D10 (CPU1) respectively. -1. "nsh> smp" works but the result will be corrupted. -2. "nsh> ostest" works but might cause a deadlock or assertion. +Currently all applications except for ostest work in SMP mode but might stop +due to deadlocks or ASSERT(). For a workaround, please try + +$ cd apps; git diff +diff --git a/examples/ostest/waitpid.c b/examples/ostest/waitpid.c +index 687f50ca..8418eff8 100644 +--- a/examples/ostest/waitpid.c ++++ b/examples/ostest/waitpid.c +@@ -54,7 +54,7 @@ + ****************************************************************************/ + + #define RETURN_STATUS 14 +-#define NCHILDREN 3 ++#define NCHILDREN 2 + #define PRIORITY 100 + + /**************************************************************************** + +If other deadlocks or ASSERT() still happen, please try the following. + +$ cd nuttx; git revert e238c8b0904988b966c3b33e7df2ba3faba52e2b + +This will revert the changes for clock_systimer() for 64bit so that it can +use spinlock to protect the internal data. We think that there still exist +race conditions somewhere in SMP logic but the revert might relax the conditions. Other Status ^^^^^^^^^^^^ diff --git a/configs/lc823450-xgevk/audio/defconfig b/configs/lc823450-xgevk/audio/defconfig index ae8ef0ad3763e87ee2fdb116ec8ff549c8cda39a..e06f30abc50630677f90a55b893f54623373724c 100644 --- a/configs/lc823450-xgevk/audio/defconfig +++ b/configs/lc823450-xgevk/audio/defconfig @@ -127,6 +127,7 @@ CONFIG_START_MONTH=10 CONFIG_START_YEAR=2013 CONFIG_SYSTEM_I2CTOOL=y CONFIG_SYSTEM_NXPLAYER=y +CONFIG_SYSTEM_TIME64=y CONFIG_SYSTEM_USBMSC_CMD_STACKSIZE=2048 CONFIG_SYSTEM_USBMSC_DEVPATH1="/dev/mtdblock0p10" CONFIG_SYSTEM_USBMSC_DEVPATH2="/dev/mtdblock1" diff --git a/configs/lc823450-xgevk/nsh/defconfig b/configs/lc823450-xgevk/nsh/defconfig index 74040a673989e2b1560fd721fe0ace0af5220e23..91b32fbe49b1c52197313dd51952ef8f35ca0de6 100644 --- a/configs/lc823450-xgevk/nsh/defconfig +++ b/configs/lc823450-xgevk/nsh/defconfig @@ -124,6 +124,7 @@ CONFIG_START_DAY=3 CONFIG_START_MONTH=10 CONFIG_START_YEAR=2013 CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_TIME64=y CONFIG_TASK_NAME_SIZE=24 CONFIG_UART0_RXBUFSIZE=512 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/configs/lc823450-xgevk/rndis/defconfig b/configs/lc823450-xgevk/rndis/defconfig index c07e826ca66abe90b886e1d4afc831ab0c683c92..32a899edd9d64cf7d6220426702365fb678c24df 100644 --- a/configs/lc823450-xgevk/rndis/defconfig +++ b/configs/lc823450-xgevk/rndis/defconfig @@ -150,6 +150,9 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_HPWORKPERIOD=50000 CONFIG_SCHED_HPWORKPRIORITY=192 CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_INSTRUMENTATION_BUFFER=y +CONFIG_SCHED_INSTRUMENTATION_PREEMPTION=y +CONFIG_SCHED_INSTRUMENTATION=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_ONEXIT_MAX=32 CONFIG_SCHED_ONEXIT=y @@ -169,6 +172,7 @@ CONFIG_START_YEAR=2013 CONFIG_SYSTEM_I2CTOOL=y CONFIG_SYSTEM_NXPLAYER=y CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_TIME64=y CONFIG_TASK_NAME_SIZE=24 CONFIG_TELNET_CHARACTER_MODE=y CONFIG_UART0_RXBUFSIZE=512 diff --git a/configs/lc823450-xgevk/src/lc823450_bringup.c b/configs/lc823450-xgevk/src/lc823450_bringup.c index 8b41c839fe5f4c84aa4f7ef3c354f6d8b73e1de1..d80e5f0a0206cfcd1be773f133f07bd99fb7b37e 100644 --- a/configs/lc823450-xgevk/src/lc823450_bringup.c +++ b/configs/lc823450-xgevk/src/lc823450_bringup.c @@ -49,6 +49,8 @@ # include #endif +#include + #ifdef CONFIG_RNDIS # include #endif @@ -132,7 +134,7 @@ int lc823450_bringup(void) /* NOTE: pid=4 is assumed to be lpwork */ - sched_setaffinity(4, sizeof(cpu_set_t), &cpuset); + (void)nxsched_setaffinity(4, sizeof(cpu_set_t), &cpuset); #endif /* If we got here then perhaps not all initialization was successful, but diff --git a/configs/lc823450-xgevk/usb/defconfig b/configs/lc823450-xgevk/usb/defconfig index 4b680dbd510be51c813643b17f67c16c44a842f3..3ca1889d1bfd1ae42160c806008c2c4c6df56336 100644 --- a/configs/lc823450-xgevk/usb/defconfig +++ b/configs/lc823450-xgevk/usb/defconfig @@ -126,6 +126,7 @@ CONFIG_START_DAY=3 CONFIG_START_MONTH=10 CONFIG_START_YEAR=2013 CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_TIME64=y CONFIG_SYSTEM_USBMSC_CMD_STACKSIZE=2048 CONFIG_SYSTEM_USBMSC_DEVPATH1="/dev/mtdblock0p10" CONFIG_SYSTEM_USBMSC_DEVPATH2="/dev/mtdblock1" diff --git a/configs/lpcxpresso-lpc54628/README.txt b/configs/lpcxpresso-lpc54628/README.txt index 31a65ff18e3d55f91c789ca21886b39b77317bb9..c9b3cbb52482e2eb5e83e566599099ec69f5e0df 100644 --- a/configs/lpcxpresso-lpc54628/README.txt +++ b/configs/lpcxpresso-lpc54628/README.txt @@ -24,6 +24,12 @@ README device functionality - 10/100Mbps Ethernet (RJ45 connector) +CONTENTS +======== + + - STATUS + - Configurations + STATUS ====== @@ -86,20 +92,15 @@ STATUS of this writing. Also added the netnsh configuration will, eventually, be used to test the Ethernet driver. 2018-01-01: There Ethernet driver appears to be fully functional although - more testing is certainly needed. I believe that there is a memory - corruption issue in the current configuration that cause problems - occasionally. For example, after a longer Telnet session, I sometimes - see the following DEBUGASSERT after exiting the session from the host: - - up_assert: Assertion failed at file:mm_heap/mm_free.c line: 129 - - which is a clear indication heap corruption. Increasing the size of some - stacks might correct this problem, but I have not yet experimented with - that. I have not seen the problem in any other context. + more testing is certainly needed. + 2018-01-14: The basic SPI driver is code complete but still untested. It + is "basic" in the sense that it supports only polled mode (no DMA). + 2018-01-18: Added the lvgl configuration. See notes under "Configuration + Sub-directories" for additional status. - There is still no support for the Accelerometer, SPIFI, or USB. There is a - complete but not-yet-functional SD card. There is a partial SPI driver, - but no on-board SPI devices to test it. + There is still no support for the Accelerometer, SPIFI, or USB. There is + a complete but not-yet-functional SD card driver and and tested SPI + driver. There are no on-board devices to support SPI testing. Configurations ============== @@ -157,7 +158,7 @@ Configurations System Type -> Toolchain: CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain - Configuration sub-directories + Configuration Sub-directories ----------------------------- fb: @@ -230,6 +231,39 @@ Configurations interrupts are not supported on P4. So polled mode only for this puppy. + lvgl + ---- + This is a demonstration of the LittlevGL graphics library running on + the NuttX frame buffer driver (as in the fb configuration). You can + find LittlevGL here: + + https://littlevgl.com/ + https://github.com/littlevgl + + This configuration uses the LittlevGL demonstration at apps/examples/lvgldemo. + + NOTES: + + 1. The LittlevGL demonstration is quit large, due mostly to some large + graphic images. So memory is tight in the LPC54628's 512Kb FLASH. In + fact, if you disable optimization, the demo will not fit into FLASH + memory (at least not with debug output also enabled). + + A longer term solution might load the large images into the abundant + SDRAM at runtime instead of linking it statically in FLASH. + + STATUS: + + 2018-01-18: The demo is basically function but has some issues: + + a) The font is too big on the "Write" screen. They don't fit in on + the keyboard. + b) The "List" display is filled with a big box that says "Click a + button to copy its text to Text area." There are no buttons and + nothing to click on (maybe they are behind the big box?). This + may also be a font size issue. + c) The "Chart" display looks okay. + netnsh: ------ This is a special version of the NuttShell (nsh) configuration that is @@ -265,7 +299,6 @@ Configurations $ telnet fc00::42 - nsh: Configures the NuttShell (nsh) application located at examples/nsh. @@ -477,4 +510,3 @@ Configurations $ cd ~//nuttx $ make - diff --git a/configs/lpcxpresso-lpc54628/fb/defconfig b/configs/lpcxpresso-lpc54628/fb/defconfig index 2234418cfcc7429fd86517b85c2e825919e4ef97..afc8562724e24b91323164c3ae7793afbb4a6524 100644 --- a/configs/lpcxpresso-lpc54628/fb/defconfig +++ b/configs/lpcxpresso-lpc54628/fb/defconfig @@ -1,5 +1,4 @@ # CONFIG_ARCH_FPU is not set -# CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT is not set CONFIG_ARCH_BOARD_LPCXPRESSO_LPC54628=y CONFIG_ARCH_BOARD="lpcxpresso-lpc54628" CONFIG_ARCH_CHIP_LPC54628=y @@ -64,7 +63,7 @@ CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_PREALLOC_TIMERS=4 CONFIG_PREALLOC_WDOGS=4 CONFIG_RAM_SIZE=163840 -CONFIG_RAM_START=0x10000000 +CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y diff --git a/configs/lpcxpresso-lpc54628/include/board.h b/configs/lpcxpresso-lpc54628/include/board.h index 2ca923462a6649c9f3d67c2287a2bd7dca98a54f..802d35575c02a7cac336753798a46905e7a8a0c7 100644 --- a/configs/lpcxpresso-lpc54628/include/board.h +++ b/configs/lpcxpresso-lpc54628/include/board.h @@ -306,7 +306,7 @@ /* Pin Disambiguation *******************************************************/ /* Flexcomm0/USART0 * - * USART0 connects to the serial bridge on LPC4322JET100 and is typlical used + * USART0 connects to the serial bridge on LPC4322JET100 and is typically used * for the serial console. * * BRIDGE_UART_RXD -> P0_29-ISP_FC0_RXD -> P0.29 GPIO_FC0_RXD_SDA_MOSI_2 @@ -316,6 +316,18 @@ #define GPIO_USART0_RXD (GPIO_FC0_RXD_SDA_MOSI_2 | GPIO_FILTER_OFF) #define GPIO_USART0_TXD (GPIO_FC0_TXD_SCL_MISO_2 | GPIO_FILTER_OFF) +/* An alternative for the serial console is a Arduino Uno compatible serial + * shield: + * + * Arduino Uno J13 Board Signal + * ----------- ------ ---------------- + * D0 RX Pin 15 P3_26-FC4_RXD + * D1 TX Pin 13 P3_27-FC4_TXD + */ + +#define GPIO_USART4_RXD (GPIO_FC4_RXD_SDA_MOSI_2 | GPIO_FILTER_OFF) +#define GPIO_USART4_TXD (GPIO_FC4_TXD_SCL_MISO_2 | GPIO_FILTER_OFF) + /* Flexcomm2/I2C * * For I2C: @@ -329,8 +341,14 @@ * Type I pins need for high speed I2C need: * GPIO_FILTER_OFF + GPIO_I2C_FILTER_OFF + GPIO_I2CDRIVE_HIGH * - * The touchscreen controller is on I2C2: SCL P3.24, SDA P3.23. These are - * both Type D/I pins. + * There are several on-board devices using I2C2: + * + * Codec I2C address: 0x1a + * Accel I2C address: 0x1d + * Touch panel I2C address: 0x38 + * + * In addition, these same I2C2 pins are brought out through D14 and D15 of + * the Arduino Uno connector. */ #if defined(CONFIG_LPC54_I2C_FAST) @@ -351,6 +369,35 @@ GPIO_FILTER_OFF | _I2CFILTER | \ _I2CDRIVE) +/* Flexcomm2/SPI + * + * There are no SPI devices on board the LPCXpresso-LPC54628. SPI is + * available on the Arduino Uno compatible connector, however: + * + * Arduino Uno J9 Board Signal Pin Type + * ----------- ------ ---------------- --------- + * D10 SSEL Pin 15 P3_20-FC9_SCK Type D + * D11 MOSI Pin 13 P3_21-FC9_MOSI Type A + * D12 MISO Pin 11 P3_22-FC9_MISO Type A + * D13 SCK Pin 9 P3_30-FC9_SSELn0 Type D + * + * For SPI: + * Type A & D pins need: + * GPIO_PUSHPULL (on outputs) + GPIO_SLEW_STANDARD (Type D) + + * GPIO_FILTER_OFF + * GPIO_SLEW_FAST is optional for high data rates (Type D). + * Type I need: + * GPIO_I2C_FILTER_OFF + GPIO_I2CDRIVE_LOW + GPIO_FILTER_OFF + + * GPIO_I2CSLEW_GPIO + */ + +#define GPIO_FC9_RXD_SDA_MOSI (GPIO_FC9_RXD_SDA_MOSI_1 | \ + GPIO_PUSHPULL | GPIO_FILTER_OFF) +#define GPIO_FC9_TXD_SCL_MISO (GPIO_FC9_TXD_SCL_MISO_1 | \ + GPIO_FILTER_OFF) +#define GPIO_FC9_SCK (GPIO_FC9_SCK_1 | GPIO_PUSHPULL | \ + GPIO_SLEW_STANDARD | GPIO_FILTER_OFF) + /* SD/MMC * * P2_10-SD_CDn @@ -412,7 +459,6 @@ * feature. */ - #define GPIO_ENET_MDIO GPIO_ENET_MDIO_2 /* P4.16 */ #define GPIO_ENET_MDC GPIO_ENET_MDC_2 /* P4.15 */ diff --git a/configs/lpcxpresso-lpc54628/lvgl/defconfig b/configs/lpcxpresso-lpc54628/lvgl/defconfig new file mode 100644 index 0000000000000000000000000000000000000000..69faf20696f8095665da4850c30ab5acc4760338 --- /dev/null +++ b/configs/lpcxpresso-lpc54628/lvgl/defconfig @@ -0,0 +1,71 @@ +# CONFIG_ARCH_FPU is not set +# CONFIG_LV_FONT_ANTIALIAS is not set +CONFIG_ARCH_BOARD_LPCXPRESSO_LPC54628=y +CONFIG_ARCH_BOARD="lpcxpresso-lpc54628" +CONFIG_ARCH_CHIP_LPC54628=y +CONFIG_ARCH_CHIP_LPC54XX=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_ARCH="arm" +CONFIG_BOARD_LOOPSPERMSEC=21082 +CONFIG_BUILTIN=y +CONFIG_DRIVERS_VIDEO=y +CONFIG_EXAMPLES_LVGLDEMO=y +CONFIG_FS_PROCFS=y +CONFIG_FT5X06_POLLMODE=y +CONFIG_FT5X06_SINGLEPOINT=y +CONFIG_FT5X06_SWAPXY=y +CONFIG_GRAPHICS_LVGL=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_HOST_WINDOWS=y +CONFIG_INPUT_FT5X06=y +CONFIG_INPUT=y +CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y +CONFIG_LPC54_EMC_DYNAMIC_CS0_OFFSET=0x00080000 +CONFIG_LPC54_EMC_DYNAMIC_CS0_SIZE=0x00f80000 +CONFIG_LPC54_EMC_DYNAMIC_CS0=y +CONFIG_LPC54_EMC=y +CONFIG_LPC54_GPIOIRQ=y +CONFIG_LPC54_I2C2_MASTER=y +CONFIG_LPC54_LCD_BGR=y +CONFIG_LPC54_LCD_BPP16_565=y +CONFIG_LPC54_LCD_HBACKPORCH=43 +CONFIG_LPC54_LCD_HFRONTPORCH=8 +CONFIG_LPC54_LCD_VBACKPORCH=12 +CONFIG_LPC54_LCD_VFRONTPORCH=4 +CONFIG_LPC54_LCD_VPULSE=10 +CONFIG_LPC54_LCD_VRAMBASE=0xa0000000 +CONFIG_LPC54_LCD=y +CONFIG_LPC54_USART0=y +CONFIG_LV_HOR_RES=480 +CONFIG_LV_VER_RES=272 +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_RAM_SIZE=163840 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_TASK_NAME_SIZE=32 +CONFIG_USART0_SERIAL_CONSOLE=y +CONFIG_USE_LV_FONT_DEJAVU_40_CYRILLIC=y +CONFIG_USE_LV_FONT_DEJAVU_40_LATIN_EXT_A=y +CONFIG_USE_LV_FONT_DEJAVU_40_LATIN_EXT_B=y +CONFIG_USE_LV_FONT_DEJAVU_40_SUP=y +CONFIG_USE_LV_FONT_SYMBOL_40_BASIC=y +CONFIG_USE_LV_FONT_SYMBOL_40_FEEDBACK=y +CONFIG_USE_LV_FONT_SYMBOL_40_FILE=y +CONFIG_USER_ENTRYPOINT="lvgldemo_main" +CONFIG_VIDEO_FB=y +CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/lpcxpresso-lpc54628/netnsh/defconfig b/configs/lpcxpresso-lpc54628/netnsh/defconfig index 89836e6010933641640224f819f5eab7c76a3939..b84ff13d81e9d022fb5af77364cddfb053d62d73 100644 --- a/configs/lpcxpresso-lpc54628/netnsh/defconfig +++ b/configs/lpcxpresso-lpc54628/netnsh/defconfig @@ -55,7 +55,7 @@ CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_PREALLOC_TIMERS=4 CONFIG_PREALLOC_WDOGS=4 CONFIG_RAM_SIZE=163840 -CONFIG_RAM_START=0x10000000 +CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y diff --git a/configs/lpcxpresso-lpc54628/nsh/defconfig b/configs/lpcxpresso-lpc54628/nsh/defconfig index 70d2e780688fc5bd250aec768fc137873f1034a3..bdcaa769d364502f108e762884ac46bb462973aa 100644 --- a/configs/lpcxpresso-lpc54628/nsh/defconfig +++ b/configs/lpcxpresso-lpc54628/nsh/defconfig @@ -42,7 +42,7 @@ CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_PREALLOC_TIMERS=4 CONFIG_PREALLOC_WDOGS=4 CONFIG_RAM_SIZE=163840 -CONFIG_RAM_START=0x10000000 +CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC_ALARM=y diff --git a/configs/lpcxpresso-lpc54628/nxwm/defconfig b/configs/lpcxpresso-lpc54628/nxwm/defconfig index 4c2f839ee1a434daa462dc0351ee6ddbeb9a1aaa..6bcffd4a4b5939dfcd434f23fcebba045ba1eb2f 100644 --- a/configs/lpcxpresso-lpc54628/nxwm/defconfig +++ b/configs/lpcxpresso-lpc54628/nxwm/defconfig @@ -2,7 +2,6 @@ # CONFIG_NX_DISABLE_16BPP is not set # CONFIG_NXFONTS_DISABLE_16BPP is not set # CONFIG_NXTK_DEFAULT_BORDERCOLORS is not set -# CONFIG_NXWM_TOUCHSCREEN_DEVINIT is not set CONFIG_ARCH_BOARD_LPCXPRESSO_LPC54628=y CONFIG_ARCH_BOARD="lpcxpresso-lpc54628" CONFIG_ARCH_CHIP_LPC54628=y @@ -11,7 +10,6 @@ CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH_STDARG_H=y CONFIG_ARCH="arm" -CONFIG_BOARD_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=21082 CONFIG_BUILTIN=y CONFIG_FAT_LCNAMES=y @@ -87,7 +85,7 @@ CONFIG_NXWM=y CONFIG_PREALLOC_TIMERS=4 CONFIG_PREALLOC_WDOGS=8 CONFIG_RAM_SIZE=163840 -CONFIG_RAM_START=0x10000000 +CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y diff --git a/configs/lpcxpresso-lpc54628/scripts/flash.ld b/configs/lpcxpresso-lpc54628/scripts/flash.ld index fc09e2fffc5a443499319069f3d9fd19abe8470d..42a0396af854c0327936d8bb61a6260f31f9d852 100644 --- a/configs/lpcxpresso-lpc54628/scripts/flash.ld +++ b/configs/lpcxpresso-lpc54628/scripts/flash.ld @@ -33,7 +33,7 @@ * ****************************************************************************/ -/* The LPC54628 on the LPCXPressio has 512Kb of FLASH at address 0x0000:0000. +/* The LPC54628 on the LPCXPresso has 512Kb of FLASH at address 0x0000:0000. * The Main SRAM is comprised of up to a total 160 KB of contiguous, on-chip * static RAM memory beginning at address 0x2000:0000 (this is in addition * to SRAMX aso the total device SRAM can be up to 200 KB). diff --git a/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c b/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c index 162089b190bb2b3382358c7dc2e3039ff2830610..8893f08ff6532d4306f6851e1dc2bfe4759052dc 100644 --- a/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c +++ b/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c @@ -245,25 +245,4 @@ int lpc54_ft5x06_register(void) return OK; } -/**************************************************************************** - * Name: board_tsc_setup and board_tsc_teardown - * - * Description: - * Stubs for expected interfaces. This implementation does not permit the - * application to mange the touch screen controller. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_TSCTEST -int board_tsc_setup(int minor) -{ - DEBUGASSERT(minor == 0); - return OK; -} - -void board_tsc_teardown(void) -{ -} -#endif - #endif /* HAVE_FT5x06*/ diff --git a/configs/mcb1700/src/lpc17_bringup.c b/configs/mcb1700/src/lpc17_bringup.c index 6b5da0d75eebd8b6713d851e6499e2842146fcd1..8e87b8592724183e773cd10ca045b5e8f3f12620 100644 --- a/configs/mcb1700/src/lpc17_bringup.c +++ b/configs/mcb1700/src/lpc17_bringup.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -301,9 +302,9 @@ static int nsh_usbhostinitialize(void) syslog(LOG_ERR, "ERROR: Start nsh_waiter\n"); - pid = task_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO, - CONFIG_MCB1700_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO, + CONFIG_MCB1700_USBHOST_STACKSIZE, + (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } diff --git a/configs/mcu123-lpc214x/src/lpc2148_spi1.c b/configs/mcu123-lpc214x/src/lpc2148_spi1.c index a5001a5a0c26fff96ee6dee3e704891695b1d4e2..8a4675fc9c7bd6ff6e93175a270c9996b97ec244 100644 --- a/configs/mcu123-lpc214x/src/lpc2148_spi1.c +++ b/configs/mcu123-lpc214x/src/lpc2148_spi1.c @@ -525,7 +525,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/configs/mikroe-stm32f4/fulldemo/defconfig b/configs/mikroe-stm32f4/fulldemo/defconfig index 0896fb141259e03b54aaff1536d048b323e03b03..dab8c12914e617652f3f9f8f2f5d0d14025e624f 100644 --- a/configs/mikroe-stm32f4/fulldemo/defconfig +++ b/configs/mikroe-stm32f4/fulldemo/defconfig @@ -45,6 +45,7 @@ CONFIG_INTELHEX_BINARY=y CONFIG_LCD_MIO283QT2=y CONFIG_LCD=y CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_STRERROR=y CONFIG_M25P_MANUFACTURER=0x1C CONFIG_M25P_MEMORY_TYPE=0x31 diff --git a/configs/mikroe-stm32f4/src/mikroe-stm32f4.h b/configs/mikroe-stm32f4/src/mikroe-stm32f4.h index 4b8bcc3dafac837ab50a8436c82013b36cd26d17..0df889c4246807872e7c8cfbc0497920cd18b24c 100644 --- a/configs/mikroe-stm32f4/src/mikroe-stm32f4.h +++ b/configs/mikroe-stm32f4/src/mikroe-stm32f4.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/mikroe-stm32f4/src/mikroe-stm32f4.h * - * Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -218,7 +218,7 @@ void weak_function stm32_spidev_initialize(void); * Name: stm32_usbinitialize * * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related + * Called from stm32_usbinitialize very early in initialization to setup USB-related * GPIO pins for the Mikroe-stm32f4 board. * ****************************************************************************************************/ @@ -227,13 +227,13 @@ void weak_function stm32_spidev_initialize(void); void weak_function stm32_usbinitialize(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_pwm_setup * * Description: * Initialize PWM and register the PWM device. * - ************************************************************************************/ + ****************************************************************************************************/ #ifdef CONFIG_PWM int stm32_pwm_setup(void); @@ -252,13 +252,13 @@ int stm32_pwm_setup(void); # error "The Mikroe-STM32F4 board does not support HOST OTG, only device!" #endif -/**************************************************************************** +/**************************************************************************************************** * Name: stm32_qencoder_initialize * * Description: * Initialize and register a qencoder * - ****************************************************************************/ + ****************************************************************************************************/ #ifdef CONFIG_SENSORS_QENCODER int stm32_qencoder_initialize(FAR const char *devpath, int timer); @@ -277,6 +277,26 @@ int stm32_qencoder_initialize(FAR const char *devpath, int timer); void stm32_lcdinitialize(void); #endif +/**************************************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen device. This + * function will register the driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to indicate the + * nature of the failure. + * + ****************************************************************************************************/ + +#ifdef CONFIG_INPUT +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************************************** * Name: up_vs1053initialize * diff --git a/configs/mikroe-stm32f4/src/stm32_appinit.c b/configs/mikroe-stm32f4/src/stm32_appinit.c index 134f819fc4ccffe6c1dca7850a9a39f06b117daa..18028def31237923f4f96907ec36b20566e1e1aa 100644 --- a/configs/mikroe-stm32f4/src/stm32_appinit.c +++ b/configs/mikroe-stm32f4/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/mikroe_stm32f4/src/stm32_appinit.c * - * Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -350,6 +350,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/mikroe-stm32f4/src/stm32_pm.c b/configs/mikroe-stm32f4/src/stm32_pm.c index c5f89f50abbdb9f9655bdd3bb187273fa138925b..4ff3d14badd7c162458bcabd48b4cd1f75dad955 100644 --- a/configs/mikroe-stm32f4/src/stm32_pm.c +++ b/configs/mikroe-stm32f4/src/stm32_pm.c @@ -78,10 +78,10 @@ * *before* any other device drivers are initialized (since they may * attempt to register with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/configs/mikroe-stm32f4/src/stm32_touchscreen.c b/configs/mikroe-stm32f4/src/stm32_touchscreen.c index 8dfb259f48b637349fffbaed5eccfbbc7221db24..7273285db9640ebecbd272b21ec31d3831d17fd4 100644 --- a/configs/mikroe-stm32f4/src/stm32_touchscreen.c +++ b/configs/mikroe-stm32f4/src/stm32_touchscreen.c @@ -1328,7 +1328,7 @@ errout: } /**************************************************************************** - * Name:tc_ioctl + * Name: tc_ioctl ****************************************************************************/ static int tc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) @@ -1474,13 +1474,12 @@ errout: ************************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -1491,7 +1490,7 @@ errout: * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct tc_dev_s *priv; char devname[DEV_NAMELEN]; @@ -1583,25 +1582,4 @@ errout_with_priv: return ret; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* Need to unregister the /dev/inputN device here. */ -} - #endif /* CONFIG_INPUT */ diff --git a/configs/mikroe-stm32f4/src/stm32_usb.c b/configs/mikroe-stm32f4/src/stm32_usb.c index 8047a631fd3c14316b00b9faf356aeef6baa58f2..e242c690604b2bf28f94a31e6e46e590ed7b6912 100644 --- a/configs/mikroe-stm32f4/src/stm32_usb.c +++ b/configs/mikroe-stm32f4/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -208,9 +209,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -271,11 +272,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/nucleo-144/src/stm32_usb.c b/configs/nucleo-144/src/stm32_usb.c index 597570ae1831bfccbf80307475aca496b91f1549..82118d87fac40f578fd190bb00457339c6ab8d61 100644 --- a/configs/nucleo-144/src/stm32_usb.c +++ b/configs/nucleo-144/src/stm32_usb.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -239,9 +240,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, - CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -293,11 +294,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/nucleo-f072rb/src/stm32_userleds.c b/configs/nucleo-f072rb/src/stm32_userleds.c index 0b967fc662dc8f1dee2b59d4238f767447d4d1e6..8febc96b4676015fc611c461714c277fb41c7019 100644 --- a/configs/nucleo-f072rb/src/stm32_userleds.c +++ b/configs/nucleo-f072rb/src/stm32_userleds.c @@ -181,9 +181,9 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == 1) + if (led == BOARD_LD2) { - stm32f0_gpiowrite(GPIO_LD2, ldeon); + stm32f0_gpiowrite(GPIO_LD2, ledon); } } @@ -193,10 +193,7 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - if (led == 1) - { - stm32f0_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); - } + stm32f0_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); } /**************************************************************************** diff --git a/configs/nucleo-f091rc/src/stm32_userleds.c b/configs/nucleo-f091rc/src/stm32_userleds.c index b13c1882b73b76baab6f2601a0138b84e2b97341..f62e84a30e44464c171f3c8af2adf8a538325f61 100644 --- a/configs/nucleo-f091rc/src/stm32_userleds.c +++ b/configs/nucleo-f091rc/src/stm32_userleds.c @@ -181,9 +181,9 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == 1) + if (led == BOARD_LD2) { - stm32f0_gpiowrite(GPIO_LD2, ldeon); + stm32f0_gpiowrite(GPIO_LD2, ledon); } } @@ -193,10 +193,7 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - if (led == 1) - { - stm32f0_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); - } + stm32f0_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); } /**************************************************************************** diff --git a/configs/nucleo-f303re/src/nucleo-f303re.h b/configs/nucleo-f303re/src/nucleo-f303re.h index e11495f5f151437efce03975ab336fe790f8ece2..f5ee979d7aa1db82099bffdcbb8c4106b1d53b15 100644 --- a/configs/nucleo-f303re/src/nucleo-f303re.h +++ b/configs/nucleo-f303re/src/nucleo-f303re.h @@ -145,7 +145,7 @@ void weak_function stm32_spidev_initialize(void); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/nucleo-f303re/src/stm32_timer.c b/configs/nucleo-f303re/src/stm32_timer.c index fd82bb6d4f7d64ab5a99ae7a421002846ea858e8..a13edd2943c7fa8db1b28d52c3ed7ba013c3a636 100644 --- a/configs/nucleo-f303re/src/stm32_timer.c +++ b/configs/nucleo-f303re/src/stm32_timer.c @@ -68,7 +68,7 @@ * form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/nucleo-f334r8/src/nucleo-f334r8.h b/configs/nucleo-f334r8/src/nucleo-f334r8.h index 4b2929f8aac18d730712c67494d713b208b11115..463f20cb24de4401d8cb516a9b5ddd52a5d272c3 100644 --- a/configs/nucleo-f334r8/src/nucleo-f334r8.h +++ b/configs/nucleo-f334r8/src/nucleo-f334r8.h @@ -132,7 +132,7 @@ void weak_function stm32_spidev_initialize(void); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/nucleo-f410rb/src/stm32_userleds.c b/configs/nucleo-f410rb/src/stm32_userleds.c index bdd1be2b181bb4eef7458dca436be37f54ba6432..fb283a50cc7f4e2120d114178c0411e2423dadb8 100644 --- a/configs/nucleo-f410rb/src/stm32_userleds.c +++ b/configs/nucleo-f410rb/src/stm32_userleds.c @@ -181,9 +181,9 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == 1) + if (led == BOARD_LD2) { - stm32_gpiowrite(GPIO_LD2, ldeon); + stm32_gpiowrite(GPIO_LD2, ledon); } } @@ -193,10 +193,7 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - if (led == 1) - { - stm32_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); - } + stm32_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); } /**************************************************************************** diff --git a/configs/nucleo-l432kc/README.txt b/configs/nucleo-l432kc/README.txt index 33ebc530cdb55df93560e176baf4bc365814a71e..a922e17638609d388c4b9d751f521e40b7f96645 100644 --- a/configs/nucleo-l432kc/README.txt +++ b/configs/nucleo-l432kc/README.txt @@ -230,12 +230,10 @@ NuttX EABI "buildroot" Toolchain 1. You must have already configured Nuttx in /nuttx. - $ (cd tools; ./configure.sh nucleo-f4x1re/f401-nsh) + $ tools/configure.sh nucleo-l432kc/nsh $ make qconfig $ V=1 make context all 2>&1 | tee mout - Use the f411-nsh configuration if you have the Nucleo-F411RE board. - 2. Download the latest buildroot package into 3. unpack the buildroot tarball. The resulting directory may @@ -298,14 +296,13 @@ NXFLAT Toolchain mbed ==== - The Nucleo-F401RE includes boot loader from mbed: + The Nucleo-L432KC includes boot loader from mbed: - https://mbed.org/platforms/ST-Nucleo-F401RE/ https://mbed.org/handbook/Homepage Using the mbed loader: - 1. Connect the Nucleo-F4x1RE to the host PC using the USB connector. + 1. Connect the Nucleo-L432kc to the host PC using the USB connector. 2. A new file system will appear called NUCLEO; open it with Windows Explorer (assuming that you are using Windows). 3. Drag and drop nuttx.bin into the MBED window. This will load the @@ -322,9 +319,9 @@ Hardware LEDs ---- - The Nucleo F401RE and Nucleo F411RE provide a single user LED, LD2. LD2 + The Nucleo L432KC provides a single user LED, LD2. LD2 is the green LED connected to Arduino signal D13 corresponding to MCU I/O - PA5 (pin 21) or PB13 (pin 34) depending on the STM32target. + PB3 (pin 26). - When the I/O is HIGH value, the LED is on. - When the I/O is LOW, the LED is off. @@ -367,7 +364,7 @@ Serial Consoles TTL to RS-232 converter connection: - Nucleo CN10 STM32F4x1RE + Nucleo CN10 STM32L432KC ----------- ------------ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on Pin 33 PA10 USART1_TX some RS-232 converters @@ -399,7 +396,7 @@ Serial Consoles TTL to RS-232 converter connection: - Nucleo CN9 STM32F4x1RE + Nucleo CN9 STM32L432KC ----------- ------------ Pin 1 PA3 USART2_RX *Warning you make need to reverse RX/TX on Pin 2 PA2 USART2_TX some RS-232 converters @@ -457,7 +454,7 @@ Configurations nsh: --------- Configures the NuttShell (nsh) located at apps/examples/nsh for the - Nucleo-F401RE board. The Configuration enables the serial interfaces + Nucleo-L432KC board. The Configuration enables the serial interfaces on UART2. Support for builtin applications is enabled, but in the base configuration no builtin applications are selected (see NOTES below). @@ -484,7 +481,7 @@ Configurations Consoles). I have been using a TTL-to-RS-232 converter connected as shown below: - Nucleo CN10 STM32F4x1RE + Nucleo CN10 STM32L432KC ----------- ------------ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on Pin 33 PA10 USART1_TX some RS-232 converters diff --git a/configs/nucleo-l432kc/include/board.h b/configs/nucleo-l432kc/include/board.h index cbec4b9c37ad2a6556734ee179c861d8d1c911c9..041a755787c970dc5fbd56e4ace759f3f8d32086 100644 --- a/configs/nucleo-l432kc/include/board.h +++ b/configs/nucleo-l432kc/include/board.h @@ -45,7 +45,9 @@ # include #endif +#ifdef __KERNEL__ #include +#endif /************************************************************************************ * Pre-processor Definitions @@ -144,9 +146,9 @@ /* LEDs * - * The Nucleo l476RG board provides a single user LED, LD2. LD2 - * is the green LED connected to Arduino signal D13 corresponding to MCU I/O - * PA5 (pin 21) or PB13 (pin 34) depending on the STM32 target. + * The Nucleo l432kc board provides a single user LED, LD2. LD2 + * is the green LED connected to Arduino signal D13 corresponding to + * MCU I/O PB3 (pin 26). * * - When the I/O is HIGH value, the LED is on. * - When the I/O is LOW, the LED is off. @@ -264,4 +266,4 @@ void stm32l4_board_initialize(void); #endif #endif /* __ASSEMBLY__ */ -#endif /* __CONFIGS_NUCLEO_F476RG_INCLUDE_BOARD_H */ +#endif /* __CONFIGS_NUCLEO_L432KC_INCLUDE_BOARD_H */ diff --git a/configs/nucleo-l432kc/src/nucleo-l432kc.h b/configs/nucleo-l432kc/src/nucleo-l432kc.h index a9ce4bee64732f57156a61bfb4d0a810181ff83f..e5c34816bb903768741bcd8d82cb928dfac643f3 100644 --- a/configs/nucleo-l432kc/src/nucleo-l432kc.h +++ b/configs/nucleo-l432kc/src/nucleo-l432kc.h @@ -77,7 +77,7 @@ #endif /* LED. User LD2: the green LED is a user LED connected to Arduino signal D13 - * corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on the STM32 + * corresponding to MCU I/O PB3 (pin 26) * target. * * - When the I/O is HIGH value, the LED is on. @@ -85,8 +85,9 @@ */ #define GPIO_LD2 \ - (GPIO_PORTA | GPIO_PIN5 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | \ + (GPIO_PORTB | GPIO_PIN3 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | \ GPIO_SPEED_50MHz) +#define LED_DRIVER_PATH "/dev/userleds" /* Buttons * diff --git a/configs/nucleo-l432kc/src/stm32_appinit.c b/configs/nucleo-l432kc/src/stm32_appinit.c index 0422e0cf20c155114cf3dfdbf69096602994fcdf..d3a725c776abff37878c3938ea7d364dad017509 100644 --- a/configs/nucleo-l432kc/src/stm32_appinit.c +++ b/configs/nucleo-l432kc/src/stm32_appinit.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -135,6 +136,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) + /* Register the LED driver */ + + ret = userled_lower_initialize(LED_DRIVER_PATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + } +#endif + #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32L4 lower-half RTC driver */ diff --git a/configs/nucleo-l432kc/src/stm32_timer.c b/configs/nucleo-l432kc/src/stm32_timer.c index 8750ba76b9f2f35b299e03f00ebf9ce6b9c2a142..f7183936d66c1e1af31fb7a1ce20ab44ca40389e 100644 --- a/configs/nucleo-l432kc/src/stm32_timer.c +++ b/configs/nucleo-l432kc/src/stm32_timer.c @@ -68,7 +68,7 @@ * form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/nucleo-l432kc/src/stm32_userleds.c b/configs/nucleo-l432kc/src/stm32_userleds.c index 0ff3ce66c866d01aafa3b7c3954b02f0be645bc1..8dec7afee3c4e56c3dfb3b375d864a37cd7d649f 100644 --- a/configs/nucleo-l432kc/src/stm32_userleds.c +++ b/configs/nucleo-l432kc/src/stm32_userleds.c @@ -181,7 +181,7 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == 1) + if (led == BOARD_LD2) { stm32l4_gpiowrite(GPIO_LD2, ledon); } @@ -193,10 +193,7 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - if (led == 1) - { - stm32l4_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); - } + stm32l4_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); } /**************************************************************************** diff --git a/configs/nucleo-l452re/src/stm32_userleds.c b/configs/nucleo-l452re/src/stm32_userleds.c index 77ba277c34285a1f699aad01fc3602ea17b185de..4ed1b8d807e8c584111cfc0d193d08034fe334e0 100644 --- a/configs/nucleo-l452re/src/stm32_userleds.c +++ b/configs/nucleo-l452re/src/stm32_userleds.c @@ -181,9 +181,9 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == 1) + if (led == BOARD_LD2) { - stm32l4_gpiowrite(GPIO_LD2, ldeon); + stm32l4_gpiowrite(GPIO_LD2, ledon); } } @@ -193,10 +193,7 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - if (led == 1) - { - stm32l4_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); - } + stm32l4_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); } /**************************************************************************** diff --git a/configs/nucleo-l476rg/src/stm32_timer.c b/configs/nucleo-l476rg/src/stm32_timer.c index 2d6f83835ee1e99656c2a0ff218cc5ae6a25ffe7..9f578b5bc6b2459d5bc83e6d599f574d1b36936e 100644 --- a/configs/nucleo-l476rg/src/stm32_timer.c +++ b/configs/nucleo-l476rg/src/stm32_timer.c @@ -68,7 +68,7 @@ * form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/nucleo-l476rg/src/stm32_userleds.c b/configs/nucleo-l476rg/src/stm32_userleds.c index 53d9193230ab20d528488f0f83a8e17c20e8f764..9464a6ad341153563fa96f43c7c44ec7198ce71e 100644 --- a/configs/nucleo-l476rg/src/stm32_userleds.c +++ b/configs/nucleo-l476rg/src/stm32_userleds.c @@ -172,7 +172,7 @@ void board_userled_initialize(void) { /* Configure LD2 GPIO for output */ - stm32_configgpio(GPIO_LD2); + stm32l4_configgpio(GPIO_LD2); } /**************************************************************************** @@ -181,9 +181,9 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == 1) + if (led == BOARD_LD2) { - stm32_gpiowrite(GPIO_LD2, ldeon); + stm32l4_gpiowrite(GPIO_LD2, ledon); } } @@ -193,10 +193,7 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - if (led == 1) - { - stm32_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); - } + stm32l4_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0); } /**************************************************************************** diff --git a/configs/nucleo-l496zg/src/stm32_usb.c b/configs/nucleo-l496zg/src/stm32_usb.c index 505d78445a41d2c9223138d853ad3b2ed9bdd0ce..a5a0937b05922867c45a5ee2c5826a92a4ca4f80 100644 --- a/configs/nucleo-l496zg/src/stm32_usb.c +++ b/configs/nucleo-l496zg/src/stm32_usb.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -239,9 +240,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, - CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -293,11 +294,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/olimex-lpc-h3131/include/board.h b/configs/olimex-lpc-h3131/include/board.h index a411461668bda0a948d5d7c2506afe113ba069c1..2b9ace582b0a93c87d4292eaa94da13f71df3f23 100644 --- a/configs/olimex-lpc-h3131/include/board.h +++ b/configs/olimex-lpc-h3131/include/board.h @@ -174,11 +174,11 @@ extern "C" * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument that will accompany the interrupt * - * Returned value: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on failure. * ************************************************************************************/ diff --git a/configs/olimex-lpc-h3131/src/lpc31_usbhost.c b/configs/olimex-lpc-h3131/src/lpc31_usbhost.c index 18b865b7dbe65f2cddef216498804c5cd87a06a5..f267b235e76ac1667945cc568c0127f90612bcb1 100644 --- a/configs/olimex-lpc-h3131/src/lpc31_usbhost.c +++ b/configs/olimex-lpc-h3131/src/lpc31_usbhost.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -230,8 +231,9 @@ int lpc31_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, - (main_t)ehci_waiter, (FAR char * const *)NULL); + pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO,i + CONFIG_USBHOST_STACKSIZE, + (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); @@ -291,11 +293,11 @@ void lpc31_usbhost_vbusdrive(int rhport, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument that will accompany the interrupt * - * Returned value: + * Returned Value: * Zero (OK) returned on success; a negated errno value is returned on failure. * ************************************************************************************/ diff --git a/configs/olimex-lpc1766stk/src/lpc1766stk.h b/configs/olimex-lpc1766stk/src/lpc1766stk.h index e591862819a519056e9d5fd33a16ad6f8b225082..bb67e6b7efd4aa7dd8b6a73d091061b99d6dfc4e 100644 --- a/configs/olimex-lpc1766stk/src/lpc1766stk.h +++ b/configs/olimex-lpc1766stk/src/lpc1766stk.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/olimex-lpc1766stk/src/lpc1766stk.h * - * Copyright (C) 2010-2011, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -272,6 +272,27 @@ void weak_function lpc1766stk_sspdev_initialize(void); int lpc1766stk_can_setup(void); #endif +/************************************************************************************ + * Name: lpc1766stk_hidmouse_setup + * + * Description: + * This function is called by board-bringup logic to configure the HID mouse + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef CONFIG_USBHOST_HIDMOUSE +int lpc1766stk_hidmouse_setup(int minor); +#endif + #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_OLIMEX_LPC1766STK_SRC_LPC1766STK_H */ diff --git a/configs/olimex-lpc1766stk/src/lpc17_appinit.c b/configs/olimex-lpc1766stk/src/lpc17_appinit.c index 22e4858fc3eb08fa4d424aa2cf86eb20be160901..8a5d9a2fd4f80875e401cf6ec24a8b1480273120 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_appinit.c +++ b/configs/olimex-lpc1766stk/src/lpc17_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/olimex-lpc1766stk/src/lpc17_appinit.c * - * Copyright (C) 2010, 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -301,9 +302,9 @@ static int nsh_usbhostinitialize(void) syslog(LOG_ERR, "ERROR: Start nsh_waiter\n"); - pid = task_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO, - CONFIG_LPC1766STK_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO, + CONFIG_LPC1766STK_USBHOST_STACKSIZE, + (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -362,6 +363,16 @@ int board_app_initialize(uintptr_t arg) syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); } +#ifdef CONFIG_USBHOST_HIDMOUSE + /* Initialize the HID Mouse class */ + + ret = lpc1766stk_hidmouse_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: lpc1766stk_hidmouse_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_CAN /* Initialize CAN and register the CAN driver. */ diff --git a/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c b/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c index f583d52679213d618ac69e0ae3a99e4a19dd06cf..c4b6792d12f6c3f026ff30cdc51c244f3305436a 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c +++ b/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c @@ -71,17 +71,15 @@ ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: lpc1766stk_hidmouse_setup * * Description: - * Each board that supports a touchscreen device must provide this - * function. This function is called by application-specific, setup logic - * to configure the USB HID mouse driver that emulates a touchscreen - * device. This function will register the driver as /dev/mouseN where N - * is the minor device number. + * This function is called by board-bringup logic to configure the HID + * mouse device. This function will register the driver as /dev/inputN + * where N is the minor device number. * * Input Parameters: - * minor - The mouse device minor number + * minor - The mouse device minor number * * Returned Value: * Zero is returned on success. Otherwise, a negated errno value is @@ -89,7 +87,7 @@ * ****************************************************************************/ -int board_tsc_setup(int minor) +int lpc1766stk_hidmouse_setup(int minor) { static bool initialized = false; int ret; @@ -132,27 +130,4 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the USB mouse driver. It will continue - * to run and process touch interrupts in the background. - */ -} - #endif /* CONFIG_USBHOST_HIDMOUSE */ diff --git a/configs/olimex-stm32-e407/src/stm32_usb.c b/configs/olimex-stm32-e407/src/stm32_usb.c index f59dc54486b2f559993a50f3f71cbdac83a0c7a6..5e28e17faa5a1da67b033682e74348b1a2330fc2 100644 --- a/configs/olimex-stm32-e407/src/stm32_usb.c +++ b/configs/olimex-stm32-e407/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -237,9 +238,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, - CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -300,11 +301,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/olimex-stm32-h407/src/stm32_usb.c b/configs/olimex-stm32-h407/src/stm32_usb.c index a5148f1e578a441b706ecd2230f0e639a244f197..584e8c0a4e31c162f585ab8a45fbe94802b2ff95 100644 --- a/configs/olimex-stm32-h407/src/stm32_usb.c +++ b/configs/olimex-stm32-h407/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -215,9 +216,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32H407_USBHOST_PRIO, - CONFIG_STM32H407_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32H407_USBHOST_PRIO, + CONFIG_STM32H407_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -282,7 +283,7 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/olimex-stm32-p207/src/stm32_usb.c b/configs/olimex-stm32-p207/src/stm32_usb.c index fdef1532dc03d19ca76912fc6e46c3222a561fea..8195a326d28f58cb435dddba62a409182f9e015b 100644 --- a/configs/olimex-stm32-p207/src/stm32_usb.c +++ b/configs/olimex-stm32-p207/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -219,9 +220,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -236,11 +237,11 @@ int stm32_usbhost_initialize(void) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/olimex-stm32-p407/src/stm32_usb.c b/configs/olimex-stm32-p407/src/stm32_usb.c index 2456beecf6026de6a3980ab649d7f9be6e21bc57..428b44af6248d58d6ca294312d92345ca5ee4445 100644 --- a/configs/olimex-stm32-p407/src/stm32_usb.c +++ b/configs/olimex-stm32-p407/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -236,9 +237,9 @@ int stm32_usbhost_setup(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO, - CONFIG_OLIMEXP407_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO, + CONFIG_OLIMEXP407_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -299,11 +300,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/olimex-strp711/src/str71_spi.c b/configs/olimex-strp711/src/str71_spi.c index 1c18a4e5536ee1c7cc08d6a0548b18bd395572b9..f73dc744d511bd66f84bd740a8fc63604960bdc6 100644 --- a/configs/olimex-strp711/src/str71_spi.c +++ b/configs/olimex-strp711/src/str71_spi.c @@ -952,7 +952,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t bu * Initialize the selected SPI port. This function could get called * multiple times for each STR7 devices that needs an SPI reference. * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/configs/olimexino-stm32/can/defconfig b/configs/olimexino-stm32/can/defconfig index 0791cf78896bb3acec7037a85f6ff25838837a7e..8ed1c496421684fbc18fad0235326b867e25671f 100644 --- a/configs/olimexino-stm32/can/defconfig +++ b/configs/olimexino-stm32/can/defconfig @@ -48,7 +48,7 @@ CONFIG_I2C=y CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_NAME_MAX=8 diff --git a/configs/olimexino-stm32/composite/defconfig b/configs/olimexino-stm32/composite/defconfig index ad25c1672df44afad64988bea346a67957a24d5b..868b2a697ef47e583579ca8f1b72ccb5b86d23af 100644 --- a/configs/olimexino-stm32/composite/defconfig +++ b/configs/olimexino-stm32/composite/defconfig @@ -66,7 +66,7 @@ CONFIG_HAVE_CXXINITIALIZE=y CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MMCSD=y diff --git a/configs/olimexino-stm32/nsh/defconfig b/configs/olimexino-stm32/nsh/defconfig index 30a421918e32dad9584f799cad9313a22dbf31ff..0bd53f08b208b7eb86b234eaec18d50117594aa3 100644 --- a/configs/olimexino-stm32/nsh/defconfig +++ b/configs/olimexino-stm32/nsh/defconfig @@ -54,7 +54,7 @@ CONFIG_HAVE_CXXINITIALIZE=y CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MMCSD=y diff --git a/configs/olimexino-stm32/src/olimexino-stm32.h b/configs/olimexino-stm32/src/olimexino-stm32.h index 987c55c00f76913a038456726c5c67b43d5b0797..c3383eb8a2fb4f52441c280d248cde21f8222615 100644 --- a/configs/olimexino-stm32/src/olimexino-stm32.h +++ b/configs/olimexino-stm32/src/olimexino-stm32.h @@ -163,7 +163,7 @@ void stm32_usbinitialize(void); * Description: * Called to setup set a call back for USB power state changes. * - * Inputs: + * Input Parameters: * pwr_changed_handler: An interrupt handler that will be called on VBUS power * state changes. * diff --git a/configs/olimexino-stm32/src/stm32_usbdev.c b/configs/olimexino-stm32/src/stm32_usbdev.c index 148ae44312950c9bb3f53d677e09641c2c07753a..a2814fc361f6e4b0d4ebd16e079d9657e5dbe005 100644 --- a/configs/olimexino-stm32/src/stm32_usbdev.c +++ b/configs/olimexino-stm32/src/stm32_usbdev.c @@ -69,7 +69,7 @@ * Name: stm32_usb_set_pwr_callback() * * Description: - * Inputs: + * Input Parameters: * pwr_changed_handler: An interrupt handler that will be called on VBUS power * state changes. * diff --git a/configs/open1788/src/lpc17_appinit.c b/configs/open1788/src/lpc17_appinit.c index 19cc0ee0ac317717d8adbdcd5bcdc66d16f433f7..ee557911a5f0adbdf08f35b36fa62ffad83b44d7 100644 --- a/configs/open1788/src/lpc17_appinit.c +++ b/configs/open1788/src/lpc17_appinit.c @@ -89,6 +89,6 @@ int board_app_initialize(uintptr_t arg) #else /* Perform board-specific initialization */ - return lpc17_bringup(); + return open1788_bringup(); #endif } diff --git a/configs/open1788/src/lpc17_boardinitialize.c b/configs/open1788/src/lpc17_boardinitialize.c index 12109ea14e71dab411f8ce5ffa1f86a565098e05..1058f6cc7edd152d77d5939ea9ca75414d843fde 100644 --- a/configs/open1788/src/lpc17_boardinitialize.c +++ b/configs/open1788/src/lpc17_boardinitialize.c @@ -137,6 +137,6 @@ void board_initialize(void) { /* Perform board-specific initialization */ - (void)lpc17_bringup(); + (void)open1788_bringup(); } #endif diff --git a/configs/open1788/src/lpc17_bringup.c b/configs/open1788/src/lpc17_bringup.c index 98a79fcf4ec1c3129fd3871531c3393ef0064aa5..44d9228f2409525786e4442e6cd7363212e29af0 100644 --- a/configs/open1788/src/lpc17_bringup.c +++ b/configs/open1788/src/lpc17_bringup.c @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -245,12 +246,11 @@ static int nsh_sdinitialize(void) lpc17_configgpio(GPIO_SD_CD); +#ifdef NSH_HAVE_MMCSD_CDINT /* Attach an interrupt handler to get notifications when a card is * inserted or deleted. */ -#ifdef NSH_HAVE_MMCSD_CDINT - (void)irq_attach(LPC17_IRQ_P0p13, nsh_cdinterrupt, NULL); up_enable_irq(LPC17_IRQ_P0p13); @@ -344,9 +344,9 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -361,7 +361,7 @@ static int nsh_usbhostinitialize(void) ****************************************************************************/ /**************************************************************************** - * Name: lpc17_bringup + * Name: open1788_bringup * * Description: * Perform architecture-specific initialization @@ -374,7 +374,7 @@ static int nsh_usbhostinitialize(void) * ****************************************************************************/ -int lpc17_bringup(void) +int open1788_bringup(void) { int ret; @@ -398,6 +398,16 @@ int lpc17_bringup(void) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = open1788_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: open1788_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_OPEN1788_DJOYSTICK /* Initialize and register the joystick driver */ diff --git a/configs/open1788/src/lpc17_touchscreen.c b/configs/open1788/src/lpc17_touchscreen.c index eb63f526145a681c0051d8191d5594e00842808b..65a0f33faef7186ec35e0f76eeb24d9f175cc089 100644 --- a/configs/open1788/src/lpc17_touchscreen.c +++ b/configs/open1788/src/lpc17_touchscreen.c @@ -1,6 +1,5 @@ /************************************************************************************ * configs/open1788/src/lpc17_touchscreen.c - * arch/arm/src/board/lpc17_touchscreen.c * * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -255,13 +254,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: open1788_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this - * function. This function is called by application-specific, setup logic - * to configure the touchscreen device. This function will register the - * driver as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -272,76 +270,45 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int open1788_tsc_setup(int minor) { - static bool initialized = false; FAR struct spi_dev_s *dev; int ret; - iinfo("initialized:%d minor:%d\n", initialized, minor); + iinfo("minor:%d\n", minor); DEBUGASSERT(minor == 0); - /* Since there is no uninitialized logic, this initialization can be - * performed only one time. - */ - - if (!initialized) - { - /* Configure and enable the XPT2046 PENIRQ pin as an interrupting input. */ + /* Configure and enable the XPT2046 PENIRQ pin as an interrupting input. */ - (void)lpc17_configgpio(GPIO_TC_PENIRQ); + (void)lpc17_configgpio(GPIO_TC_PENIRQ); - /* Configure the XPT2046 BUSY pin as a normal input. */ + /* Configure the XPT2046 BUSY pin as a normal input. */ #ifndef XPT2046_NO_BUSY - (void)lpc17_configgpio(GPIO_TC_BUSY); + (void)lpc17_configgpio(GPIO_TC_BUSY); #endif - /* Get an instance of the SPI interface */ + /* Get an instance of the SPI interface */ - dev = lpc17_sspbus_initialize(CONFIG_ADS7843E_SPIDEV); - if (!dev) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); - return -ENODEV; - } - - /* Initialize and register the SPI touchscreen device */ + dev = lpc17_sspbus_initialize(CONFIG_ADS7843E_SPIDEV); + if (!dev) + { + ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); + return -ENODEV; + } - ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device minor=%d\n", - CONFIG_ADS7843E_DEVMINOR); - /* up_spiuninitialize(dev); */ - return -ENODEV; - } + /* Initialize and register the SPI touchscreen device */ - initialized = true; + ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device minor=%d\n", + CONFIG_ADS7843E_DEVMINOR); + /* up_spiuninitialize(dev); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen XPT2046 device yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/open1788/src/open1788.h b/configs/open1788/src/open1788.h index 589d78b261b5ed164dae27045c77eda500ab897f..4a8254348bc4dc99eabd91d6a1841a89966c806b 100644 --- a/configs/open1788/src/open1788.h +++ b/configs/open1788/src/open1788.h @@ -2,7 +2,7 @@ * configs/open1788/src/open1788.h * arch/arm/src/board/open1788.n * - * Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -162,7 +162,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_bringup + * Name: open1788_bringup * * Description: * Perform architecture-specific initialization @@ -175,7 +175,7 @@ * ************************************************************************************/ -int lpc17_bringup(void); +int open1788_bringup(void); /************************************************************************************ * Name: open1788_sspdev_initialize @@ -237,13 +237,34 @@ void open1788_nand_initialize(void); void open1788_lcd_initialize(void); #endif -/**************************************************************************** +/************************************************************************************ + * Name: open1788_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int open1788_tsc_setup(int minor); +#endif + +/************************************************************************************ * Name: lpc17_djoy_initialization * * Description: * Initialize and register the discrete joystick driver * - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_OPEN1788_DJOYSTICK int lpc17_djoy_initialization(void); diff --git a/configs/photon/src/photon.h b/configs/photon/src/photon.h index f98c223341f26e46ff2e0706570cc445cbad4f21..5b2412f7e029ee765b6ba1f7b6e9ea7bbedbf551 100644 --- a/configs/photon/src/photon.h +++ b/configs/photon/src/photon.h @@ -120,7 +120,7 @@ void weak_function stm32_spidev_initialize(void); * Description: * Perform architecture-specific initialization of the Watchdog hardware. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -138,7 +138,7 @@ int photon_watchdog_initialize(void); * Description: * Initialize wlan hardware and driver for Photon board. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/configs/pic32mx-starterkit/src/pic32mx_appinit.c b/configs/pic32mx-starterkit/src/pic32mx_appinit.c index 68aadbcce2b48f74d800cf150e6d7d71de9962f6..12ad25b4b9a41b5ca92dfeb1727d8eb8eacb5630 100644 --- a/configs/pic32mx-starterkit/src/pic32mx_appinit.c +++ b/configs/pic32mx-starterkit/src/pic32mx_appinit.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -309,9 +310,9 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } diff --git a/configs/pic32mx7mmb/src/pic32_bringup.c b/configs/pic32mx7mmb/src/pic32_bringup.c index c082621356ec4c41a8a8fd1c86ebca7ff4a7563f..bdc6b7bec113cce7340c7dc158b8bf7ad1911072 100644 --- a/configs/pic32mx7mmb/src/pic32_bringup.c +++ b/configs/pic32mx7mmb/src/pic32_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/pic32mx7mmb/src/pic32_bringup.c * - * Copyright (C) 2012, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -320,9 +321,9 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } return -ENODEV; @@ -407,5 +408,15 @@ int pic32mx_bringup(void) ret = nsh_usbdevinitialize(); } +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = pic32mx_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: pic32mx_tsc_setup failed: %d\n", ret); + } +#endif + return ret; } diff --git a/configs/pic32mx7mmb/src/pic32_touchscreen.c b/configs/pic32mx7mmb/src/pic32_touchscreen.c index 950d1fc8671b386c3dc0aadcf8f94a7c6566d7a0..82e1a91b37a319d4a753e4ec3490e59fdcd3f168 100644 --- a/configs/pic32mx7mmb/src/pic32_touchscreen.c +++ b/configs/pic32mx7mmb/src/pic32_touchscreen.c @@ -1197,7 +1197,7 @@ errout: } /**************************************************************************** - * Name:tc_ioctl + * Name: tc_ioctl ****************************************************************************/ static int tc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) @@ -1343,13 +1343,12 @@ errout: ************************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: pic32mx_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -1360,7 +1359,7 @@ errout: * ****************************************************************************/ -int board_tsc_setup(int minor) +int pic32mx_tsc_setup(int minor) { FAR struct tc_dev_s *priv; char devname[DEV_NAMELEN]; @@ -1435,25 +1434,4 @@ errout_with_priv: return ret; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* Need to unregister the /dev/inputN device here. */ -} - #endif /* CONFIG_INPUT */ diff --git a/configs/pic32mx7mmb/src/pic32mx7mmb.h b/configs/pic32mx7mmb/src/pic32mx7mmb.h index da60ef9b6fc8c961a7afe365ac9eebbd54b82a97..f28e0cb901fde09b5c37a5eebff74c38c8df729d 100644 --- a/configs/pic32mx7mmb/src/pic32mx7mmb.h +++ b/configs/pic32mx7mmb/src/pic32mx7mmb.h @@ -1,7 +1,7 @@ /**************************************************************************** * configs/pic32mx7mmb/src/pic32mx7mmb.h * - * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -119,33 +119,33 @@ extern "C" { #define EXTERN extern #endif -/************************************************************************************ +/**************************************************************************** * Name: pic32mx_spidev_initialize * * Description: - * Called to configure SPI chip select GPIO pins for the Mikroelektronika PIC32MX7 - * MMB board. + * Called to configure SPI chip select GPIO pins for the Mikroelektronika + * PIC32MX7 MMB board. * - ************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \ defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4) void weak_function pic32mx_spidev_initialize(void); #endif -/************************************************************************************ +/**************************************************************************** * Name: pic32mx_led_initialize * * Description: * Configure on-board LEDs if LED support has been selected. * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_ARCH_LEDS void pic32mx_led_initialize(void); #endif -/************************************************************************************ +/**************************************************************************** * Name: pic32mx_bringup * * Description: @@ -157,7 +157,7 @@ void pic32mx_led_initialize(void); * CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y : * Called from the NSH library * - ************************************************************************************/ + ****************************************************************************/ int pic32mx_bringup(void); @@ -173,6 +173,27 @@ int pic32mx_bringup(void); void pic32mx_lcdinitialize(void); +/**************************************************************************** + * Name: pic32mx_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT +int pic32mx_tsc_setup(int minor); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/configs/sabre-6quad/README.txt b/configs/sabre-6quad/README.txt index 9d2b4981078bd6582396bc850022b57f775ff4c5..f16dc7611397fabc3b926b5b02547565bef312e7 100644 --- a/configs/sabre-6quad/README.txt +++ b/configs/sabre-6quad/README.txt @@ -115,11 +115,48 @@ Status 2016-11-28: SMP is unusable until the SCU cache coherency logic is fixed. I do not know how to do that now. -2016-12-01: I committed a completely untest SPI driver. This was taken +2016-12-01: I committed a completely untested SPI driver. This was taken directly from the i.MX1 and is most certainly not ready for use yet. 2016-12-07: Just a note to remind myself. The PL310 L2 cache has *not* - yet been enbled. + yet been enabled. + +2018-02-06: Revisited SMP to see how much has been broken due to bit rot. + Several fixes were needed mostly due to: (1) The new version of + this_task() that calls sched_lock() and sched_unlock(), and (2) to + deferred setting g_cpu_irqlock(). That latter setting is now deferred + until sched_resume_scheduler() runs. These commits were made: + + commit 50ab5d638a37b539775d1e60085f182bf26be57f + sched/task: It is not appropriate for logic in task_exit() to call + the new version of this_task(). sched/irq: Remove redundant fetch + of CPU index; configs/sabre-6quad: update README. + + commit 0ba78530164814360eb09ed9805137b934c6f03b + sched/irq: Fix a infinite recursion problem that a recent change + introduced into the i.MX6 SMP implementation. + + commit 8aa15385060bf705bbca2c22a5682128740e55a8 + arch/arm/src/armv7-a: Found some additional places were the new + this_task() function cannot be called in the i.MX6 SMP configuration. + + commit de34b4523fc33c6f2f20619349af8fa081a3bfcd + sched/ and arch/arm/src/armv7-a: Replace a few more occurrences + of this_task() with current_task(cpu) in an effort to get the i.MX6 + working in SMP mode again. It does not yet work, sadly. + + commit cce21bef3292a40dcd97b6176ea016e2b559de8b + sched/sched: sched_lock() and sched_unlock().. back out some changes + I made recently. The seemed correct but apparently not. Also + reorder to logic so that g_global_lockcount is incremented for the very + minimum amount of time. + + With these changes, basic SMP functionality is restored and there are no + known issues (Configuration 'smp' with 4 CPUs and data cache disabled). + It is possible, however, that additional changes similar to the above will + be required in other areas of the OS, but none such are known as of this + writing. Insufficient stress testing has been done to prove that the + solution is stable. Platform Features ================= @@ -329,7 +366,7 @@ could do would be put the nuttx.bin file on that partition, then boot like: MX6Q SABRESD U-Boot > fatload mmc 2:4 0x10800000 nuttx.bin SD Card Image Copy (Successful Attempt #5) -------------------------------------- +------------------------------------------ You can use the 'dd' command to copy the first couple of megabytes from the 8GB SD card and copy that to another SD card. You then have to use 'fdisk' @@ -386,7 +423,7 @@ Debugging the NuttX image on the SD card the terminal window. Stop the U-Boot countdown to get to the U-Boot prompt. -2. Start the Segger GDB server: +3. Start the Segger GDB server: Target: MCIMX6Q6 Target Interface: JTAG @@ -396,7 +433,7 @@ Debugging the NuttX image on the SD card Waiting for GDB Connection -3. In another Xterm terminal window, start arm-none-eabi-gdb and connect to +4. In another Xterm terminal window, start arm-none-eabi-gdb and connect to the GDB server. From the Xterm Window: @@ -409,7 +446,7 @@ Debugging the NuttX image on the SD card gdb> target connect localhost:2331 gdb> mon halt -4. Start U-boot under GDB control: +5. Start U-boot under GDB control: From GDB: gdb> mon reset @@ -417,12 +454,12 @@ Debugging the NuttX image on the SD card Again stop the U-Boot countdown to get to the U-Boot prompt. -5. Load NuttX from the SD card into RAM +6. Load NuttX from the SD card into RAM From U-Boot: MX6Q SABRESD U-Boot > fatload mmc 2:1 0x10800000 nuttx.bin -6. Load symbols and set a breakpoint +7. Load symbols and set a breakpoint From GDB: gdb> mon halt @@ -434,12 +471,12 @@ Debugging the NuttX image on the SD card of course, use a different symbol if you want to start debugging later in the boot sequence. -7. Start NuttX +8. Start NuttX From U-Boot: MX6Q SABRESD U-Boot > go 0x10800040 -8. You should hit the breakpoint that you set above and be off and +9. You should hit the breakpoint that you set above and be off and debugging. Debugging a Different NuttX Image @@ -449,10 +486,20 @@ Q: What if I want do run a different version of nuttx than the nuttx.bin file on the SD card. I just want to build and debug without futzing with the SD card. Can I do that? -A: Yes with the following modifications to the prodecure above. +A: Yes with the following modifications to the procedure above. - - Skip step 5, don't bother to load NuttX into RAM - - In step 6, load NuttX into RAM like this: + - Follow steps 1-5, i.e., + + 1. Connect the J-Link to the 20-pin JTAG connector. + 2. Connect the "USB TO UART" USB VCOM port to the host PC and start a + terminal emulation program. + 3. Start the Segger GDB server. + 4. Start arm-none-eabi-gdb and connect to the GDB server. + 5. Start U-boot under GDB control, stopping the countdown to get + the U-boot prompt. + + - Skip step 6, don't bother to load NuttX into RAM + - In step 7, load NuttX into RAM like this: gdb> mon halt gdb> load nuttx <-- Loads NuttX into RAM at 0x010800000 @@ -469,14 +516,17 @@ A: Yes with the following modifications to the prodecure above. gdb> mon halt gdb> load nuttx <-- Loads NuttX into RAM at 0x010800000 gdb> file nuttx - gdb> mon set pc 0x10800040 + gdb> mon reg pc 0x10800040 gdb> s The final single will then step into the freshly loaded program. - You can then forget about steps 7 and 8. + You can then forget about steps 8 and 9. This is, in fact, my preferred way to debug. + NOTE: Setting the PC to 0x10800040 is a superstituous step. The PC + will be set 0x10800040 by the 'load nuttx' command. + You can restart the debug session at any time at the gdb> prompt by: gdb> mon reset @@ -520,7 +570,7 @@ Open Issues: This will cause the interrupt handlers on other CPUs to spin until leave_critical_section() is called. More verification is needed. -2. Cache Concurency. Cache coherency in SMP configurations is managed by the +2. Cache Concurrency. Cache coherency in SMP configurations is managed by the MPCore snoop control unit (SCU). But I don't think I have the set up correctly yet. @@ -571,6 +621,10 @@ index eedf179..1db2092 100644 #endif +3. Recent redesigns to SMP of another ARMv7-M platform have made changes to the OS + SMP support. There are no known problem but the changes have not been verified + fully (see STATUS above for 2019-02-06). + Configurations ============== @@ -661,12 +715,114 @@ Configuration sub-directories smp --- This is a configuration of testing the SMP configuration. It is - essentially equivalent to the SMP configuration except has SMP enabled. + essentially equivalent to the nsh configuration except has SMP enabled + and supports apps/examples/smp. + + Sample output of the SMP test is show below (Configuration all 4 CPUs + but with data cache disabled): + + NuttShell (NSH) NuttX-7.23 + nsh> smp + Main[0]: Running on CPU0 + Main[0]: Initializing barrier + Thread[1]: Started + Main[0]: Thread 1 created + Thread[1]: Running on CPU0 + Main[0]: Now running on CPU1 + Thread[2]: Started + Main[0]: Thread 2 created + Thread[2]: Running on CPU1 + Main[0]: Now running on CPU2 + Thread[3]: Started + Main[0]: Thread 3 created + Thread[3]: Running on CPU2 + Main[0]: Now running on CPU3 + Thread[4]: Started + Thread[4]: Running on CPU3 + Main[0]: Thread 4 created + Main[0]: Now running on CPU0 + Thread[5]: Started + Thread[5]: Running on CPU0 + Main[0]: Thread 5 created + Thread[6]: Started + Thread[6]: Running on CPU0 + Main[0]: Thread 6 created + Thread[7]: Started + Thread[7]: Running on CPU0 + Main[0]: Thread 7 created + Thread[8]: Started + Thread[8]: Running on CPU0 + Main[0]: Thread 8 created + Thread[2]: Now running on CPU0 + Thread[3]: Now running on CPU0 + Thread[4]: Now running on CPU0 + Thread[3]: Now running on CPU2 + Thread[3]: Now running on CPU0 + Thread[5]: Now running on CPU1 + Thread[5]: Now running on CPU0 + Thread[6]: Calling pthread_barrier_wait() + Thread[8]: Calling pthread_barrier_wait() + Thread[3]: Calling pthread_barrier_wait() + Thread[5]: Calling pthread_barrier_wait() + Thread[1]: Calling pthread_barrier_wait() + Thread[2]: Now running on CPU2 + Thread[2]: Calling pthread_barrier_wait() + Thread[7]: Now running on CPU3 + Thread[4]: Now running on CPU1 + Thread[4]: Calling pthread_barrier_wait() + Thread[7]: Calling pthread_barrier_wait() + Thread[7]: Back with ret=PTHREAD_BARRIER_SERIAL_THREAD (I AM SPECIAL) + Thread[6]: Back with ret=0 (I am not special) + Thread[8]: Back with ret=0 (I am not special) + Thread[3]: Back with ret=0 (I am not special) + Thread[5]: Back with ret=0 (I am not special) + Thread[1]: Back with ret=0 (I am not special) + Thread[2]: Back with ret=0 (I am not special) + Thread[4]: Back with ret=0 (I am not special) + Thread[7]: Now running on CPU1 + Thread[6]: Now running on CPU2 + Thread[3]: Now running on CPU1 + Thread[5]: Now running on CPU2 + Thread[1]: Now running on CPU1 + Thread[4]: Now running on CPU3 + Thread[2]: Now running on CPU0 + Thread[7]: Now running on CPU0 + Thread[6]: Now running on CPU0 + Thread[3]: Now running on CPU0 + Thread[4]: Now running on CPU0 + Thread[1]: Now running on CPU0 + Thread[5]: Now running on CPU0 + Thread[3]: Now running on CPU3 + Thread[3]: Now running on CPU0 + Thread[4]: Now running on CPU2 + Thread[3]: Done + Thread[4]: Now running on CPU0 + Thread[4]: Done + Thread[7]: Done + Thread[2]: Done + Thread[5]: Now running on CPU2 + Thread[8]: Now running on CPU1 + Thread[8]: Done + Thread[6]: Now running on CPU3 + Thread[5]: Done + Thread[1]: Done + Main[0]: Now running on CPU1 + Main[0]: Thread 1 completed with result=0 + Main[0]: Thread 2 completed with result=0 + Main[0]: Thread 3 completed with result=0 + Main[0]: Thread 4 completed with result=0 + Main[0]: Thread 5 completed with result=0 + Thread[6]: Done + Main[0]: Now running on CPU0 + Main[0]: Thread 6 completed with result=0 + Main[0]: Thread 7 completed with result=0 + Main[0]: Thread 8 completed with result=0 + nsh> NOTES: - 1. See the notest for the nsh configuration. Since this configuration + 1. See the notes for the nsh configuration. Since this configuration is essentially the same all of those comments apply. - 2. SMP is not fully functional. See the STATUS and SMP sections above - for detailed SMP-related issues. + 2. See the STATUS and SMP sections above for detailed SMP-related + issues. diff --git a/configs/sam3u-ek/nxwm/defconfig b/configs/sam3u-ek/nxwm/defconfig index 3e21c6bd89234cfc955beee0e288dfd791de7c84..498f5833f51f5d8a97877439ea69c2016335e216 100644 --- a/configs/sam3u-ek/nxwm/defconfig +++ b/configs/sam3u-ek/nxwm/defconfig @@ -19,7 +19,6 @@ CONFIG_ARCH="arm" CONFIG_ARMV7M_OABI_TOOLCHAIN=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_BOARD_LOOPSPERMSEC=8720 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_CXX_NEWLONG=y CONFIG_DISABLE_POLL=y CONFIG_HAVE_CXX=y @@ -29,6 +28,7 @@ CONFIG_INPUT=y CONFIG_LCD_MAXCONTRAST=1 CONFIG_LCD_MAXPOWER=31 CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=2 diff --git a/configs/sam3u-ek/src/sam3u-ek.h b/configs/sam3u-ek/src/sam3u-ek.h index 714ff54c2a4a6e03fe518a39130873bf6618a016..87119e417d4469a5d11b7d1c17de477f19d3b83b 100644 --- a/configs/sam3u-ek/src/sam3u-ek.h +++ b/configs/sam3u-ek/src/sam3u-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sam3u-ek/src/sam3u-ek.h * - * Copyright (C) 2009-2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2011, 2013, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -263,5 +263,26 @@ bool sam_writeprotected(unsigned char slot); # define sam_writeprotected(slot) (false) #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int sam_tsc_setup(int minor); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAM3U_EK_SRC_SAM3U_EK_H */ diff --git a/configs/sam3u-ek/src/sam_appinit.c b/configs/sam3u-ek/src/sam_appinit.c index 00f2cd2e212bcabe739aec51e1e49f1a73cf75f0..3de2d64e6147603dc865ada4a74d2750cdb94c77 100644 --- a/configs/sam3u-ek/src/sam_appinit.c +++ b/configs/sam3u-ek/src/sam_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sam3u-ek/src/sam_appinit.c * - * Copyright (C) 2010, 2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -128,9 +128,10 @@ int board_app_initialize(uintptr_t arg) { + int ret; + #ifdef NSH_HAVE_MMCSD FAR struct sdio_dev_s *sdio; - int ret; /* Mount the SDIO-based MMC/SD block driver */ /* First, get an instance of the SDIO interface */ @@ -164,5 +165,17 @@ int board_app_initialize(uintptr_t arg) sdio_mediachange(sdio, sam_cardinserted(0)); #endif + +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + + UNUSED(ret); return OK; } diff --git a/configs/sam3u-ek/src/sam_spi.c b/configs/sam3u-ek/src/sam_spi.c index a6a08e70905f5b063d81e523992f668d5a992dda..7813f8da7aab0bf39c2cb4903a56acb6fcb430a6 100644 --- a/configs/sam3u-ek/src/sam_spi.c +++ b/configs/sam3u-ek/src/sam_spi.c @@ -133,7 +133,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -165,7 +165,7 @@ void sam_spi0select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/sam3u-ek/src/sam_touchscreen.c b/configs/sam3u-ek/src/sam_touchscreen.c index c5cc9df288d0769138965372d0ca1de5fb7172aa..da529f2d873001b059108616a4a9f0e80a16b4e1 100644 --- a/configs/sam3u-ek/src/sam_touchscreen.c +++ b/configs/sam3u-ek/src/sam_touchscreen.c @@ -216,13 +216,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -233,7 +232,7 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; @@ -272,26 +271,4 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen ADS7843E device yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ - diff --git a/configs/sam4e-ek/nxwm/defconfig b/configs/sam4e-ek/nxwm/defconfig index a9b0bb4aea7d76915eab1526bc77c854a4792f64..bb74cc19521f93877ed5300bc4e84476b8598417 100644 --- a/configs/sam4e-ek/nxwm/defconfig +++ b/configs/sam4e-ek/nxwm/defconfig @@ -31,6 +31,7 @@ CONFIG_INTELHEX_BINARY=y CONFIG_LCD_MAXCONTRAST=1 CONFIG_LCD_MAXPOWER=64 CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/sam4e-ek/src/sam4e-ek.h b/configs/sam4e-ek/src/sam4e-ek.h index 591b90be1f6b4b7d4e8cf11637dcad34466c6935..dacbe510986669059a1da246d04982467eddc0ed 100644 --- a/configs/sam4e-ek/src/sam4e-ek.h +++ b/configs/sam4e-ek/src/sam4e-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sam4e-ek/src/sam4e-ek.h * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -440,14 +440,14 @@ bool sam_writeprotected(int slotno); # define sam_writeprotected(slotno) (false) #endif -/**************************************************************************** +/************************************************************************************ * Name: sam_at25_automount * * Description: * Initialize, configure, and mount the AT25 serial FLASH. The FLASH will * be mounted at /dev/at25. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_AT25 int sam_at25_automount(int minor); @@ -455,5 +455,26 @@ int sam_at25_automount(int minor); # define sam_at25_automount(minor) (-ENOSYS) #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int sam_tsc_setup(int minor); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAM4E_EK_SRC_SAM4E_EK_H */ diff --git a/configs/sam4e-ek/src/sam_ads7843e.c b/configs/sam4e-ek/src/sam_ads7843e.c index 82dd848cd907a34331ad60e968d564d1467aacc3..b925125a5165d2c3b56ab7ecc31bd04908d28b02 100644 --- a/configs/sam4e-ek/src/sam_ads7843e.c +++ b/configs/sam4e-ek/src/sam_ads7843e.c @@ -213,13 +213,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -230,7 +229,7 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; @@ -269,25 +268,4 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen ADS7843E device yet */ -} - #endif /* CONFIG_INPUT && CONFIG_INPUT_ADS7843E */ diff --git a/configs/sam4e-ek/src/sam_appinit.c b/configs/sam4e-ek/src/sam_appinit.c index b9ec0bcf11e7ee8489b41de9aa63603187fffe0e..38c239602f484b7904f8b6616c0326dc79813473 100644 --- a/configs/sam4e-ek/src/sam_appinit.c +++ b/configs/sam4e-ek/src/sam_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sam4e-ek/src/sam_appinit.c * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -89,9 +89,7 @@ int board_app_initialize(uintptr_t arg) { -#if defined(HAVE_AT25) || defined(HAVE_HSMCI) || defined(HAVE_USBMONITOR) int ret; -#endif #ifdef HAVE_AT25 /* Initialize the AT25 driver */ @@ -115,6 +113,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ @@ -126,5 +134,6 @@ int board_app_initialize(uintptr_t arg) } #endif + UNUSED(ret); return OK; } diff --git a/configs/sam4e-ek/src/sam_spi.c b/configs/sam4e-ek/src/sam_spi.c index 340210ec8c94f287cb22e105cc526d55d79cb467..715f97ce735e8772ca1881d6fb78995fdfbf75e0 100644 --- a/configs/sam4e-ek/src/sam_spi.c +++ b/configs/sam4e-ek/src/sam_spi.c @@ -135,7 +135,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -180,7 +180,7 @@ void sam_spi0select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/sam4l-xplained/src/sam_spi.c b/configs/sam4l-xplained/src/sam_spi.c index a6eeee18a21d8a96004260aa9611f74cae8899fb..70787cc011d97a7c6de4a3d71b199fec2859e088 100644 --- a/configs/sam4l-xplained/src/sam_spi.c +++ b/configs/sam4l-xplained/src/sam_spi.c @@ -135,7 +135,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -178,7 +178,7 @@ void sam_spi0select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -225,7 +225,7 @@ uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid) * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h b/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h index a20eb969deb67155104a0e7a7394cf259bfd02da..e6baf02f1de9e0e4dbe37cc87462427152edd803 100644 --- a/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h +++ b/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h @@ -221,7 +221,7 @@ bool sam_writeprotected(int slotno); * Description: * Perform architecture-specific initialization of the Watchdog hardware. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/configs/sama5d3-xplained/src/sam_nandflash.c b/configs/sama5d3-xplained/src/sam_nandflash.c index 69157cc3faa7a251d93a51608b1f4dbd5ac9a32c..f53fa352d9f8d26f036c01a491881b5eadadac4c 100644 --- a/configs/sama5d3-xplained/src/sam_nandflash.c +++ b/configs/sama5d3-xplained/src/sam_nandflash.c @@ -91,7 +91,7 @@ * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned Values: + * Returned Value: * OK if the HSMC was successfully configured for this CS. A negated * errno value is returned on a failure. This would fail with -ENODEV, * for example, if the board does not support NAND FLASH on the requested diff --git a/configs/sama5d3-xplained/src/sam_spi.c b/configs/sama5d3-xplained/src/sam_spi.c index a4e1b3d95da0e4bdbead690eead2d53570452fb8..ce4bfb64038e5eb9cb6b033d5b213bef9f95565e 100644 --- a/configs/sama5d3-xplained/src/sam_spi.c +++ b/configs/sama5d3-xplained/src/sam_spi.c @@ -134,7 +134,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -168,7 +168,7 @@ void sam_spi1select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/sama5d3-xplained/src/sam_usb.c b/configs/sama5d3-xplained/src/sam_usb.c index cad7cf01500d3e20aa3fdc186f35d2f3fda1b61e..8abe5f5493e90739d6ca12b1b9cccf6727b6fa05 100644 --- a/configs/sama5d3-xplained/src/sam_usb.c +++ b/configs/sama5d3-xplained/src/sam_usb.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -357,9 +358,9 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, - CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, - (main_t)ohci_waiter, (FAR char * const *)NULL); + pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, + CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, + (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); @@ -379,9 +380,9 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, - CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, - (main_t)ehci_waiter, (FAR char * const *)NULL); + pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, + CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, + (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); @@ -486,10 +487,10 @@ void sam_usbhost_vbusdrive(int rhport, bool enable) * REVISIT: Since this is a common signal, we will need to come up with some way * to inform both EHCI and OHCI drivers when this error occurs. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * - * Returned value: + * Returned Value: * Old overcurrent interrupt handler * ************************************************************************************/ diff --git a/configs/sama5d3x-ek/nxwm/defconfig b/configs/sama5d3x-ek/nxwm/defconfig index 998bd7c2523adcfb2d67b30a8125d9b5e1edcb86..8fef1f7fd99cebab9eaca90d9e76e0b124127d68 100644 --- a/configs/sama5d3x-ek/nxwm/defconfig +++ b/configs/sama5d3x-ek/nxwm/defconfig @@ -12,7 +12,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7A_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=49341 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILTIN=y CONFIG_DISABLE_POLL=y CONFIG_FLASH_SIZE=134217728 @@ -23,6 +22,7 @@ CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HOST_WINDOWS=y CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/sama5d3x-ek/src/sam_appinit.c b/configs/sama5d3x-ek/src/sam_appinit.c index 0d3083ad2bcf0f0d4b78aa1f7e85e818b46a16a4..5da376d0427e75f11f7542127afbb80867709c12 100644 --- a/configs/sama5d3x-ek/src/sam_appinit.c +++ b/configs/sama5d3x-ek/src/sam_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sama5d3x-ek/src/sam_appinit.c * - * Copyright (C) 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -173,6 +173,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_SAMA5_TSD + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef HAVE_WM8904 /* Configure WM8904 audio */ diff --git a/configs/sama5d3x-ek/src/sam_nandflash.c b/configs/sama5d3x-ek/src/sam_nandflash.c index 50c327e9f3e9109515fa10a2c2ea3f60f5c7d56e..e212a7f27498e580032016e118e59fcefdf2925c 100644 --- a/configs/sama5d3x-ek/src/sam_nandflash.c +++ b/configs/sama5d3x-ek/src/sam_nandflash.c @@ -91,7 +91,7 @@ * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned Values: + * Returned Value: * OK if the HSMC was successfully configured for this CS. A negated * errno value is returned on a failure. This would fail with -ENODEV, * for example, if the board does not support NAND FLASH on the requested diff --git a/configs/sama5d3x-ek/src/sam_spi.c b/configs/sama5d3x-ek/src/sam_spi.c index c9827f9a77d82eb27bd016b5b1a44179237b69c9..be4c0e322b867f05998d0a92f62ac6bd3d4928a9 100644 --- a/configs/sama5d3x-ek/src/sam_spi.c +++ b/configs/sama5d3x-ek/src/sam_spi.c @@ -134,7 +134,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -168,7 +168,7 @@ void sam_spi1select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/sama5d3x-ek/src/sam_touchscreen.c b/configs/sama5d3x-ek/src/sam_touchscreen.c index ba5126643ae7ed0afc669b8dc374a32fb35d4f56..e22f9911210136fc8f37f1c7b492de914388f257 100644 --- a/configs/sama5d3x-ek/src/sam_touchscreen.c +++ b/configs/sama5d3x-ek/src/sam_touchscreen.c @@ -64,34 +64,17 @@ # define CONFIG_SAMA5D3xEK_TSD_DEVMINOR 0 #endif -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this - * function. This function is called by application-specific, setup logic - * to configure the touchscreen device. This function will register the - * driver as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -102,65 +85,34 @@ * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { struct sam_adc_s *adc; - static bool initialized = false; int ret; - iinfo("initialized:%d minor:%d\n", initialized, minor); + iinfo("minor:%d\n", minor); DEBUGASSERT(minor == 0); - /* Since there is no uninitialized logic, this initialization can be - * performed only one time. - */ + /* Initialize the ADC driver */ - if (!initialized) + adc = sam_adc_initialize(); + if (!adc) { - /* Initialize the ADC driver */ - - adc = sam_adc_initialize(); - if (!adc) - { - ierr("ERROR: Failed to initialize the ADC driver\n"); - return -ENODEV; - } - - /* Initialize and register the SPI touchscreen device */ - - ret = sam_tsd_register(adc, CONFIG_SAMA5D3xEK_TSD_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device /dev/input%d: %d\n", - CONFIG_SAMA5D3xEK_TSD_DEVMINOR, ret); - return -ENODEV; - } - - initialized = true; + ierr("ERROR: Failed to initialize the ADC driver\n"); + return -ENODEV; } - return OK; -} + /* Initialize and register the SPI touchscreen device */ -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ + ret = sam_tsd_register(adc, CONFIG_SAMA5D3xEK_TSD_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device /dev/input%d: %d\n", + CONFIG_SAMA5D3xEK_TSD_DEVMINOR, ret); + return -ENODEV; + } -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen yet */ + return OK; } #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/sama5d3x-ek/src/sam_usb.c b/configs/sama5d3x-ek/src/sam_usb.c index 5b365f422d90a9e88d82b949b8d0239bb35c8e8f..614b6c31e24ef5a44b81632dafa016e4422c5279 100644 --- a/configs/sama5d3x-ek/src/sam_usb.c +++ b/configs/sama5d3x-ek/src/sam_usb.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -355,9 +356,9 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("OHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO, - CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE, - (main_t)ohci_waiter, (FAR char * const *)NULL); + pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO, + CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE, + (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); @@ -377,9 +378,9 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO, - CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE, - (main_t)ehci_waiter, (FAR char * const *)NULL); + pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO, + CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE, + (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); @@ -478,10 +479,10 @@ void sam_usbhost_vbusdrive(int rhport, bool enable) * REVISIT: Since this is a common signal, we will need to come up with some way * to inform both EHCI and OHCI drivers when this error occurs. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * - * Returned value: + * Returned Value: * Old overcurrent interrupt handler * ************************************************************************************/ diff --git a/configs/sama5d3x-ek/src/sama5d3x-ek.h b/configs/sama5d3x-ek/src/sama5d3x-ek.h index fcdfa53b3ee540d2b0190f02960bac20b52ef779..c6dd625998a551675efd125a3b141ef00f89ccee 100644 --- a/configs/sama5d3x-ek/src/sama5d3x-ek.h +++ b/configs/sama5d3x-ek/src/sama5d3x-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sama5d3x-ek/src/sama5d3x-ek.h * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -833,6 +833,27 @@ int sam_usbhost_initialize(void); void weak_function sam_netinitialize(void); #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef CONFIG_SAMA5_TSD +int sam_tsc_setup(int minor); +#endif + /************************************************************************************ * Name: sam_pwm_setup * diff --git a/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt index 40a703e40257a9b9b92c8d0a1daed0a015812a1f..fa063560b7ae4cd59f4d449dacbffc4fe56053cb 100644 --- a/configs/sama5d4-ek/README.txt +++ b/configs/sama5d4-ek/README.txt @@ -3268,7 +3268,6 @@ TM7000 LCD/Touchscreen build in a touchscreen test: CONFIG_EXAMPLES_TOUCHSCREEN=y - CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 diff --git a/configs/sama5d4-ek/nxwm/defconfig b/configs/sama5d4-ek/nxwm/defconfig index 5970178745b1c66734abef288c9ae902aa1b79e8..c669a50f4a2ad870052200a02c16e7988dd3d8cd 100644 --- a/configs/sama5d4-ek/nxwm/defconfig +++ b/configs/sama5d4-ek/nxwm/defconfig @@ -46,6 +46,7 @@ CONFIG_I2CTOOL_MAXBUS=0 CONFIG_INPUT_MXT=y CONFIG_INPUT=y CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/sama5d4-ek/src/at25_main.c b/configs/sama5d4-ek/src/at25_main.c index 699f613b10e364c0b966560f4d63b0c627a084ed..2d07927ee366586ce7dbbb06166cf75a6bf6d855 100644 --- a/configs/sama5d4-ek/src/at25_main.c +++ b/configs/sama5d4-ek/src/at25_main.c @@ -144,7 +144,7 @@ int at25_main(int argc, char *argv) fd = open(g_at25dev, O_WRONLY); if (fd < 0) { - int errcode = errno; + int errcode = get_errno(); fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_at25dev, errcode); return EXIT_FAILURE; } @@ -205,7 +205,7 @@ int at25_main(int argc, char *argv) nwritten = write(fd, src, memoutstream.public.nput); if (nwritten <= 0) { - int errcode = errno; + int errcode = get_errno(); if (errno != EINTR) { fprintf(stderr, "ERROR: Write failed: %d\n", errcode); @@ -235,7 +235,7 @@ int at25_main(int argc, char *argv) fd = open(g_at25dev, O_RDONLY); if (fd < 0) { - int errcode = errno; + int errcode = get_errno(); fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_at25dev, errcode); return EXIT_FAILURE; } @@ -254,7 +254,7 @@ int at25_main(int argc, char *argv) nread = read(fd, g_iobuffer, rdsize); if (nread <= 0) { - int errcode = errno; + int errcode = get_errno(); if (errno != EINTR) { fprintf(stderr, "ERROR: Read failed: %d\n", errcode); diff --git a/configs/sama5d4-ek/src/sam_bringup.c b/configs/sama5d4-ek/src/sam_bringup.c index 5669b17fc78fcefcbf4ef00a9e4ee4f55a080c17..d5a01c2fe671ac3bd0ae6b651d47388e2399f32f 100644 --- a/configs/sama5d4-ek/src/sam_bringup.c +++ b/configs/sama5d4-ek/src/sam_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sama5d4-ek/src/sam_bringup.c * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -288,6 +288,16 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MAXTOUCH + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/sama5d4-ek/src/sam_maxtouch.c b/configs/sama5d4-ek/src/sam_maxtouch.c index 1511c7a662ca4cc2de6dd77242a8b425c8147676..0790caa711df20f53939b253d84677310f8e5eb8 100644 --- a/configs/sama5d4-ek/src/sam_maxtouch.c +++ b/configs/sama5d4-ek/src/sam_maxtouch.c @@ -219,13 +219,12 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -236,81 +235,44 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct i2c_master_s *i2c; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ - - if (!initialized) - { - /* Configure the maXTouch CHG interrupt pin */ + /* Configure the maXTouch CHG interrupt pin */ - (void)sam_configpio(PIO_CHG_MXT); + (void)sam_configpio(PIO_CHG_MXT); - /* Get an instance of the I2C interface for the touchscreen chip select */ + /* Get an instance of the I2C interface for the touchscreen chip select */ - i2c = sam_i2cbus_initialize(MXT_TWI_BUS); - if (!i2c) - { - ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); - return -ENODEV; - } - - /* Configure maXTouch CHG interrupts */ - - sam_pioirq(PIO_CHG_MXT); - (void)irq_attach(IRQ_CHG_MXT, mxt_interrupt, NULL); + i2c = sam_i2cbus_initialize(MXT_TWI_BUS); + if (!i2c) + { + ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); + return -ENODEV; + } - /* Initialize and register the I2C touchscreen device */ + /* Configure maXTouch CHG interrupts */ - ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMA5D4EK_MXT_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - irq_detach(IRQ_CHG_MXT); - /* sam_i2cbus_uninitialize(i2c); */ - return -ENODEV; - } + sam_pioirq(PIO_CHG_MXT); + (void)irq_attach(IRQ_CHG_MXT, mxt_interrupt, NULL); - /* Now we are initialized */ + /* Initialize and register the I2C touchscreen device */ - initialized = true; + ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMA5D4EK_MXT_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + irq_detach(IRQ_CHG_MXT); + /* sam_i2cbus_uninitialize(i2c); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen maXTouch device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* HAVE_MAXTOUCH */ diff --git a/configs/sama5d4-ek/src/sam_nandflash.c b/configs/sama5d4-ek/src/sam_nandflash.c index 6a5c90db285a11e0624f1290df8dea3595a3902d..467ac8b106fcf287252229d2bd751f93a6f08e15 100644 --- a/configs/sama5d4-ek/src/sam_nandflash.c +++ b/configs/sama5d4-ek/src/sam_nandflash.c @@ -91,7 +91,7 @@ * cs - Chip select number (in the event that multiple NAND devices * are connected on-board). * - * Returned Values: + * Returned Value: * OK if the HSMC was successfully configured for this CS. A negated * errno value is returned on a failure. This would fail with -ENODEV, * for example, if the board does not support NAND FLASH on the requested diff --git a/configs/sama5d4-ek/src/sam_spi.c b/configs/sama5d4-ek/src/sam_spi.c index 7534e373b1b59032bd9ebfdb16ae723d0e467793..611378c462ade2677f7ef129d4e6b4e1c5c0dc45 100644 --- a/configs/sama5d4-ek/src/sam_spi.c +++ b/configs/sama5d4-ek/src/sam_spi.c @@ -134,7 +134,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -168,7 +168,7 @@ void sam_spi1select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/sama5d4-ek/src/sam_usb.c b/configs/sama5d4-ek/src/sam_usb.c index a73c4b384f70883e1fd4fdaef038f87f67228f48..081197a7fadbe332341277e9346ae8196c56bdf2 100644 --- a/configs/sama5d4-ek/src/sam_usb.c +++ b/configs/sama5d4-ek/src/sam_usb.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -356,9 +357,9 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, - CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, - (main_t)ohci_waiter, (FAR char * const *)NULL); + pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, + CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, + (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); @@ -378,9 +379,9 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, - CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, - (main_t)ehci_waiter, (FAR char * const *)NULL); + pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, + CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, + (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); @@ -482,7 +483,7 @@ void sam_usbhost_vbusdrive(int rhport, bool enable) * Input Parameters: * handler - New over-current interrupt handler * - * Returned value: + * Returned Value: * Old over-current interrupt handler * ************************************************************************************/ diff --git a/configs/sama5d4-ek/src/sama5d4-ek.h b/configs/sama5d4-ek/src/sama5d4-ek.h index 1a364f64c23c031bba4e184d71193b31db5adb05..50e956b08de99e4cafe7dd6e77a0b9ee9331aa98 100644 --- a/configs/sama5d4-ek/src/sama5d4-ek.h +++ b/configs/sama5d4-ek/src/sama5d4-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sama5d4-ek/src/sama5d4-ek.h * - * Copyright (C) 2014-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1060,19 +1060,41 @@ bool sam_writeprotected(int slotno); void weak_function sam_usbinitialize(void); #endif -/**************************************************************************************************** +/************************************************************************************ * Name: stm32_usbhost_initialize * * Description: - * Called at application startup time to initialize the USB host functionality. This function will - * start a thread that will monitor for device connection/disconnection events. + * Called at application startup time to initialize the USB host functionality. + * This function will start a thread that will monitor for device connection/ + * disconnection events. * - ****************************************************************************************************/ + ************************************************************************************/ #ifdef HAVE_USBHOST int sam_usbhost_initialize(void); #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef HAVE_MAXTOUCH +int sam_tsc_setup(int minor); +#endif + /************************************************************************************ * Name: sam_pwm_setup * diff --git a/configs/samd20-xplained/src/sam_spi.c b/configs/samd20-xplained/src/sam_spi.c index 2367243fe54038d1baa12b464c46e415c584a9b3..0a15fa4d358df066b7ca0ab9f8fbe9606fcf10a9 100644 --- a/configs/samd20-xplained/src/sam_spi.c +++ b/configs/samd20-xplained/src/sam_spi.c @@ -142,7 +142,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -241,7 +241,7 @@ void sam_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -340,7 +340,7 @@ uint8_t sam_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/configs/samd21-xplained/src/sam_spi.c b/configs/samd21-xplained/src/sam_spi.c index 32dbdb62bbaf3044057f6bc537c407386b9ffaf5..624fc59bbaa0f53a8bf96a5b6f2b4360ccdce445 100644 --- a/configs/samd21-xplained/src/sam_spi.c +++ b/configs/samd21-xplained/src/sam_spi.c @@ -142,7 +142,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -241,7 +241,7 @@ void sam_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -340,7 +340,7 @@ uint8_t sam_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/configs/same70-xplained/src/sam_spi.c b/configs/same70-xplained/src/sam_spi.c index a9095c462d206aa4585469055d289d5ffdc16521..57bde8904d5ebba4e8a697c7e4101c880895d378 100644 --- a/configs/same70-xplained/src/sam_spi.c +++ b/configs/same70-xplained/src/sam_spi.c @@ -146,7 +146,7 @@ void sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -204,7 +204,7 @@ void sam_spi1select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/saml21-xplained/src/sam_spi.c b/configs/saml21-xplained/src/sam_spi.c index 576444508d1ef9c09989179a9ae191a495e88d87..ff654a2d3052872e9c4cd534e3170dcdfbd50f6e 100644 --- a/configs/saml21-xplained/src/sam_spi.c +++ b/configs/saml21-xplained/src/sam_spi.c @@ -142,7 +142,7 @@ void weak_function sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -241,7 +241,7 @@ void sam_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -340,7 +340,7 @@ uint8_t sam_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) * dev - SPI device info * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Zero on success; a negated errno on failure. * ****************************************************************************/ diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index c290d05badd3964f851c648eba5a8dc609f87661..782bdaf632733c2dc34d2124bc62adba795ca583 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1231,7 +1231,6 @@ MXT Configuration Options Application Configuration -> Examples -> Touchscreen example CONFIG_EXAMPLES_TOUCHSCREEN=y : Enables the example - CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y : Have board-specific intialization CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 diff --git a/configs/samv71-xult/nxwm/defconfig b/configs/samv71-xult/nxwm/defconfig index 80cc25bf5c7d892f7c0fff3c49aa2b987cd6b551..668cdb620d995b886bf27234aa38c1e1d4cc7488 100644 --- a/configs/samv71-xult/nxwm/defconfig +++ b/configs/samv71-xult/nxwm/defconfig @@ -27,7 +27,6 @@ CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 CONFIG_AT24XX_SIZE=2 CONFIG_BOARD_LOOPSPERMSEC=51262 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILTIN=y CONFIG_DISABLE_POLL=y CONFIG_FAT_LCNAMES=y @@ -41,6 +40,7 @@ CONFIG_INPUT_MXT=y CONFIG_INPUT=y CONFIG_LCD_NOGETRUN=y CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 5d6e288e214eed95a4454e0b630f34d048260e3a..4326c2b8eec38cf48a868c9ff4c8870a52a4e440 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -507,6 +507,16 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MAXTOUCH + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef HAVE_WM8904 /* Configure WM8904 audio */ diff --git a/configs/samv71-xult/src/sam_maxtouch.c b/configs/samv71-xult/src/sam_maxtouch.c index e6e97de0e528c1efea872f0f0a442c92d73d8d8f..e368d5958d9d6ad4e990c3e7e347e98e8764a36e 100644 --- a/configs/samv71-xult/src/sam_maxtouch.c +++ b/configs/samv71-xult/src/sam_maxtouch.c @@ -218,13 +218,12 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -235,81 +234,44 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct i2c_master_s *i2c; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ - - if (!initialized) - { - /* Configure the maXTouch CHG interrupt pin */ + /* Configure the maXTouch CHG interrupt pin */ - (void)sam_configgpio(GPIO_MXT_CHG); + (void)sam_configgpio(GPIO_MXT_CHG); - /* Get an instance of the I2C interface for the touchscreen chip select */ + /* Get an instance of the I2C interface for the touchscreen chip select */ - i2c = sam_i2cbus_initialize(MXT_TWI_BUS); - if (!i2c) - { - ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); - return -ENODEV; - } - - /* Configure maXTouch CHG interrupts */ - - sam_gpioirq(GPIO_MXT_CHG); - (void)irq_attach(IRQ_MXT_CHG, mxt_interrupt, NULL); + i2c = sam_i2cbus_initialize(MXT_TWI_BUS); + if (!i2c) + { + ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); + return -ENODEV; + } - /* Initialize and register the I2C touchscreen device */ + /* Configure maXTouch CHG interrupts */ - ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMV71XULT_MXT_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - irq_detach(IRQ_MXT_CHG); - /* sam_i2cbus_uninitialize(i2c); */ - return -ENODEV; - } + sam_gpioirq(GPIO_MXT_CHG); + (void)irq_attach(IRQ_MXT_CHG, mxt_interrupt, NULL); - /* Now we are initialized */ + /* Initialize and register the I2C touchscreen device */ - initialized = true; + ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMV71XULT_MXT_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + irq_detach(IRQ_MXT_CHG); + /* sam_i2cbus_uninitialize(i2c); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen maXTouch device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* HAVE_MAXTOUCH */ diff --git a/configs/samv71-xult/src/sam_spi.c b/configs/samv71-xult/src/sam_spi.c index 563c03965c9c17e97e784cffaa2663e88d4dc37c..e7e2271f9f14c13ca2e4325822ba75d1b4663760 100644 --- a/configs/samv71-xult/src/sam_spi.c +++ b/configs/samv71-xult/src/sam_spi.c @@ -151,7 +151,7 @@ void sam_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -197,7 +197,7 @@ void sam_spi1select(uint32_t devid, bool selected) * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index c9b3718b2cc2cff521b0008c3307d2659f40d6a7..cb273a819fa1073f87ff2334049f1e1e841e97c0 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/samv71-xult/src/samv71-xult.h * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -846,28 +846,49 @@ bool sam_writeprotected(int slotno); int sam_at24config(void); #endif -/**************************************************************************** +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef HAVE_MAXTOUCH +int sam_tsc_setup(int minor); +#endif + +/************************************************************************************ * Name: sam_wm8904_initialize * * Description: - * This function is called by platform-specific, setup logic to configure - * and register the WM8904 device. This function will register the driver - * as /dev/wm8904[x] where x is determined by the minor device number. + * This function is called by platform-specific, setup logic to configure and + * register the WM8904 device. This function will register the driver as + * /dev/wm8904[x] where x is determined by the minor device number. * * Input Parameters: * minor - The input device minor number * * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. + * Zero is returned on success. Otherwise, a negated errno value is returned + * to indicate the nature of the failure. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_WM8904 int sam_wm8904_initialize(int minor); #endif /* HAVE_WM8904 */ -/**************************************************************************** +/************************************************************************************ * Name: sam_audio_null_initialize * * Description: @@ -877,26 +898,26 @@ int sam_wm8904_initialize(int minor); * minor - The input device minor number * * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. + * Zero is returned on success. Otherwise, a negated errno value is returned + * to indicate the nature of the failure. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_AUDIO_NULL int sam_audio_null_initialize(int minor); #endif /* HAVE_AUDIO_NULL */ -/**************************************************************************** +/************************************************************************************ * Name: stm32_mrf24j40_initialize * * Description: * Initialize the MRF24J40 device. * * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. + * Zero is returned on success. Otherwise, a negated errno value is returned + * to indicate the nature of the failure. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_MRF24J40 int sam_mrf24j40_initialize(void); diff --git a/configs/samv71-xult/vnxwm/defconfig b/configs/samv71-xult/vnxwm/defconfig index ac4e18a30d880b9b4296befbb1740da56d0dee77..40870a8f12de1bab68e2b55643c988771f5f99c4 100644 --- a/configs/samv71-xult/vnxwm/defconfig +++ b/configs/samv71-xult/vnxwm/defconfig @@ -39,6 +39,7 @@ CONFIG_HOST_WINDOWS=y CONFIG_I2C_DRIVER=y CONFIG_IOB_NBUFFERS=72 CONFIG_IOB_THROTTLE=32 +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/shenzhou/nxwm/defconfig b/configs/shenzhou/nxwm/defconfig index 33241b13dc7dadcd75b7a2ce32ce4595913ea65a..859bb2ca3e4fff58ff709124037a3c2eda7592aa 100644 --- a/configs/shenzhou/nxwm/defconfig +++ b/configs/shenzhou/nxwm/defconfig @@ -17,7 +17,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_ETH0_PHY_DM9161=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y @@ -29,6 +28,7 @@ CONFIG_LCD_MAXCONTRAST=1 CONFIG_LCD_NOGETRUN=y CONFIG_LCD_SSD1289=y CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MQ_MAXMSGSIZE=64 diff --git a/configs/shenzhou/src/shenzhou.h b/configs/shenzhou/src/shenzhou.h index 68fb63d1020afd888736a7c85b752386b8b1cbc3..a841307dfb532f1aa0e09949d8528c2ff41d15da 100644 --- a/configs/shenzhou/src/shenzhou.h +++ b/configs/shenzhou/src/shenzhou.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/shenzhou/src/shenzhou.h * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -426,7 +426,7 @@ void weak_function stm32_spidev_initialize(void); * Name: stm32_usbinitialize * * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related GPIO pins for + * Called from stm32_usbinitialize very early in initialization to setup USB-related GPIO pins for * the STM3240G-EVAL board. * ****************************************************************************************************/ @@ -448,13 +448,34 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif -/************************************************************************************ +/**************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int stm32_tsc_setup(int minor); +#endif + +/**************************************************************************** * Name: stm32_adc_setup * * Description: * Initialize ADC and register the ADC driver. * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_ADC int stm32_adc_setup(void); diff --git a/configs/shenzhou/src/stm32_appinit.c b/configs/shenzhou/src/stm32_appinit.c index a260c4ec1e99d677157f295199918a91deb0a0a6..18de2f1660d943a2b4f0e2001036aef1cdc2c88c 100644 --- a/configs/shenzhou/src/stm32_appinit.c +++ b/configs/shenzhou/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/shenzhou/src/stm32_appinit.c * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -204,6 +204,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_ADC /* Initialize ADC and register the ADC driver. */ diff --git a/configs/shenzhou/src/stm32_touchscreen.c b/configs/shenzhou/src/stm32_touchscreen.c index 99b3971df80b1db8d459d1dc5dd084d796246e89..1e0fe2e12cc295ff7605673522c89fbfdc5b0d87 100644 --- a/configs/shenzhou/src/stm32_touchscreen.c +++ b/configs/shenzhou/src/stm32_touchscreen.c @@ -230,13 +230,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -247,7 +246,7 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; @@ -281,26 +280,5 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen ADS7843E device yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/shenzhou/src/stm32_usb.c b/configs/shenzhou/src/stm32_usb.c index 5baddf4d016329dc0945a03b0a0480f7dc8c1998..a45f43a83f437b5f67626f5a3bc7b33db1410daa 100644 --- a/configs/shenzhou/src/stm32_usb.c +++ b/configs/shenzhou/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -208,9 +209,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -271,11 +272,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 226ddd3ffd8f3933eb7f1f33c7e40cff8f95c187..b463f412af154436134a1b91bf6052f88b61837e 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -729,10 +729,6 @@ nx11 CONFIG_INPUT=y CONFIG_SIM_TOUCHSCREEN=y - Then you must also have some application logic that will call - board_tsc_setup(0) to register the touchscreen driver. See - also configuration "touchscreen" - NOTES: a. If you do not have the call to sim_tcinitialize(0), the build diff --git a/configs/sim/nxwm/defconfig b/configs/sim/nxwm/defconfig index 17fadb5035f764a7eefcb9368d5c13f0082704f1..a0c17d2cfa131ef2b3c8eede222efa544e712ebd 100644 --- a/configs/sim/nxwm/defconfig +++ b/configs/sim/nxwm/defconfig @@ -15,6 +15,7 @@ CONFIG_FS_PROCFS=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MQ_MAXMSGSIZE=64 CONFIG_NSH_ARCHINIT=y diff --git a/configs/sim/src/sim.h b/configs/sim/src/sim.h index f851b339ccaff306d8c6a47194a2ff9de0e50941..808818da1ac57fc1a909409e4e84961e783cb7f5 100644 --- a/configs/sim/src/sim.h +++ b/configs/sim/src/sim.h @@ -1,7 +1,7 @@ /**************************************************************************** * config/sim/src/sim.h * - * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -123,4 +123,25 @@ int sim_zoneinfo(int minor); int sim_gpio_initialize(void); #endif +/**************************************************************************** + * Name: sim_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) +int sim_tsc_setup(int minor); +#endif + #endif /* __CONFIGS_SIM_SRC_SIM_H */ \ No newline at end of file diff --git a/configs/sim/src/sim_bringup.c b/configs/sim/src/sim_bringup.c index 22351f6270bf62155dc2db2778d4e382cef74e42..a2233a5fd84706f15bcf0015c9380c71c196e16e 100644 --- a/configs/sim/src/sim_bringup.c +++ b/configs/sim/src/sim_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/sim/src/sam_bringup.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -68,8 +68,7 @@ int trv_mount_world(int minor, FAR const char *mountpoint); #define NEED_FRAMEBUFFER 1 /* If we are using the X11 touchscreen simulation, then the frame buffer - * initialization happens in board_tsc_setup. Otherwise, we will need to - * do that here. + * initialization will need to be done here. */ #if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) @@ -200,6 +199,16 @@ int sim_bringup(void) sim_ajoy_initialize(); #endif +#if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) + /* Initialize the touchscreen */ + + ret = sim_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sim_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO /* Special initialization for the Traveler game simulation */ diff --git a/configs/sim/src/sim_touchscreen.c b/configs/sim/src/sim_touchscreen.c index 0f45d5300df2aa44a527baaeb0fc46bf530bae35..c9e9a58f2813e37ec819a1aaae7300854a416303 100644 --- a/configs/sim/src/sim_touchscreen.c +++ b/configs/sim/src/sim_touchscreen.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sim/src/sim_touchscreen.c * - * Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -145,16 +146,23 @@ static FAR void *sim_listener(FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup() + * Name: sim_tsc_setup * * Description: - * Perform architecuture-specific initialization of the touchscreen - * hardware. This interface must be provided by all configurations - * using apps/examples/touchscreen + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. * ****************************************************************************/ -int board_tsc_setup(int minor) +int sim_tsc_setup(int minor) { struct sched_param param; nxgl_mxpixel_t color; @@ -164,10 +172,10 @@ int board_tsc_setup(int minor) /* Set the client task priority */ param.sched_priority = CONFIG_SIM_CLIENTPRIO; - ret = sched_setparam(0, ¶m); + ret = nxsched_setparam(0, ¶m); if (ret < 0) { - gerr("ERROR: sched_setparam failed: %d\n" , ret); + gerr("ERROR: nxsched_setparam failed: %d\n" , ret); return ret; } @@ -262,24 +270,3 @@ errout_with_nx: errout: return ret; } - -/**************************************************************************** - * Name: board_tsc_teardown() - * - * Description: - * Perform architecuture-specific un-initialization of the touchscreen - * hardware. This interface must be provided by all configurations - * using apps/examples/touchscreen - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* Shut down the touchscreen driver */ - - sim_tsc_uninitialize(); - - /* Close NX */ - - nx_disconnect(g_simtc.hnx); -} diff --git a/configs/spark/composite/defconfig b/configs/spark/composite/defconfig index af4f8711003e91319d754c1a80d14cedf4c18b05..64e28d8db7b8c7c236884a6ee0a9eb1ab067763f 100644 --- a/configs/spark/composite/defconfig +++ b/configs/spark/composite/defconfig @@ -58,7 +58,7 @@ CONFIG_IDLETHREAD_STACKSIZE=280 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/spark/nsh/defconfig b/configs/spark/nsh/defconfig index 40363aae9f910caa8e26e8566fcf04650274d5cc..28222b3f4d91b0d9b1e7f4ac31b4211022189c1e 100644 --- a/configs/spark/nsh/defconfig +++ b/configs/spark/nsh/defconfig @@ -49,7 +49,7 @@ CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/spark/src/stm32_cc3000.c b/configs/spark/src/stm32_cc3000.c index 92d255d6d9db835c08b23f80e3e532dcb80f4268..8cda9fb6020427ff00e736fdf06f0faad017ce58 100644 --- a/configs/spark/src/stm32_cc3000.c +++ b/configs/spark/src/stm32_cc3000.c @@ -327,7 +327,7 @@ int wireless_archinitialize(size_t max_rx_size) * Warning: This function must be called before ANY other wlan driver * function * - * Input Parmeters: + * Input Parameters: * sWlanCB Asynchronous events callback. * 0 no event call back. * - Call back parameters: diff --git a/configs/spark/usbmsc/defconfig b/configs/spark/usbmsc/defconfig index 37cd3ef6cc5916471842da9b20e93697ac995281..eed15c31c7559f4b42bcee2ce0e1ab39e0c15c1e 100644 --- a/configs/spark/usbmsc/defconfig +++ b/configs/spark/usbmsc/defconfig @@ -44,7 +44,7 @@ CONFIG_IDLETHREAD_STACKSIZE=280 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/spark/usbserial/defconfig b/configs/spark/usbserial/defconfig index 1699ef387d73d23088017037a394cea83f1626d6..7b0d94af996585586f3ce7e4fce75a0d60f21696 100644 --- a/configs/spark/usbserial/defconfig +++ b/configs/spark/usbserial/defconfig @@ -41,7 +41,7 @@ CONFIG_INTELHEX_BINARY=y CONFIG_LIB_BOARDCTL=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/stm3210e-eval/include/board.h b/configs/stm3210e-eval/include/board.h index f76389222b7973fe769bd85c2cca7fbdcabd467e..d03816b43992fdd5690cceb6bc0e62e0194ee074 100644 --- a/configs/stm3210e-eval/include/board.h +++ b/configs/stm3210e-eval/include/board.h @@ -261,7 +261,7 @@ void stm3210e_lcdclear(uint16_t color); * Description: * Initialize and register the LM-75 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: @@ -279,7 +279,7 @@ int stm32_lm75initialize(FAR const char *devpath); * Description: * Attach the LM-75 interrupt handler * - * Input parameters: + * Input Parameters: * irqhandler - the LM-75 interrupt handler * arg - The argument that will accompany the interrupt * diff --git a/configs/stm3210e-eval/src/stm32_lm75.c b/configs/stm3210e-eval/src/stm32_lm75.c index a083b7838300cc8b28fc31772d2dbef6bd8053d8..52b04c495bed30625486e3a29d6dc4d4483b2354 100644 --- a/configs/stm3210e-eval/src/stm32_lm75.c +++ b/configs/stm3210e-eval/src/stm32_lm75.c @@ -60,7 +60,7 @@ * Description: * Initialize and register the LM-75 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: @@ -104,7 +104,7 @@ int stm32_lm75initialize(FAR const char *devpath) * Description: * Attach the LM-75 interrupt handler * - * Input parameters: + * Input Parameters: * irqhandler - the LM-75 interrupt handler * arg - The argument that will accompany the interrupt * diff --git a/configs/stm3210e-eval/src/stm32_pm.c b/configs/stm3210e-eval/src/stm32_pm.c index 1da3078a9c2b698c7c5f8cc66bb117e2f84ae48e..7c7b13f4b93eb89f658a468f177e3ffd836c1b91 100644 --- a/configs/stm3210e-eval/src/stm32_pm.c +++ b/configs/stm3210e-eval/src/stm32_pm.c @@ -78,10 +78,10 @@ * *before* any other device drivers are initialized (since they may * attempt to register with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/configs/stm3220g-eval/nxwm/defconfig b/configs/stm3220g-eval/nxwm/defconfig index 1bfe7f8541516a29d59fd4108b149b0c7a7eeae5..25a868d87264ad01c94b1ec00f81251201c8ed89 100644 --- a/configs/stm3220g-eval/nxwm/defconfig +++ b/configs/stm3220g-eval/nxwm/defconfig @@ -15,7 +15,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=10926 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_ETH0_PHY_DP83848C=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y diff --git a/configs/stm3220g-eval/src/stm3220g-eval.h b/configs/stm3220g-eval/src/stm3220g-eval.h index 1e3087109f491931c8a3bd93bceffb8958f69801..95e603fd17a41241a8c8b898575cc0a06b21d7e3 100644 --- a/configs/stm3220g-eval/src/stm3220g-eval.h +++ b/configs/stm3220g-eval/src/stm3220g-eval.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/stm3220g_eval/src/stm3220g.h * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -249,6 +249,26 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif +/**************************************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen device. This + * function will register the driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to indicate the + * nature of the failure. + * + ****************************************************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************************************** * Name: stm32_pwm_setup * @@ -321,7 +341,7 @@ void stm32_extmemaddr(int naddrs); void stm32_extmemdata(int ndata); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_enablefsmc * * Description: @@ -333,7 +353,7 @@ void stm32_extmemdata(int ndata); void stm32_enablefsmc(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_disablefsmc * * Description: @@ -345,7 +365,7 @@ void stm32_enablefsmc(void); void stm32_disablefsmc(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_selectsram * * Description: @@ -375,7 +395,7 @@ void stm32_disablefsmc(void); void stm32_selectsram(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_deselectsram * * Description: @@ -387,7 +407,7 @@ void stm32_selectsram(void); void stm32_deselectsram(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_selectlcd * * Description: @@ -399,7 +419,7 @@ void stm32_deselectsram(void); void stm32_selectlcd(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_deselectlcd * * Description: @@ -413,4 +433,3 @@ void stm32_deselectlcd(void); #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_STM3220G_EVAL_SRC_STM3220G_H */ - diff --git a/configs/stm3220g-eval/src/stm32_appinit.c b/configs/stm3220g-eval/src/stm32_appinit.c index 447bb24f3d219694ce2be8d5fda3463781cd2bb7..4800fca07077892d4493ef5db5ea615c6c3f0be6 100644 --- a/configs/stm3220g-eval/src/stm32_appinit.c +++ b/configs/stm3220g-eval/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/stm3220g_eval/src/stm32_appinit.c * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -292,6 +292,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT_STMPE811 + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/stm3220g-eval/src/stm32_stmpe811.c b/configs/stm3220g-eval/src/stm32_stmpe811.c index ec79a318644e6d284b7aba6c123e8dfa247e7707..d0346d5cf2eacbb570897fe4c66bbb24407d3ace 100644 --- a/configs/stm3220g-eval/src/stm32_stmpe811.c +++ b/configs/stm3220g-eval/src/stm32_stmpe811.c @@ -146,7 +146,8 @@ struct stm32_stmpe811config_s /* IRQ/GPIO access callbacks. These operations all hidden behind callbacks * to isolate the STMPE811 driver from differences in GPIO - * interrupt handling by varying boards and MCUs.* so that contact and loss-of-contact events can be detected. + * interrupt handling by varying boards and MCUs.* so that contact and loss- + * of-contact events can be detected. * * attach - Attach the STMPE811 interrupt handler to the GPIO interrupt * enable - Enable or disable the GPIO interrupt @@ -264,16 +265,15 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: - * minor - The input device minor number + * minor - The input device minor number * * Returned Value: * Zero is returned on success. Otherwise, a negated errno value is @@ -281,7 +281,7 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { #ifndef CONFIG_STMPE811_TSC_DISABLE FAR struct i2c_master_s *dev; @@ -336,26 +336,5 @@ int board_tsc_setup(int minor) #endif } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen STMPE811 device yet */ -} - #endif /* CONFIG_INPUT_STMPE811 */ diff --git a/configs/stm3220g-eval/src/stm32_usb.c b/configs/stm3220g-eval/src/stm32_usb.c index 33809073c8430e9055bcff9f567bad1c6a19e35f..71474fa5ce13e41841c5ba6408bffdce389f0635 100644 --- a/configs/stm3220g-eval/src/stm32_usb.c +++ b/configs/stm3220g-eval/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -208,9 +209,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -271,11 +272,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/stm3240g-eval/knxwm/defconfig b/configs/stm3240g-eval/knxwm/defconfig index 8a33d10f5656d2a8a5d5bf259657b883db31b6a9..18f80a8e220cf003558f5ae35ff708e8a98340fc 100644 --- a/configs/stm3240g-eval/knxwm/defconfig +++ b/configs/stm3240g-eval/knxwm/defconfig @@ -13,9 +13,7 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARM_MPU=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y -CONFIG_BOARD_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=16717 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILD_PROTECTED=y CONFIG_CXX_NEWLONG=y CONFIG_DISABLE_POLL=y diff --git a/configs/stm3240g-eval/nxwm/defconfig b/configs/stm3240g-eval/nxwm/defconfig index a72b8984d487ea8b87bdf621ef70f6135f347ff7..6a277c9bd89e424d944a5d64749da32f64121b0e 100644 --- a/configs/stm3240g-eval/nxwm/defconfig +++ b/configs/stm3240g-eval/nxwm/defconfig @@ -15,7 +15,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=16717 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y CONFIG_FS_FAT=y diff --git a/configs/stm3240g-eval/src/stm3240g-eval.h b/configs/stm3240g-eval/src/stm3240g-eval.h index 8b98bf85d57055c90125ed8319b240d3e1c3ba73..71d997bbd389b9a21f999d8207bed0e4e3464c9a 100644 --- a/configs/stm3240g-eval/src/stm3240g-eval.h +++ b/configs/stm3240g-eval/src/stm3240g-eval.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/stm3240g_eval/src/stm3240g_eval.h * - * Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -266,6 +266,26 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif +/**************************************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen device. This + * function will register the driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to indicate the + * nature of the failure. + * + ****************************************************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************************************** * Name: stm32_led_initialize * diff --git a/configs/stm3240g-eval/src/stm32_appinit.c b/configs/stm3240g-eval/src/stm32_appinit.c index f3362bf01297ec6cc8a1f59fcee0cfa49cc6862d..1ae1aa76baf2c8afa40659f8ad6745405c048aa4 100644 --- a/configs/stm3240g-eval/src/stm32_appinit.c +++ b/configs/stm3240g-eval/src/stm32_appinit.c @@ -67,7 +67,7 @@ * arg - The boardctl() argument is passed to the board_app_initialize() * implementation without modification. The argument has no * meaning to NuttX; the meaning of the argument is a contract - * between the board-specific initalization logic and the + * between the board-specific initialization logic and the * matching application logic. The value cold be such things as a * mode enumeration value, a set of DIP switch switch settings, a * pointer to configuration data read from a file or serial FLASH, diff --git a/configs/stm3240g-eval/src/stm32_boot.c b/configs/stm3240g-eval/src/stm32_boot.c index 13f7591a40e77ddefda76d935eb96ed58ae4e6bc..2861a30b1d3658871faa0967275a025ecdeb78ef 100644 --- a/configs/stm3240g-eval/src/stm32_boot.c +++ b/configs/stm3240g-eval/src/stm32_boot.c @@ -45,139 +45,10 @@ #include "stm3240g-eval.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ -/* Configuration ********************************************************************/ -/* Should we initialize the NX server using nx_start? This is done for NxWidgets - * (CONFIG_NXWIDGETS=y) and if the NxWidget::CNxServer class expects the RTOS do the - * the NX initialization (CONFIG_NXWIDGET_SERVERINIT=n). This combination of - * settings is normally only used in the kernel build mode* (CONFIG_BUILD_PROTECTED) - * when NxWidgets is unable to initialize NX from user-space. - */ - -#undef HAVE_NXSTART - -#if defined(CONFIG_NXWIDGETS) && !defined(CONFIG_NXWIDGET_SERVERINIT) -# define HAVE_NXSTART -# include -#endif - -/* Should we initialize the touchscreen for the NxWM (CONFIG_NXWM=y)? This - * is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y), NxWM uses the - * touchscreen (CONFIG_NXWM_TOUCHSCREEN=y), and if we were asked to - * initialize the touchscreen for NxWM (NXWM_TOUCHSCREEN_DEVINIT=n). This - * combination of settings is normally only used in the kernel build mode - * (CONFIG_BUILD_PROTECTED) when NxWidgets is unable to initialize NX from - * user-space. - */ - -#undef HAVE_TCINIT - -#if defined(CONFIG_NXWM_TOUCHSCREEN) -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVNO) -# error CONFIG_NXWM_TOUCHSCREEN_DEVNO is not defined -# elif defined(CONFIG_INPUT_STMPE811) -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) -# define HAVE_TCINIT -# include -# endif -# else -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) && defined(CONFIG_BUILD_PROTECTED) -# error CONFIG_INPUT_STMPE811=y is needed -# endif -# endif -#endif - -/* Check if we will need to support the initialization kernel thread */ - -#undef HAVE_INITTHREAD - -#ifdef CONFIG_BOARD_INITIALIZE -# if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL) -# define HAVE_INITTHREAD 1 -# elif defined(HAVE_NXSTART) -# define HAVE_INITTHREAD 1 -# elif defined(HAVE_TCINIT) -# define HAVE_INITTHREAD 1 -# endif -#endif - -#ifdef HAVE_INITTHREAD -# include -# include -# include -# ifndef CONFIG_STM3240G_BOARDINIT_PRIO -# define CONFIG_STM3240G_BOARDINIT_PRIO 196 -# endif -# ifndef CONFIG_STM3240G_BOARDINIT_STACK -# define CONFIG_STM3240G_BOARDINIT_STACK 2048 -# endif -#endif - /************************************************************************************ * Private Functions ************************************************************************************/ -/************************************************************************************ - * Name: board_initthread - * - * Description: - * Board initialization kernel thread. This thread exists to support - * initialization when CONFIG_BOARD_INITIALIZE is defined. It is started by - * board_initialize() which runs on the IDLE thread. - * - * This function thread exists because some initialization steps may require - * waiting for events. Such waiting is not possible on the IDLE thread. - * - * Input Parameters: - * Standard task start-up parameters (none of which are used) - * - * Returned Value: - * Always returns EXIT_SUCCESS. - * - ************************************************************************************/ - -#ifdef HAVE_INITTHREAD -static int board_initthread(int argc, char *argv[]) -{ - int ret; - - /* Perform NSH initialization here instead of from the NSH. This - * alternative NSH initialization is necessary when NSH is ran in user-space - * but the initialization function must run in kernel space. - */ - - ret = stm32_bringup(); - if (ret < 0) - { - gerr("ERROR: stm32_bringup failed: %d\n", ret); - } - -#ifdef HAVE_NXSTART - /* Initialize the NX server */ - - ret = nx_start(); - if (ret < 0) - { - gerr("ERROR: nx_start failed: %d\n", ret); - } -#endif - -#ifdef HAVE_TCINIT - /* Initialize the touchscreen */ - - ret = board_tsc_setup(CONFIG_NXWM_TOUCHSCREEN_DEVNO); - if (ret < 0) - { - gerr("ERROR: board_tsc_setup failed: %d\n", ret); - } -#endif - - return EXIT_SUCCESS; -} -#endif - /************************************************************************************ * Public Functions ************************************************************************************/ @@ -215,7 +86,7 @@ void stm32_boardinitialize(void) /* Initialize USB if the 1) OTG FS controller is in the configuration and 2) * disabled, and 3) the weak function stm32_usbinitialize() has been brought * the weak function stm32_usbinitialize() has been brought into the build. - * Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also selected. + * Presumably either CONFIG_USBDEV or CONFIG_USBHOST is also selected. */ if (stm32_usbinitialize) @@ -247,17 +118,11 @@ void stm32_boardinitialize(void) #ifdef CONFIG_BOARD_INITIALIZE void board_initialize(void) { -#ifdef HAVE_INITTHREAD - pid_t server; - - /* Start the board initialization kernel thread */ + /* Perform the board initialization on the start-up thread. Some + * initializations may fail in this case due to the limited capability of + * the start-up thread. + */ - server = kthread_create("Board Init", CONFIG_STM3240G_BOARDINIT_PRIO, - CONFIG_STM3240G_BOARDINIT_STACK, board_initthread, - NULL); - ASSERT(server > 0); -#else (void)stm32_bringup(); -#endif } #endif diff --git a/configs/stm3240g-eval/src/stm32_bringup.c b/configs/stm3240g-eval/src/stm32_bringup.c index 3fcc402b22a9c2f271db91fee9e7970e2b0e3d6b..7f78ccb8f308c3e61d8fe43acaba7d98d1dbdd78 100644 --- a/configs/stm3240g-eval/src/stm32_bringup.c +++ b/configs/stm3240g-eval/src/stm32_bringup.c @@ -71,6 +71,10 @@ # include #endif +#ifdef CONFIG_INPUT_STMPE811 +# include +#endif + #include "stm32.h" #include "stm32_i2c.h" #include "stm3240g-eval.h" @@ -354,6 +358,18 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_INPUT_STMPE811 + /* Initialize the touchscreen. + * WARNING: stm32_tsc_setup() cannot be called from the IDLE thread. + */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/stm3240g-eval/src/stm32_stmpe811.c b/configs/stm3240g-eval/src/stm32_stmpe811.c index b1b8126c579bb7c1b67c6905cc14ddc62ecf603f..876b91d0d52ae98599e4ae995b2baec6c3c4669d 100644 --- a/configs/stm3240g-eval/src/stm32_stmpe811.c +++ b/configs/stm3240g-eval/src/stm32_stmpe811.c @@ -264,13 +264,12 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -281,7 +280,7 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { #ifndef CONFIG_STMPE811_TSC_DISABLE FAR struct i2c_master_s *dev; @@ -336,26 +335,5 @@ int board_tsc_setup(int minor) #endif } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen STMPE811 device yet */ -} - #endif /* CONFIG_INPUT_STMPE811 */ diff --git a/configs/stm3240g-eval/src/stm32_usb.c b/configs/stm3240g-eval/src/stm32_usb.c index 27846d9cf66c6297169fbd9a8d8f15f5d17bb318..eb1e60d951155376d994c7eaf72bd9f188f2a9bc 100644 --- a/configs/stm3240g-eval/src/stm32_usb.c +++ b/configs/stm3240g-eval/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -208,7 +209,7 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; @@ -271,11 +272,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/stm32butterfly2/src/stm32_boot.c b/configs/stm32butterfly2/src/stm32_boot.c index f42e7a7fd7f788d120d89e38cc0133e965ad8e35..928b558633f4dc4c288d812b56d5553f859440a8 100644 --- a/configs/stm32butterfly2/src/stm32_boot.c +++ b/configs/stm32butterfly2/src/stm32_boot.c @@ -66,7 +66,7 @@ void stm32_boardinitialize(void) * Description: * Initializes upper half drivers with board specific settings * - * Returned value: + * Returned Value: * 0 on sucess or errno value of failed init function. ****************************************************************************/ diff --git a/configs/stm32butterfly2/src/stm32_leds.c b/configs/stm32butterfly2/src/stm32_leds.c index dae6352fa7b7d79e0f641082e3bc84a473bd9e36..4fced6d597839887c4a5e89fa1afe57bed312749 100644 --- a/configs/stm32butterfly2/src/stm32_leds.c +++ b/configs/stm32butterfly2/src/stm32_leds.c @@ -130,7 +130,7 @@ void stm32_led_initialize(void) * Description: * Drives board leds when specific RTOS state led occurs. * - * Input parameters: + * Input Parameters: * led - This is actually an RTOS state not led number of anything like that ****************************************************************************/ @@ -173,7 +173,7 @@ void board_autoled_on(int led) * Description: * Drives board leds when specific RTOS state led ends * - * Input parameters: + * Input Parameters: * led - This is actually an RTOS state not led number of anything like that ****************************************************************************/ @@ -225,7 +225,7 @@ void board_userled_initialize(void) * Description: * Sets led to ledon state. * - * Input parameters: + * Input Parameters: * led - Led to be set, indexed from 0 * ledon - new state for the led. ****************************************************************************/ @@ -251,7 +251,7 @@ void board_userled(int led, bool ledon) * Description: * Sets whole ledset to given state. * - * Input parameters: + * Input Parameters: * ledset - Led bits to be set on or off ****************************************************************************/ diff --git a/configs/stm32f103-minimum/include/board.h b/configs/stm32f103-minimum/include/board.h index f71653a4478d0809e49c383e86e9c78a637abd39..6764eaa60ba336e48e7cff825de422932518297d 100644 --- a/configs/stm32f103-minimum/include/board.h +++ b/configs/stm32f103-minimum/include/board.h @@ -46,12 +46,6 @@ # include #endif -#ifdef __KERNEL__ -# include "stm32_rcc.h" -# include "stm32_sdio.h" -# include "stm32.h" -#endif - /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ diff --git a/configs/stm32f103-minimum/src/Makefile b/configs/stm32f103-minimum/src/Makefile index d2a4afcfbe23865a29f5b7c6aa4c806135b2aedd..755c4e6bb183516b8f13d58b8f23e720874950ce 100644 --- a/configs/stm32f103-minimum/src/Makefile +++ b/configs/stm32f103-minimum/src/Makefile @@ -65,10 +65,18 @@ ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif +ifeq ($(CONFIG_SENSORS_ZEROCROSS),y) + CSRCS += stm32_zerocross.c +endif + ifeq ($(CONFIG_LEDS_APA102),y) CSRCS += stm32_apa102.c endif +ifeq ($(CONFIG_SENSORS_BMP180),y) + CSRCS += stm32_bmp180.c +endif + ifeq ($(CONFIG_LM75_I2C),y) CSRCS += stm32_lm75.c endif @@ -107,6 +115,10 @@ ifeq ($(CONFIG_SENSORS_HCSR04),y) CSRCS += stm32_hcsr04.c endif +ifeq ($(CONFIG_SENSORS_MAX6675),y) + CSRCS += stm32_max6675.c +endif + ifeq ($(CONFIG_LCD_MAX7219),y) CSRCS += stm32_max7219.c endif @@ -115,6 +127,10 @@ ifeq ($(CONFIG_INPUT_NUNCHUCK),y) CSRCS += stm32_nunchuck.c endif +ifeq ($(CONFIG_LCD_SSD1306_I2C),y) +CSRCS += stm32_ssd1306.c +endif + ifeq ($(CONFIG_LCD_ST7567),y) CSRCS += stm32_lcd.c endif diff --git a/configs/stm32f103-minimum/src/stm32_apa102.c b/configs/stm32f103-minimum/src/stm32_apa102.c index 32717b212bd47ac5639734fb93f37fb8a95250bc..88c5a5ae49ffcbbd5c17120b68ce39cad69cc625 100644 --- a/configs/stm32f103-minimum/src/stm32_apa102.c +++ b/configs/stm32f103-minimum/src/stm32_apa102.c @@ -68,7 +68,7 @@ * Description: * Initialize and register the APA102 LED Strip driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/leddrv0" * * Returned Value: diff --git a/configs/stm32f103-minimum/src/stm32_apds9960.c b/configs/stm32f103-minimum/src/stm32_apds9960.c index 14045df518d848224add9fc8b6e633b8cb345578..614cbcf45db5c9d25804ed55703a3b0e41fd65cd 100644 --- a/configs/stm32f103-minimum/src/stm32_apds9960.c +++ b/configs/stm32f103-minimum/src/stm32_apds9960.c @@ -136,7 +136,7 @@ static int apds9960_irq_attach(FAR struct apds9960_config_s *state, xcpt_t isr, * Description: * Initialize and register the APDS9960 gesture sensor. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/gest0" * * Returned Value: diff --git a/configs/stm32f103-minimum/src/stm32_bmp180.c b/configs/stm32f103-minimum/src/stm32_bmp180.c new file mode 100644 index 0000000000000000000000000000000000000000..fc5e9964e726e856ef6e91745c4c560c68c98373 --- /dev/null +++ b/configs/stm32f103-minimum/src/stm32_bmp180.c @@ -0,0 +1,105 @@ +/************************************************************************************ + * configs/stm32f103-minimum/src/stm32_bmp180.c + * + * Copyright (C) 2018 Alan Carvalho de Assis. All rights reserved. + * Author: Alan Carvalho de Assis + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "stm32.h" +#include "stm32_i2c.h" +#include "stm32f103_minimum.h" + +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#define MPL115A_I2C_PORTNO 1 /* On I2C1 */ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_bmp180initialize + * + * Description: + * Initialize and register the MPL115A Pressure Sensor driver. + * + * Input parameters: + * devpath - The full path to the driver to register. E.g., "/dev/press0" + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ************************************************************************************/ + +int stm32_bmp180initialize(FAR const char *devpath) +{ + FAR struct i2c_master_s *i2c; + int ret; + + sninfo("Initializing BMP180!\n"); + + /* Initialize I2C */ + + i2c = stm32_i2cbus_initialize(BMP180_I2C_PORTNO); + + if (!i2c) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = bmp180_register(devpath, i2c); + if (ret < 0) + { + snerr("ERROR: Error registering BM180\n"); + } + + return ret; +} + +#endif /* CONFIG_I2C && CONFIG_SENSORS_MPL115A && CONFIG_STM32_I2C1 */ diff --git a/configs/stm32f103-minimum/src/stm32_bringup.c b/configs/stm32f103-minimum/src/stm32_bringup.c index dec8bea5e1a8157b987ab81c6e0546b51ccf03f1..e751211aeed209643006cc4b8c4760aaef3f38b9 100644 --- a/configs/stm32f103-minimum/src/stm32_bringup.c +++ b/configs/stm32f103-minimum/src/stm32_bringup.c @@ -167,6 +167,17 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_SENSORS_ZEROCROSS + /* Configure the zero-crossing driver */ + + ret = stm32_zerocross_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize Zero-Cross, error %d\n", ret); + return ret; + } +#endif + #ifdef CONFIG_MMCSD ret = stm32_mmcsd_initialize(MMCSD_MINOR); if (ret < 0) @@ -176,6 +187,15 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_SENSORS_BMP180 + ret = stm32_bmp180initialize("/dev/press0"); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize BMP180, error %d\n", ret); + return ret; + } +#endif + #ifdef HAVE_W25 /* Initialize and register the W25 FLASH file system. */ @@ -259,6 +279,14 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_SENSORS_MAX6675 + ret = stm32_max6675initialize("/dev/temp0"); + if (ret < 0) + { + serr("ERROR: stm32_max6675initialize failed: %d\n", ret); + } +#endif + #ifdef CONFIG_CAN_MCP2515 /* Configure and initialize the MCP2515 CAN device */ diff --git a/configs/stm32f103-minimum/src/stm32_buttons.c b/configs/stm32f103-minimum/src/stm32_buttons.c index 154f24225e83a028f97d1fe4f823ff4348325ba6..b22347c0039b4fbef671db79d7cc431ff5f49c21 100644 --- a/configs/stm32f103-minimum/src/stm32_buttons.c +++ b/configs/stm32f103-minimum/src/stm32_buttons.c @@ -46,6 +46,7 @@ #include #include +#include "stm32_gpio.h" #include "stm32f103_minimum.h" #if defined(CONFIG_ARCH_BUTTONS) diff --git a/configs/stm32f103-minimum/src/stm32_lm75.c b/configs/stm32f103-minimum/src/stm32_lm75.c index 7cd9b2422ee5ebe4aab431a4332bf71c11ce1d00..75e193354fac6eb0d064733a429bdda945a16b3f 100644 --- a/configs/stm32f103-minimum/src/stm32_lm75.c +++ b/configs/stm32f103-minimum/src/stm32_lm75.c @@ -60,7 +60,7 @@ * Description: * Initialize and register the LM-75 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: @@ -104,7 +104,7 @@ int stm32_lm75initialize(FAR const char *devpath) * Description: * Attach the LM-75 interrupt handler * - * Input parameters: + * Input Parameters: * irqhandler - the LM-75 interrupt handler * arg - The argument that will accompany the interrupt * diff --git a/configs/stm32f103-minimum/src/stm32_max6675.c b/configs/stm32f103-minimum/src/stm32_max6675.c new file mode 100644 index 0000000000000000000000000000000000000000..2f3b1c9018322e8f14f5e7b656a0a5cd479d4882 --- /dev/null +++ b/configs/stm32f103-minimum/src/stm32_max6675.c @@ -0,0 +1,102 @@ +/************************************************************************************ + * configs/stm32f4discovery/src/stm32_max6675.c + * + * Copyright (C) 2018 Alan Carvalho de Assis. All rights reserved. + * Author: Alan Carvalho de Assis + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "stm32.h" +#include "stm32_spi.h" +#include "stm32f103_minimum.h" + +#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MAX6675) && defined(CONFIG_STM32_SPI1) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#define MAX6675_SPI_PORTNO 1 /* On SPI1 */ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_max6675initialize + * + * Description: + * Initialize and register the MAX6675 Temperature Sensor driver. + * + * Input Parameters: + * devpath - The full path to the driver to register. E.g., "/dev/temp0" + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ************************************************************************************/ + +int stm32_max6675initialize(FAR const char *devpath) +{ + FAR struct spi_dev_s *spi; + int ret; + + spi = stm32_spibus_initialize(MAX6675_SPI_PORTNO); + + if (!spi) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = max6675_register(devpath, spi); + if (ret < 0) + { + snerr("ERROR: Error registering MAX6675\n"); + } + + return ret; +} + +#endif /* CONFIG_SPI && CONFIG_SENSORS_MAX6675 */ + diff --git a/configs/stm32f103-minimum/src/stm32_mcp2515.c b/configs/stm32f103-minimum/src/stm32_mcp2515.c index 739cfe884a93c3ea2246d428931270cd035a60c3..a7794603fd1c9c18a97f79d925912777c971acf1 100644 --- a/configs/stm32f103-minimum/src/stm32_mcp2515.c +++ b/configs/stm32f103-minimum/src/stm32_mcp2515.c @@ -173,7 +173,7 @@ static int mcp2515_attach(FAR struct mcp2515_config_s *state, * Description: * Initialize and register the MCP2515 RFID driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/rfid0" * * Returned Value: diff --git a/configs/stm32f103-minimum/src/stm32_mfrc522.c b/configs/stm32f103-minimum/src/stm32_mfrc522.c index 441bc5a6fa204122c426e7fb91610e6800371611..5fc1db4b4b178f6f985eb44bfd664e828105716c 100644 --- a/configs/stm32f103-minimum/src/stm32_mfrc522.c +++ b/configs/stm32f103-minimum/src/stm32_mfrc522.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the MFRC522 RFID driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/rfid0" * * Returned Value: diff --git a/configs/stm32f103-minimum/src/stm32_nrf24l01.c b/configs/stm32f103-minimum/src/stm32_nrf24l01.c index 6edecba0e010b5ebb99eba7f3fcf77de075a3c9c..34bf775091dd9a5429837f3a2f52bb9f82fac861 100644 --- a/configs/stm32f103-minimum/src/stm32_nrf24l01.c +++ b/configs/stm32f103-minimum/src/stm32_nrf24l01.c @@ -105,7 +105,7 @@ static void stm32tiny_wl_chip_enable(bool enable) * Description: * Initialize the NRF24L01 wireless module * - * Input Parmeters: + * Input Parameters: * None * * Returned Value: diff --git a/configs/stm32f103-minimum/src/stm32_pwm.c b/configs/stm32f103-minimum/src/stm32_pwm.c index dec2597991d3dfd2dd0c8fdde23d50f5af04f616..eac41ab675eb1ca3ec417e7bda9f6fa8f17720b4 100644 --- a/configs/stm32f103-minimum/src/stm32_pwm.c +++ b/configs/stm32f103-minimum/src/stm32_pwm.c @@ -1,7 +1,7 @@ /************************************************************************************ * configs/stm32f103-minimum/src/stm32_pwm.c * - * Copyright (C) 2013, 2015, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2015, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Alan Carvalho de Assis * @@ -40,6 +40,7 @@ #include +#include #include #include diff --git a/configs/stm32f103-minimum/src/stm32_rgbled.c b/configs/stm32f103-minimum/src/stm32_rgbled.c index 21b7a0b78c98d25e8df57f11c051cfcdffc3052a..024772a20ef73affe0690fe4115c01a89dd3dc20 100644 --- a/configs/stm32f103-minimum/src/stm32_rgbled.c +++ b/configs/stm32f103-minimum/src/stm32_rgbled.c @@ -1,7 +1,7 @@ /************************************************************************************ * configs/stm32f4discovery/src/stm32_rgbled.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Alan Carvalho de Assis * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include +#include #include #include diff --git a/configs/stm32f103-minimum/src/stm32_spi.c b/configs/stm32f103-minimum/src/stm32_spi.c index 2ae29c9e95b06fddc5a09441082f431bee7b2264..a0ff5d7ee6223d9959c5887286dda71331991034 100644 --- a/configs/stm32f103-minimum/src/stm32_spi.c +++ b/configs/stm32f103-minimum/src/stm32_spi.c @@ -86,6 +86,10 @@ void stm32_spidev_initialize(void) (void)stm32_configgpio(GPIO_CS_MFRC522); /* MFRC522 chip select */ #endif +#if defined(CONFIG_SENSORS_MAX6675) + (void)stm32_configgpio(GPIO_MAX6675_CS); /* MAX6675 chip select */ +#endif + #ifdef CONFIG_LCD_MAX7219 (void)stm32_configgpio(STM32_LCD_CS); /* MAX7219 chip select */ #endif @@ -150,6 +154,13 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, } #endif +#if defined(CONFIG_SENSORS_MAX6675) + if (devid == SPIDEV_TEMPERATURE(0)) + { + stm32_gpiowrite(GPIO_MAX6675_CS, !selected); + } +#endif + #ifdef CONFIG_LCD_MAX7219 if (devid == SPIDEV_DISPLAY(0)) { diff --git a/configs/stm32f103-minimum/src/stm32_ssd1306.c b/configs/stm32f103-minimum/src/stm32_ssd1306.c new file mode 100644 index 0000000000000000000000000000000000000000..0bd49bf03a7e71ac5c1b436859f62cc6746355d0 --- /dev/null +++ b/configs/stm32f103-minimum/src/stm32_ssd1306.c @@ -0,0 +1,130 @@ +/**************************************************************************** + * config/stm32f103-minimum/src/sam_ug2832hsweg04.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include + +#include "stm32.h" +#include "stm32_i2c.h" +#include "stm32f103_minimum.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifndef CONFIG_LCD_SSD1306 +# error "The OLED driver requires CONFIG_LCD_SSD1306 in the configuration" +#endif + +#ifndef CONFIG_LCD_MAXPOWER +# define CONFIG_LCD_MAXPOWER 1 +#endif + +#define OLED_I2C_PORT 1 /* OLED display connected to I2C1 */ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +FAR struct i2c_master_s *g_i2c; +FAR struct lcd_dev_s *g_lcddev; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + /* Initialize I2C */ + + g_i2c = stm32_i2cbus_initialize(OLED_I2C_PORT); + if (!g_i2c) + { + lcderr("ERROR: Failed to initialize I2C port %d\n", OLED_I2C_PORT); + return 0; + } + + return 1; +} + +/**************************************************************************** + * Name: board_lcd_getdev + ****************************************************************************/ + +FAR struct lcd_dev_s *board_lcd_getdev(int devno) +{ + /* Bind the I2C port to the OLED */ + + g_lcddev = ssd1306_initialize(g_i2c, NULL, devno); + if (!g_lcddev) + { + lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); + } + else + { + lcdinfo("Bound I2C port %d to OLED %d\n", OLED_I2C_PORT, devno); + + /* And turn the OLED on */ + + (void)g_lcddev->setpower(g_lcddev, CONFIG_LCD_MAXPOWER); + return g_lcddev; + } + + return NULL; +} + +/**************************************************************************** + * Name: board_lcd_uninitialize + ****************************************************************************/ + +void board_lcd_uninitialize(void) +{ + /* TO-FIX */ +} diff --git a/configs/stm32f103-minimum/src/stm32_veml6070.c b/configs/stm32f103-minimum/src/stm32_veml6070.c index 5e8765e9e713073940a85f1e8b3a3cb176f6ccc2..8a84517f2f7f2081c2abc01a55e5d23bec8ffe42 100644 --- a/configs/stm32f103-minimum/src/stm32_veml6070.c +++ b/configs/stm32f103-minimum/src/stm32_veml6070.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the VEML6070 UV-A Light sensor. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/uvlight0" * * Returned Value: diff --git a/configs/stm32f103-minimum/src/stm32_zerocross.c b/configs/stm32f103-minimum/src/stm32_zerocross.c new file mode 100644 index 0000000000000000000000000000000000000000..da6fda354e258bff600669cd74d93e4dc3b1f8f6 --- /dev/null +++ b/configs/stm32f103-minimum/src/stm32_zerocross.c @@ -0,0 +1,194 @@ +/**************************************************************************** + * configs/stm32f4discovery/src/stm32_zerocross.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include "stm32_gpio.h" +#include "stm32f103_minimum.h" + +#ifdef CONFIG_SENSORS_ZEROCROSS + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void zcross_enable(FAR const struct zc_lowerhalf_s *lower, + zc_interrupt_t handler, FAR void *arg); + +static void zcross_disable(void); +static int zcross_interrupt(int irq, FAR void *context, FAR void *arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Current interrupt handler and argument */ + +static zc_interrupt_t g_zcrosshandler; +static FAR void *g_zcrossarg; + +/* This is the zero cross lower half driver interface */ + +static struct zc_lowerhalf_s g_zcrosslower = +{ + .zc_enable = zcross_enable, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: zcross_enable + * + * Description: + * Enable interrupts on the selected zero cross pin. And empty + * set will disable all interrupts. + * + ****************************************************************************/ + +static void zcross_enable(FAR const struct zc_lowerhalf_s *lower, + zc_interrupt_t handler, FAR void *arg) +{ + irqstate_t flags; + bool rising = false; + bool falling = true; + + /* Start with all interrupts disabled */ + + flags = enter_critical_section(); + zcross_disable(); + + sninfo("handler: %p arg: %p\n", handler, arg); + + if (handler) + { + g_zcrosshandler = handler; + g_zcrossarg = arg; + } + + (void)stm32_gpiosetevent(GPIO_ZEROCROSS, rising, falling, + true, zcross_interrupt, NULL); + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: zcross_disable + * + * Description: + * Disable all joystick interrupts + * + ****************************************************************************/ + +static void zcross_disable(void) +{ + irqstate_t flags; + + /* Disable zero cross pin interrupt */ + + flags = enter_critical_section(); + + (void)stm32_gpiosetevent(GPIO_ZEROCROSS, false, false, false, NULL, NULL); + + leave_critical_section(flags); + + /* Nullify the handler and argument */ + + g_zcrosshandler = NULL; + g_zcrossarg = NULL; +} + +/**************************************************************************** + * Name: zcross_interrupt + * + * Description: + * Zero Cross interrupt handler + * + ****************************************************************************/ + +static int zcross_interrupt(int irq, FAR void *context, FAR void *arg) +{ + DEBUGASSERT(g_zcrosshandler != NULL); + if (g_zcrosshandler) + { + g_zcrosshandler(&g_zcrosslower, g_zcrossarg); + } + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_zerocross_initialize + * + * Description: + * Initialize and register the zero cross driver + * + ****************************************************************************/ + +int stm32_zerocross_initialize(void) +{ + /* Configure the GPIO pin as input. NOTE: This is unnecessary for + * interrupting pins since it will also be done by stm32_gpiosetevent(). + */ + + stm32_configgpio(GPIO_ZEROCROSS); + + /* Make sure that all interrupts are disabled */ + + zcross_disable(); + + /* Register the zero cross device as /dev/zc0 */ + + return zc_register("/dev/zc0", &g_zcrosslower); +} + +#endif /* CONFIG_SENSORS_ZEROCROSS */ + diff --git a/configs/stm32f103-minimum/src/stm32f103_minimum.h b/configs/stm32f103-minimum/src/stm32f103_minimum.h index f3159c7eacee0825be1354f17da754eb70a15294..8355bae9c15b8796ff4508ccb0d212c5b59c9cd0 100644 --- a/configs/stm32f103-minimum/src/stm32f103_minimum.h +++ b/configs/stm32f103-minimum/src/stm32f103_minimum.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/stm32f103-minimum/src/stm32f103_minimum.h * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Laurent Latil * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,12 @@ #include #include +#include + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + #define HAVE_AT24 1 /* AT24 Serial EEPROM */ @@ -77,10 +83,6 @@ # undef HAVE_AT24 #endif -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - /* How many SPI modules does this chip support? The LM3S6918 supports 2 SPI * modules (others may support more -- in such case, the following must be * expanded). @@ -110,6 +112,10 @@ #define MAX_IRQBUTTON BUTTON_USER2 #define NUM_IRQBUTTONS (BUTTON_USER1 - BUTTON_USER2 + 1) +/* ZERO CROSS pin definiton */ + +#define GPIO_ZEROCROSS (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_PORTA|GPIO_PIN0) + /* Pins config to use with HC-SR04 sensor */ #define GPIO_HCSR04_INT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_PORTA|GPIO_PIN0) @@ -131,6 +137,9 @@ #define STM32_LCD_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\ GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) +#define GPIO_MAX6675_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) + #define GPIO_MCP2515_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\ GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) @@ -228,6 +237,18 @@ int stm32_bringup(void); int stm32_gpio_initialize(void); #endif +/**************************************************************************** + * Name: stm32_zerocross_initialize + * + * Description: + * Initialize and register the zero cross driver + * + ****************************************************************************/ + +#ifdef CONFIG_SENSORS_ZEROCROSS +int stm32_zerocross_initialize(void); +#endif + /************************************************************************************ * Name: stm32_adc_setup * @@ -252,6 +273,19 @@ int stm32_adc_setup(void); int stm32_apds9960initialize(FAR const char *devpath); #endif +/**************************************************************************** + * Name: stm32_bmp180initialize + * + * Description: + * Called to configure an I2C and to register BMP180 for the stm32f4discovery + * board. + * + ****************************************************************************/ + +#ifdef CONFIG_SENSORS_BMP180 +int stm32_bmp180initialize(FAR const char *devpath); +#endif + /************************************************************************************ * Name: stm32_spidev_initialize * @@ -308,6 +342,18 @@ int stm32_hcsr04_initialize(FAR const char *devname); int stm32_lm75initialize(FAR const char *devpath); #endif +/************************************************************************************ + * Name: stm32_max6675initialize + * + * Description: + * Called to initialize MAX6675 temperature sensor + * + ************************************************************************************/ + +#ifdef CONFIG_SENSORS_MAX6675 +int stm32_max6675initialize(FAR const char *devpath); +#endif + /************************************************************************************ * Name: stm32_w25initialize * @@ -331,7 +377,7 @@ int stm32_qencoder_initialize(FAR const char *devpath, int timer); #endif /**************************************************************************** - * Name stm32_rgbled_setup + * Name: stm32_rgbled_setup * * Description: * This function is called by board initialization logic to configure the @@ -402,7 +448,7 @@ int stm32_pwm_setup(void); * Description: * Initialize the NRF24L01 wireless module * - * Input Parmeters: + * Input Parameters: * None * * Returned Value: diff --git a/configs/stm32f334-disco/include/board.h b/configs/stm32f334-disco/include/board.h index 115b02abd482c03970a6a6536a2ab05733ed9ecc..c138e01cabfc62998ca1a2512cca63ea7f0e6ddd 100644 --- a/configs/stm32f334-disco/include/board.h +++ b/configs/stm32f334-disco/include/board.h @@ -277,12 +277,42 @@ /* HRTIM configuration ******************************************************/ -#define HRTIM_TIMA_PRESCALER HRTIM_PRESCALER_32 +/* Timer A configuration - Buck operations */ + +#define HRTIM_TIMA_PRESCALER HRTIM_PRESCALER_1 #define HRTIM_TIMA_MODE HRTIM_MODE_CONT -#define HRTIM_TIMB_PRESCALER HRTIM_PRESCALER_32 +#define HRTIM_TIMA_CH1_SET HRTIM_OUT_SET_NONE +#define HRTIM_TIMA_CH1_RST HRTIM_OUT_RST_NONE +#define HRTIM_TIMA_CH2_SET HRTIM_OUT_SET_NONE +#define HRTIM_TIMA_CH2_RST HRTIM_OUT_RST_NONE + +#define HRTIM_TIMA_DT_FSLOCK HRTIM_DT_LOCK +#define HRTIM_TIMA_DT_RSLOCK HRTIM_DT_LOCK +#define HRTIM_TIMA_DT_FVLOCK HRTIM_DT_RW +#define HRTIM_TIMA_DT_RVLOCK HRTIM_DT_RW +#define HRTIM_TIMA_DT_FSIGN HRTIM_DT_SIGN_POSITIVE +#define HRTIM_TIMA_DT_RSIGN HRTIM_DT_SIGN_POSITIVE +#define HRTIM_TIMA_DT_PRESCALER HRTIM_DEADTIME_PRESCALER_1 + +/* Timer B configuration - Boost operations */ + +#define HRTIM_TIMB_PRESCALER HRTIM_PRESCALER_1 #define HRTIM_TIMB_MODE HRTIM_MODE_CONT +#define HRTIM_TIMB_CH1_SET HRTIM_OUT_SET_NONE +#define HRTIM_TIMB_CH1_RST HRTIM_OUT_RST_NONE +#define HRTIM_TIMB_CH2_SET HRTIM_OUT_SET_NONE +#define HRTIM_TIMB_CH2_RST HRTIM_OUT_RST_NONE + +#define HRTIM_TIMB_DT_FSLOCK HRTIM_DT_LOCK +#define HRTIM_TIMB_DT_RSLOCK HRTIM_DT_LOCK +#define HRTIM_TIMB_DT_FVLOCK HRTIM_DT_RW +#define HRTIM_TIMB_DT_RVLOCK HRTIM_DT_RW +#define HRTIM_TIMB_DT_FSIGN HRTIM_DT_SIGN_POSITIVE +#define HRTIM_TIMB_DT_RSIGN HRTIM_DT_SIGN_POSITIVE +#define HRTIM_TIMB_DT_PRESCALER HRTIM_DEADTIME_PRESCALER_1 + #define HRTIM_ADC_TRG2 HRTIM_ADCTRG24_AC4 /* DMA channels *************************************************************/ diff --git a/configs/stm32f334-disco/src/stm32_smps.c b/configs/stm32f334-disco/src/stm32_smps.c index 952af64c1b15ba5220127084a893d539122e7727..12f85667b1abda70e5680db6200a196f1850ec0c 100644 --- a/configs/stm32f334-disco/src/stm32_smps.c +++ b/configs/stm32f334-disco/src/stm32_smps.c @@ -105,8 +105,8 @@ /* ADC1 injected channels numeration */ -#define VIN_ADC_INJ_CHANNEL 0 -#define VOUT_ADC_INJ_CHANNEL 1 +#define V_IN_ADC_INJ_CHANNEL 0 +#define V_OUT_ADC_INJ_CHANNEL 1 /* Voltage reference for ADC */ @@ -118,11 +118,11 @@ /* Input voltage convertion ratio - 6.8k/(6.8k + 27k) */ -#define VIN_RATIO (float)((float)(6800+27000)/(float)6800) +#define V_IN_RATIO (float)((float)(6800+27000)/(float)6800) /* Output voltage convertion ratio - 3.3k/(3.3k + 13.3k) */ -#define VOUT_RATIO (float)((float)(3300+13300)/(float)3300) +#define V_OUT_RATIO (float)((float)(3300+13300)/(float)3300) /* Some absolute limits */ @@ -130,6 +130,61 @@ #define SMPS_ABSOLUTE_OUT_VOLTAGE_LIMIT_mV 15000 #define SMPS_ABSOLUTE_IN_VOLTAGE_LIMIT_mV 15000 +#if CONFIG_EXAMPLES_SMPS_OUT_CURRENT_LIMIT > SMPS_ABSOLUTE_OUT_CURRENT_LIMIT_mA +# error "Output current limit great than absolute limit!" +#endif +#if CONFIG_EXAMPLES_SMPS_OUT_VOLTAGE_LIMIT > SMPS_ABSOLUTE_OUT_VOLTAGE_LIMIT_mV +# error "Output voltage limit greater than absolute limit!" +#endif +#if CONFIG_EXAMPLES_SMPS_IN_VOLTAGE_LIMIT > SMPS_ABSOLUTE_IN_VOLTAGE_LIMIT_mV +# error "Input voltage limit greater than absolute limit!" +#endif + +/* Maximum output voltage for boost conveter in float */ + +#define BOOST_VOLT_MAX ((float)CONFIG_EXAMPLES_SMPS_OUT_VOLTAGE_LIMIT/1000.0) + +/* Current limit table dimmension */ + +#define SMPS_CURRENT_LIMIT_TAB_DIM 15 + +/* At this time only PID controller implemented */ + +#define SMPS_CONTROLLER_PID 1 + +/* Converter's finite accuracy */ + +#define SMPS_VOLTAGE_ACCURACY ((float)0.01) + +/* Buck-boost mode threshold */ + +#define SMPS_BUCKBOOST_RANGE ((float)0.5) + +/* PID controller configuration */ + +#define PID_KP ((float)1.0) +#define PID_KI ((float)0.1) +#define PID_KD ((float)0.0) + +/* Converter frequncies: + * - TIMA_PWM_FREQ - buck converter 250kHz + * - TIMB_PWM_FREQ - boost converter 250kHz + */ + +#define TIMA_PWM_FREQ 250000 +#define TIMB_PWM_FREQ 250000 + +/* Deadtime configuration */ + +#define DT_RISING 0x0A0 +#define DT_FALLING 0x0A0 + +/* Helper macros */ + +#define HRTIM_ALL_OUTPUTS_ENABLE(hrtim, state) \ + HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMA_CH1|HRTIM_OUT_TIMA_CH2| \ + HRTIM_OUT_TIMB_CH1|HRTIM_OUT_TIMB_CH2, state); + /**************************************************************************** * Private Types ****************************************************************************/ @@ -138,6 +193,7 @@ enum converter_mode_e { + CONVERTER_MODE_INIT, /* Initial mode */ CONVERTER_MODE_BUCK, /* Buck mode operations (V_in > V_out) */ CONVERTER_MODE_BOOST, /* Boost mode operations (V_in < V_out) */ CONVERTER_MODE_BUCKBOOST, /* Buck-boost operations (V_in near V_out)*/ @@ -159,11 +215,13 @@ struct smps_lower_dev_s struct smps_priv_s { uint8_t conv_mode; /* Converter mode */ - uint16_t vin_raw; /* Voltage input RAW value */ - uint16_t vout_raw; /* Voltage output RAW value */ - float vin; /* Voltage input real value in V */ - float vout; /* Voltage output real value in V */ + uint16_t v_in_raw; /* Voltage input RAW value */ + uint16_t v_out_raw; /* Voltage output RAW value */ + float v_in; /* Voltage input real value in V */ + float v_out; /* Voltage output real value in V */ bool running; /* Running flag */ + float state[3]; /* Controller state vartiables */ + float *c_limit_tab; /* Current limit tab */ }; /**************************************************************************** @@ -215,8 +273,9 @@ struct smps_ops_s g_smps_ops = struct smps_dev_s g_smps_dev = { - .ops = &g_smps_ops, - .priv = &g_smps + .ops = &g_smps_ops, + .priv = &g_smps, + .lower = NULL }; /* ADC configuration: @@ -232,16 +291,16 @@ struct smps_dev_s g_smps_dev = * Transistors configuration in boost mode: * - T4 - ON * - T11 - OFF - * - T5 and T15 - boost operation + * - T5 and T12 - boost operation * Transistors configuration in buck-boost mode: * - T4, T11 - buck operation - * - T5 and T15 - boost operation + * - T5 and T12 - boost operation * * HRTIM outputs configuration: * - T4 -> PA8 -> HRTIM_CHA1 * - T5 -> PA11 -> HRTIM_CHB2 * - T11 -> PA9 -> HRTIM_CHA2 - * - T15 -> PA10 -> HRTIM_CHB1 + * - T12 -> PA10 -> HRTIM_CHB1 * */ @@ -257,8 +316,8 @@ static const uint8_t g_adc1chan[ADC1_NCHANNELS] = static const uint32_t g_adc1pins[ADC1_NCHANNELS] = { - GPIO_ADC1_IN2, /* PA1 - VIN */ - GPIO_ADC1_IN4, /* PA3 - VOUT */ + GPIO_ADC1_IN2, /* PA1 - V_IN */ + GPIO_ADC1_IN4, /* PA3 - V_OUT */ }; /**************************************************************************** @@ -290,7 +349,7 @@ static int smps_shutdown(FAR struct smps_dev_s *dev) * Description: * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ @@ -300,6 +359,7 @@ static int smps_setup(FAR struct smps_dev_s *dev) FAR struct smps_s *smps = (FAR struct smps_s *)dev->priv; FAR struct hrtim_dev_s *hrtim = NULL; FAR struct adc_dev_s *adc = NULL; + FAR struct smps_priv_s *priv; /* Initialize smps structure */ @@ -321,6 +381,8 @@ static int smps_setup(FAR struct smps_dev_s *dev) printf("ERROR: failed to get ADC lower level interface"); } + /* TODO: create current limit table */ + errout: return OK; } @@ -331,28 +393,89 @@ static int smps_start(FAR struct smps_dev_s *dev) FAR struct stm32_adc_dev_s *stm32_adc = (FAR struct stm32_adc_dev_s *) lower->adc->ad_priv; FAR struct smps_s *smps = (FAR struct smps_s *)dev->priv; + FAR struct smps_priv_s *priv = (struct smps_priv_s *)smps->priv; FAR struct hrtim_dev_s *hrtim = lower->hrtim; + volatile uint64_t per = 0; + uint64_t fclk = 0; + int ret = OK; - /* Stop HRTIM PWM */ + /* Disable HRTIM outputs */ - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMA_CH1, false); - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMA_CH2, false); + HRTIM_ALL_OUTPUTS_ENABLE(hrtim, false); - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMB_CH1, false); - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMB_CH2, false); + /* Reset SMPS private structure */ - /* 1 period is 4us - 100% time */ + memset(priv, 0, sizeof(struct smps_priv_s)); - HRTIM_PER_SET(hrtim, HRTIM_TIMER_TIMA, 18432); - HRTIM_PER_SET(hrtim, HRTIM_TIMER_TIMB, 18432); + /* Get TIMA period value for given frequency */ + + fclk = HRTIM_FCLK_GET(hrtim, HRTIM_TIMER_TIMA); + per = fclk/TIMA_PWM_FREQ; + if (per > HRTIM_PER_MAX) + { + printf("ERROR: can not achieve tima pwm freq=%u if fclk=%llu\n", + (uint32_t)TIMA_PWM_FREQ, (uint64_t)fclk); + ret = -EINVAL; + goto errout; + } + + /* Set TIMA period value */ + + HRTIM_PER_SET(hrtim, HRTIM_TIMER_TIMA, (uint16_t)per); + + /* Get TIMB period value for given frequency */ + + fclk = HRTIM_FCLK_GET(hrtim, HRTIM_TIMER_TIMB); + per = fclk/TIMB_PWM_FREQ; + if (per > HRTIM_PER_MAX) + { + printf("ERROR: can not achieve timb pwm freq=%u if fclk=%llu\n", + (uint32_t)TIMB_PWM_FREQ, (uint64_t)fclk); + ret = -EINVAL; + goto errout; + } + + /* Set TIMB period value */ + + HRTIM_PER_SET(hrtim, HRTIM_TIMER_TIMB, (uint16_t)per); /* ADC trigger on TIMA CMP4 */ HRTIM_CMP_SET(hrtim, HRTIM_TIMER_TIMA, HRTIM_CMP4, 10000); + /* Configure TIMER A and TIMER B deadtime mode + * + * NOTE: In deadtime mode we have to configure output 1 only (SETx1, RSTx1), + * output 2 configuration is not significant. + */ + + HRTIM_DEADTIME_UPDATE(hrtim, HRTIM_TIMER_TIMA, HRTIM_DT_EDGE_RISING, DT_RISING); + HRTIM_DEADTIME_UPDATE(hrtim, HRTIM_TIMER_TIMA, HRTIM_DT_EDGE_FALLING, DT_FALLING); + HRTIM_DEADTIME_UPDATE(hrtim, HRTIM_TIMER_TIMB, HRTIM_DT_EDGE_RISING, DT_RISING); + HRTIM_DEADTIME_UPDATE(hrtim, HRTIM_TIMER_TIMB, HRTIM_DT_EDGE_FALLING, DT_FALLING); + + /* Set T4 and T12 to a low state. + * Deadtime mode force T11 and T5 to a high state. + */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_SET_NONE); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_RST_PER); + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_SET_NONE); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_RST_PER); + + /* Set running flag */ + + priv->running = true; + + HRTIM_ALL_OUTPUTS_ENABLE(hrtim, true); + /* Enable ADC interrupts */ stm32_adc->ops->int_en(stm32_adc, ADC_INT_JEOS); + +errout: + return ret; } static int smps_stop(FAR struct smps_dev_s *dev) @@ -366,11 +489,7 @@ static int smps_stop(FAR struct smps_dev_s *dev) /* Disable HRTIM outputs */ - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMA_CH1, false); - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMA_CH2, false); - - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMB_CH1, false); - HRTIM_OUTPUTS_ENABLE(hrtim, HRTIM_OUT_TIMB_CH2, false); + HRTIM_ALL_OUTPUTS_ENABLE(hrtim, false); /* Disable ADC interrupts */ @@ -459,27 +578,27 @@ static int smps_limits_set(FAR struct smps_dev_s *dev, goto errout; } - if (limits->v_out * 1000 > SMPS_ABSOLUTE_OUT_VOLTAGE_LIMIT_mV) + if (limits->v_out * 1000 > CONFIG_EXAMPLES_SMPS_OUT_VOLTAGE_LIMIT) { - limits->v_out = (float)SMPS_ABSOLUTE_OUT_VOLTAGE_LIMIT_mV/1000.0; + limits->v_out = (float)CONFIG_EXAMPLES_SMPS_OUT_VOLTAGE_LIMIT/1000.0; printf("SMPS output voltage limiit > SMPS absoulute output voltage limit." - " Set output voltage limit to %d.\n", + " Set output voltage limit to %.2f.\n", limits->v_out); } - if (limits->v_in * 1000 > SMPS_ABSOLUTE_IN_VOLTAGE_LIMIT_mV) + if (limits->v_in * 1000 > CONFIG_EXAMPLES_SMPS_IN_VOLTAGE_LIMIT) { - limits->v_in = (float)SMPS_ABSOLUTE_IN_VOLTAGE_LIMIT_mV/1000.0; + limits->v_in = (float)CONFIG_EXAMPLES_SMPS_IN_VOLTAGE_LIMIT/1000.0; printf("SMPS input voltage limiit > SMPS absoulute input voltage limit." - " Set input voltage limit to %d.\n", + " Set input voltage limit to %.2f.\n", limits->v_in); } - if (limits->i_out * 1000 > SMPS_ABSOLUTE_OUT_CURRENT_LIMIT_mA) + if (limits->i_out * 1000 > CONFIG_EXAMPLES_SMPS_OUT_CURRENT_LIMIT) { - limits->i_out = (float)SMPS_ABSOLUTE_OUT_CURRENT_LIMIT_mA/1000.0; + limits->i_out = (float)CONFIG_EXAMPLES_SMPS_OUT_CURRENT_LIMIT/1000.0; printf("SMPS output current limiit > SMPS absoulute output current limit." - " Set output current limit to %d.\n", + " Set output current limit to %.2f.\n", limits->i_out); } @@ -510,8 +629,8 @@ static int smps_state_get(FAR struct smps_dev_s *dev, /* Copy localy stored feedbacks data to status structure */ - smps->state.fb.v_in = g_smps_priv.vin; - smps->state.fb.v_out = g_smps_priv.vout; + smps->state.fb.v_in = g_smps_priv.v_in; + smps->state.fb.v_out = g_smps_priv.v_out; /* Return state structure to caller */ @@ -544,36 +663,322 @@ static int smps_ioctl(FAR struct smps_dev_s *dev, int cmd, unsigned long arg) return OK; } +/**************************************************************************** + * Name: pid_controller + ****************************************************************************/ + +static float pid_controller(struct smps_priv_s *priv, float err) +{ + float out; + float A0 = PID_KP + PID_KD + PID_KI; + float A1 = -PID_KP - 2.0*PID_KD; + float A2 = PID_KD; + + /* Get PID controller output */ + + out = (A0 * err) + (A1 * priv->state[0]) + (A2 * priv->state[1]) + priv->state[2]; + + /* Store PID contrroller variables */ + + priv->state[1] = priv->state[0]; + priv->state[0] = err; + priv->state[2] = out; + + return out; +} + +/**************************************************************************** + * Name: smps_controller + ****************************************************************************/ + +static float smps_controller(struct smps_priv_s *priv, float err) +{ +#ifdef SMPS_CONTROLLER_PID + return pid_controller(priv, err); +#else +# error "At this time only PID controller implemented" +#endif +} + +/**************************************************************************** + * Name: smps_duty_set + ****************************************************************************/ + +static void smps_duty_set(struct smps_priv_s *priv, struct smps_lower_dev_s *lower, + float out) +{ + FAR struct hrtim_dev_s *hrtim = lower->hrtim; + uint8_t mode = priv->conv_mode; + uint16_t cmp = 0; + float duty = 0.0; + uint16_t per = 0; + + switch (mode) + { + case CONVERTER_MODE_INIT: + { + /* Do nothing */ + + break; + } + + case CONVERTER_MODE_BUCK: + { + if (out >= priv->v_in) out = priv->v_in; + if (out < 0.0) out = 0.0; + + duty = out/priv->v_in; + +#warning TODO: current limit in buck mode + + per = HRTIM_PER_GET(hrtim, HRTIM_TIMER_TIMA); + + cmp = (uint16_t)(per * duty); + + if (cmp > per-30) cmp = per - 30; + + /* Set T4 duty cycle. T11 is complementary to T4 */ + + HRTIM_CMP_SET(hrtim, HRTIM_TIMER_TIMA, HRTIM_CMP1, cmp); + + break; + } + + case CONVERTER_MODE_BOOST: + { + per = HRTIM_PER_GET(hrtim, HRTIM_TIMER_TIMA); + + if (out < priv->v_in) out = priv->v_in; + if (out >= BOOST_VOLT_MAX) out = BOOST_VOLT_MAX; + + duty = 1.0 - priv->v_in/out; + +#warning TODO: current limit in boost mode + + cmp = (uint16_t)(per * duty); + + /* Set T12 duty cycle. T5 is complementary to T12 */ + + HRTIM_CMP_SET(hrtim, HRTIM_TIMER_TIMB, HRTIM_CMP1, cmp); + + break; + } + + case CONVERTER_MODE_BUCKBOOST: + { + /* Buck converter is set to fixed duty cycle (80%). + * Now we need set boost converter + */ + + per = HRTIM_PER_GET(hrtim, HRTIM_TIMER_TIMA); + + if (out < priv->v_in) out = priv->v_in; + if (out >= BOOST_VOLT_MAX) out = BOOST_VOLT_MAX; + + duty = 1.0 - priv->v_in/out; + +#warning TODO: current limit in buck boost mode + + cmp = (uint16_t)(per * duty); + + /* Set T12 duty cycle. T5 is complementary to T12 */ + + HRTIM_CMP_SET(hrtim, HRTIM_TIMER_TIMB, HRTIM_CMP1, cmp); + + break; + } + + default: + { + printf("ERROR: unknown converter mode %d!\n", mode); + break; + } + } +} + +/**************************************************************************** + * Name: smps_conv_mode_set + * + * Description: + * Change converter mode (buck/boost/buck-boost). + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void smps_conv_mode_set(struct smps_priv_s *priv, struct smps_lower_dev_s *lower, + uint8_t mode) +{ + FAR struct hrtim_dev_s *hrtim = lower->hrtim; + + /* Disable all outputs */ + + HRTIM_ALL_OUTPUTS_ENABLE(hrtim, false); + + switch (mode) + { + case CONVERTER_MODE_INIT: + { + + break; + } + + case CONVERTER_MODE_BUCK: + { + /* Set T12 low (T5 high) on the next PER */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_SET_NONE); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_RST_PER); + + + /* Set T4 to a high state on PER and reset on CMP1. + T11 is complementary to T4. */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_SET_PER); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_RST_CMP1); + + break; + } + + case CONVERTER_MODE_BOOST: + { + /* Set T4 high (T11 low) on the next PER */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_SET_PER); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_RST_NONE); + + /* Set T12 to a high state on PER and reset on CMP1. + T5 is complementary to T12. */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_SET_PER); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_RST_CMP1); + + break; + } + + case CONVERTER_MODE_BUCKBOOST: + { + /* Set T4 to a high state on PER and reset on CMP1. + T11 is complementary to T4. */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_SET_PER); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMA_CH1, HRTIM_OUT_RST_CMP1); + + /* Set T12 to a high state on PER and reset on CMP1. + T5 is complementary to T12. */ + + HRTIM_OUTPUT_SET_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_SET_PER); + HRTIM_OUTPUT_RST_SET(hrtim, HRTIM_OUT_TIMB_CH1, HRTIM_OUT_RST_CMP1); + + /* Set fixed duty cycle (80%) on buck converter (T4 and T11) */ + + HRTIM_CMP_SET(hrtim, HRTIM_TIMER_TIMA, HRTIM_CMP1, + 0.8 * ((uint16_t)HRTIM_PER_GET(hrtim, HRTIM_TIMER_TIMA))); + + + break; + } + + default: + { + printf("ERROR: unknown converter mode %d!\n", mode); + break; + } + } + + /* Set mode in private data */ + + priv->conv_mode = mode; + + /* Enable outputs */ + + HRTIM_ALL_OUTPUTS_ENABLE(hrtim, true); + +} + +/**************************************************************************** + * Name: adc12_handler + ****************************************************************************/ + static void adc12_handler(void) { - FAR struct smps_lower_dev_s *lower = g_smps_dev.lower; - FAR struct stm32_adc_dev_s *stm32_adc = + FAR struct smps_dev_s *dev = &g_smps_dev; + FAR struct smps_s *smps = (FAR struct smps_s *)dev->priv; + FAR struct smps_priv_s *priv = (struct smps_priv_s *)smps->priv; + FAR struct smps_lower_dev_s *lower = dev->lower; + FAR struct stm32_adc_dev_s *adc = (FAR struct stm32_adc_dev_s*)lower->adc->ad_priv; + uint32_t pending; float ref = ADC_REF_VOLTAGE; float bit = ADC_VAL_MAX; - uint32_t pending; + float err; + float out; + uint8_t mode; - pending = stm32_adc->ops->int_get(stm32_adc); + pending = adc->ops->int_get(adc); - if (pending & ADC_INT_JEOC) + if (pending & ADC_INT_JEOC && priv->running == true) { /* Get raw ADC values */ - g_smps_priv.vout_raw = stm32_adc->ops->inj_get(stm32_adc, VOUT_ADC_INJ_CHANNEL); - g_smps_priv.vin_raw = stm32_adc->ops->inj_get(stm32_adc, VIN_ADC_INJ_CHANNEL); + priv->v_out_raw = adc->ops->inj_get(adc, V_OUT_ADC_INJ_CHANNEL); + priv->v_in_raw = adc->ops->inj_get(adc, V_IN_ADC_INJ_CHANNEL); /* Convert raw values to real values */ - g_smps_priv.vout = (g_smps_priv.vout_raw * ref / bit) * VOUT_RATIO; - g_smps_priv.vin = (g_smps_priv.vin_raw * ref / bit) * VIN_RATIO; + priv->v_out = (priv->v_out_raw * ref / bit) * V_OUT_RATIO; + priv->v_in = (priv->v_in_raw * ref / bit) * V_IN_RATIO; -#warning "missing regulator logic!" + /* According to measured voltages we set converter in appropriate mode */ + + if (smps->param.v_out > (priv->v_in+SMPS_BUCKBOOST_RANGE)) + { + /* Desired output voltage greather than input voltage - set boost converter */ + mode = CONVERTER_MODE_BOOST; + } + + else if (smps->param.v_out < (priv->v_in-SMPS_BUCKBOOST_RANGE)) + { + /* Desired output voltage lower than input voltage - set buck converter */ + + mode = CONVERTER_MODE_BUCK; + } + + else + { + /* Desired output voltage close to input voltage - set buck-boost converter */ + + mode = CONVERTER_MODE_BUCKBOOST; + } + + /* Configure converter to the new mode if needed */ + + if (priv->conv_mode != mode) + { + smps_conv_mode_set(priv, lower, mode); + } + + /* Get regualtor error */ + + err = smps->param.v_out - priv->v_out; + + if (err >= SMPS_VOLTAGE_ACCURACY || err <= (-SMPS_VOLTAGE_ACCURACY)) + { + /* PID controller */ + + out = smps_controller(priv, err); + + /* Update duty cycle */ + + smps_duty_set(priv, lower, out); + } } /* Clear pending */ - stm32_adc->ops->int_ack(stm32_adc, pending); + adc->ops->int_ack(adc, pending); } /**************************************************************************** @@ -584,12 +989,12 @@ static void adc12_handler(void) * Name: stm32_smps_setup * * Description: - * Initialize SMPS driver. + * Initialize SMPS driver. * - * This function should be call by board_app_initialize(). + * This function should be call by board_app_initialize(). * * Returned Value: - * 0 on success, a negated errno value on failure + * 0 on success, a negated errno value on failure * ****************************************************************************/ diff --git a/configs/stm32f334-disco/src/stm32f334-disco.h b/configs/stm32f334-disco/src/stm32f334-disco.h index 904c8acc10d45673f232f45ba37e92e0f2f90e90..085d5abe1476d63b2e957028cff61546b930c023 100644 --- a/configs/stm32f334-disco/src/stm32f334-disco.h +++ b/configs/stm32f334-disco/src/stm32f334-disco.h @@ -113,7 +113,7 @@ void weak_function stm32_spidev_initialize(void); * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/stm32f411e-disco/src/stm32_usb.c b/configs/stm32f411e-disco/src/stm32_usb.c index 95cc3da81dcd6305bc711aa3723bf001a4b5f7da..2e2861a4cf392cec8475662c926b793ac25d7795 100644 --- a/configs/stm32f411e-disco/src/stm32_usb.c +++ b/configs/stm32f411e-disco/src/stm32_usb.c @@ -50,6 +50,7 @@ #include #include +#include #include #include #include @@ -248,9 +249,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO, - CONFIG_STM32F411DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO, + CONFIG_STM32F411DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -311,11 +312,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/stm32f429i-disco/nxwm/defconfig b/configs/stm32f429i-disco/nxwm/defconfig index c1bda648f9a343765dd844ce8485b883ee25f4ba..06a3ce05a265a40d28332e6d178d338af4285970 100644 --- a/configs/stm32f429i-disco/nxwm/defconfig +++ b/configs/stm32f429i-disco/nxwm/defconfig @@ -11,9 +11,7 @@ CONFIG_ARCH_CHIP_STM32F429Z=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" -CONFIG_BOARD_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=16717 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILTIN=y CONFIG_DEBUG_CUSTOMOPT=y CONFIG_DEBUG_SYMBOLS=y @@ -29,6 +27,7 @@ CONFIG_HEAP2_SIZE=8081408 CONFIG_INPUT_STMPE811=y CONFIG_INPUT=y CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=2 diff --git a/configs/stm32f429i-disco/src/stm32_boot.c b/configs/stm32f429i-disco/src/stm32_boot.c index 8af811400a36cafede6a7118773accbb5cfc6c23..d76f3122fac79248036a57556d0359e58e4993a1 100644 --- a/configs/stm32f429i-disco/src/stm32_boot.c +++ b/configs/stm32f429i-disco/src/stm32_boot.c @@ -48,51 +48,6 @@ #include "stm32f429i-disco.h" #include "stm32_ccm.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/* Configuration ********************************************************************/ -/* Should we initialize the NX server using nx_start? This is done for NxWidgets - * (CONFIG_NXWIDGETS=y) and if the NxWidget::CNxServer class expects the RTOS do the - * the NX initialization (CONFIG_NXWIDGET_SERVERINIT=n). This combination of - * settings is normally only used in the kernel build mode* (CONFIG_BUILD_PROTECTED) - * when NxWidgets is unable to initialize NX from user-space. - */ - -#undef HAVE_NXSTART - -#if defined(CONFIG_NXWIDGETS) && !defined(CONFIG_NXWIDGET_SERVERINIT) -# define HAVE_NXSTART -# include -#endif - -/* Should we initialize the touchscreen for the NxWM (CONFIG_NXWM=y)? This - * is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y), NxWM uses the - * touchscreen (CONFIG_NXWM_TOUCHSCREEN=y), and if we were asked to - * initialize the touchscreen for NxWM (NXWM_TOUCHSCREEN_DEVINIT=n). This - * combination of settings is normally only used in the kernel build mode - * (CONFIG_BUILD_PROTECTED) when NxWidgets is unable to initialize NX from - * user-space. - */ - -#undef HAVE_TCINIT - -#if defined(CONFIG_NXWM_TOUCHSCREEN) -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVNO) -# error CONFIG_NXWM_TOUCHSCREEN_DEVNO is not defined -# elif defined(CONFIG_INPUT_STMPE811) -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) -# define HAVE_TCINIT -# include -# endif -# else -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) && defined(CONFIG_BUILD_PROTECTED) -# error CONFIG_INPUT_STMPE811=y is needed -# endif -# endif -#endif - /************************************************************************************ * Public Functions ************************************************************************************/ diff --git a/configs/stm32f429i-disco/src/stm32_bringup.c b/configs/stm32f429i-disco/src/stm32_bringup.c index 3ba8a5c21336a266ec2316455136ff7395b8c50e..3ec0651fe92351fdf2ad368e9c6b1521a92bbf24 100644 --- a/configs/stm32f429i-disco/src/stm32_bringup.c +++ b/configs/stm32f429i-disco/src/stm32_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/stm32f429i-disco/src/stm32_bringup.c * - * Copyright (C) 2012, 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -103,6 +103,8 @@ int stm32_bringup(void) { #if defined(CONFIG_STM32_SPI4) FAR struct spi_dev_s *spi; +#endif +#if defined(CONFIG_MTD) FAR struct mtd_dev_s *mtd; FAR struct mtd_geometry_s geo; #endif @@ -345,6 +347,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_INPUT_STMPE811 + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_SENSORS_L3GD20 ret = stm32_l3gd20initialize("/dev/gyr0"); if (ret != OK) diff --git a/configs/stm32f429i-disco/src/stm32_l3gd20.c b/configs/stm32f429i-disco/src/stm32_l3gd20.c index 7a8c449c6240877a0bb00ae4da5c8be4c03bee80..1dcd99c1b355f903fafd60b2699e4df051e92c0b 100644 --- a/configs/stm32f429i-disco/src/stm32_l3gd20.c +++ b/configs/stm32f429i-disco/src/stm32_l3gd20.c @@ -100,7 +100,7 @@ static int l3gd20_attach(FAR struct l3gd20_config_s *cfg, xcpt_t irq) * Description: * Initialize and register the L3GD20 3 axis gyroscope sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/gyro0" * * Returned Value: diff --git a/configs/stm32f429i-disco/src/stm32_lcd.c b/configs/stm32f429i-disco/src/stm32_lcd.c index ab4d43ae38941781394eecc9a23a7e9d58981309..e327c53b5facb162deef011311434b4543c102bb 100644 --- a/configs/stm32f429i-disco/src/stm32_lcd.c +++ b/configs/stm32f429i-disco/src/stm32_lcd.c @@ -420,7 +420,7 @@ static int stm32_ili9341_initialize(void) * * Parameter: * - * Return: + * Returned Value: * ************************************************************************************/ @@ -444,7 +444,7 @@ void board_lcd_uninitialize(void) * Parameter: * lcddev - Number of the LDC Device. * - * Return: + * Returned Value: * Reference to the LCD object if exist otherwise NULL * ************************************************************************************/ @@ -469,7 +469,7 @@ FAR struct lcd_dev_s *board_lcd_getdev(int lcddev) * * Parameter: * - * Return: + * Returned Value: * On success - Ok * On error - Error Code * @@ -515,7 +515,7 @@ int board_lcd_initialize(void) * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -555,7 +555,7 @@ int up_fbinitialize(int display) * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/configs/stm32f429i-disco/src/stm32_spi.c b/configs/stm32f429i-disco/src/stm32_spi.c index 16a23cc5647e7c693846b13f80c93a4926c50db3..3aaecc60d1538b914afb162b9105a58ce010f7ea 100644 --- a/configs/stm32f429i-disco/src/stm32_spi.c +++ b/configs/stm32f429i-disco/src/stm32_spi.c @@ -279,7 +279,7 @@ int stm32_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) * device after the first initializing and should be used by each driver who * shares the spi5 bus. * - * Input Parameter: + * Input Parameters: * * Returned Value: * Valid SPI device structure reference on success; a NULL on failure diff --git a/configs/stm32f429i-disco/src/stm32_stmpe811.c b/configs/stm32f429i-disco/src/stm32_stmpe811.c index 29fb9284a8bcf8efefac96c547aaf295dfbaa2d9..71bc9830d9c9cf74574bc87fb649b020239d11a4 100644 --- a/configs/stm32f429i-disco/src/stm32_stmpe811.c +++ b/configs/stm32f429i-disco/src/stm32_stmpe811.c @@ -267,13 +267,12 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -284,7 +283,7 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { #ifndef CONFIG_STMPE811_TSC_DISABLE FAR struct i2c_master_s *dev; @@ -339,26 +338,5 @@ int board_tsc_setup(int minor) #endif } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen STMPE811 device yet */ -} - #endif /* CONFIG_INPUT_STMPE811 */ diff --git a/configs/stm32f429i-disco/src/stm32_usb.c b/configs/stm32f429i-disco/src/stm32_usb.c index 33718f15344a482e7e79233692814ee9390a538d..b178650480cdb0e435ad0c0e01bf6b887f5c2696 100644 --- a/configs/stm32f429i-disco/src/stm32_usb.c +++ b/configs/stm32f429i-disco/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -214,9 +215,9 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO, - CONFIG_STM32F429IDISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO, + CONFIG_STM32F429IDISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -281,7 +282,7 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/stm32f429i-disco/src/stm32f429i-disco.h b/configs/stm32f429i-disco/src/stm32f429i-disco.h index 46355dcdc112a50be3ff8c90407c74a342dfe4b9..18063a53911c60bb0c1d49cef4892b32f0605c33 100644 --- a/configs/stm32f429i-disco/src/stm32f429i-disco.h +++ b/configs/stm32f429i-disco/src/stm32f429i-disco.h @@ -1,7 +1,7 @@ /**************************************************************************** * configs/stm32f429i-disco/src/stm32f429i-disco.h * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2018 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Marco Krahl * @@ -230,8 +230,8 @@ void weak_function stm32_spidev_initialize(void); * Name: stm32_usbinitialize * * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related - * GPIO pins for the STM32F429Discovery board. + * Called from stm32_usbinitialize very early in inialization to setup USB- + * related GPIO pins for the STM32F429Discovery board. * ****************************************************************************/ @@ -253,6 +253,27 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif +/**************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************** * Name: stm32_enablefsmc @@ -340,7 +361,7 @@ FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void); * the initialized state of the spi device after the first initializing * and should be used by each driver who shares the spi5 bus. * - * Input Parameter: + * Input Parameters: * None * * Returned Value: @@ -352,14 +373,13 @@ FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void); FAR struct spi_dev_s *stm32_spi5initialize(void); #endif - /**************************************************************************** * Name: stm32_l3gd20initialize() * * Description: * Initialize and register the L3GD20 3 axis gyroscope sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/gyro0" * * Returned Value: diff --git a/configs/stm32f4discovery/src/stm32_bh1750fvi.c b/configs/stm32f4discovery/src/stm32_bh1750fvi.c index 8ac3fe68467dd466c856fa5771f11db40ce346b4..2012762d17f2868105234c37d6ee43d6853aff08 100644 --- a/configs/stm32f4discovery/src/stm32_bh1750fvi.c +++ b/configs/stm32f4discovery/src/stm32_bh1750fvi.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the MPL115A Pressure Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/light0" * * Returned Value: diff --git a/configs/stm32f4discovery/src/stm32_bmp180.c b/configs/stm32f4discovery/src/stm32_bmp180.c index b7ea5f568dac0dd876d2f3f065a52d5fd225c6f7..41553e1af7c079227f65aec78a1b89d7e9eb9817 100644 --- a/configs/stm32f4discovery/src/stm32_bmp180.c +++ b/configs/stm32f4discovery/src/stm32_bmp180.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the MPL115A Pressure Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/press0" * * Returned Value: diff --git a/configs/stm32f4discovery/src/stm32_lis3dsh.c b/configs/stm32f4discovery/src/stm32_lis3dsh.c index b48a5614fa5a106e68491ac8f34bf19aea7ecdb4..600621786fb92af80cf126c7791ac4a07e9890c6 100644 --- a/configs/stm32f4discovery/src/stm32_lis3dsh.c +++ b/configs/stm32f4discovery/src/stm32_lis3dsh.c @@ -68,7 +68,7 @@ * Attach the lis3dsh interrupt handler to PE0/EXT0 on the STM32F4 as wired * on STM32F4Discovery * - * Input parameters: + * Input Parameters: * *config - The lis3dsh instance configuration data containing the IRQ number, * device ID and interrupt handler * interrupt_handler - The interrupt handler to attach @@ -98,7 +98,7 @@ int attach_disc_lis3dsh(FAR struct lis3dsh_config_s *config, xcpt_t interrupt_ha * Description: * Initialize and register the LIS3DSH 3-axis accelerometer. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/acc0" * * Returned Value: diff --git a/configs/stm32f4discovery/src/stm32_max31855.c b/configs/stm32f4discovery/src/stm32_max31855.c index 2a03d70d7fc37f5cebec89fe3110ff4924cb5347..388fcf585d4644eb1f30d84177ac0f3ef0eb9261 100644 --- a/configs/stm32f4discovery/src/stm32_max31855.c +++ b/configs/stm32f4discovery/src/stm32_max31855.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the MAX31855 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: diff --git a/configs/stm32f4discovery/src/stm32_max6675.c b/configs/stm32f4discovery/src/stm32_max6675.c index 759565c6e27260d5731933f5d571b90ed7aa0b74..d0360c5f33feea83574acd78a823081fb6e3f897 100644 --- a/configs/stm32f4discovery/src/stm32_max6675.c +++ b/configs/stm32f4discovery/src/stm32_max6675.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the MAX6675 Temperature Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/temp0" * * Returned Value: diff --git a/configs/stm32f4discovery/src/stm32_pm.c b/configs/stm32f4discovery/src/stm32_pm.c index c012e397c30d10197f86e9fa44f7f1fe83ac923d..0bce85cc54f30ac9e5c2ced9bff6bdc1c61789e8 100644 --- a/configs/stm32f4discovery/src/stm32_pm.c +++ b/configs/stm32f4discovery/src/stm32_pm.c @@ -79,10 +79,10 @@ * *before* any other device drivers are initialized (since they may * attempt to register with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/configs/stm32f4discovery/src/stm32_timer.c b/configs/stm32f4discovery/src/stm32_timer.c index 326f2f25c09a2b73c2310a173c6e930d7c15a900..3586a181aaa18e7f0205c0b7d16960e5650cecf3 100644 --- a/configs/stm32f4discovery/src/stm32_timer.c +++ b/configs/stm32f4discovery/src/stm32_timer.c @@ -67,7 +67,7 @@ * devpath - The full path to the timer device. This should be of the form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * diff --git a/configs/stm32f4discovery/src/stm32_usb.c b/configs/stm32f4discovery/src/stm32_usb.c index f0d2e161705b25f675171c3568207eae1c0476c6..e5fa78951ef0161ed84c633b10759f75a4463587 100644 --- a/configs/stm32f4discovery/src/stm32_usb.c +++ b/configs/stm32f4discovery/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -248,7 +249,7 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; @@ -311,11 +312,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/stm32f4discovery/src/stm32f4discovery.h b/configs/stm32f4discovery/src/stm32f4discovery.h index 51936d9485a0269a50351e62cd441e851dba3200..fb1ee6b81f7304c4c6211d352f87244d1a50ab10 100644 --- a/configs/stm32f4discovery/src/stm32f4discovery.h +++ b/configs/stm32f4discovery/src/stm32f4discovery.h @@ -720,7 +720,7 @@ int stm32_pca9635_initialize(void); #endif /**************************************************************************** - * Name stm32_rgbled_setup + * Name: stm32_rgbled_setup * * Description: * This function is called by board initialization logic to configure the @@ -750,7 +750,7 @@ int stm32_rgbled_setup(void); * form /dev/timer0 * timer - The timer's number. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned * to indicate the nature of any failure. * @@ -761,7 +761,7 @@ int stm32_timer_driver_setup(FAR const char *devpath, int timer); #endif /**************************************************************************** - * Name xen1210_archinitialize + * Name: xen1210_archinitialize * * Description: * This function is called by board initialization logic to configure the diff --git a/configs/stm32f746-ws/src/stm32_usb.c b/configs/stm32f746-ws/src/stm32_usb.c index a2985140b32665ab5160d91b28d3719206c06087..46877033ba60a38de9ae9323e563c3aa9c6ac258 100644 --- a/configs/stm32f746-ws/src/stm32_usb.c +++ b/configs/stm32f746-ws/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -240,7 +241,7 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32F7F4DISCO_USBHOST_PRIO, + pid = kthread_create("usbhost", CONFIG_STM32F7F4DISCO_USBHOST_PRIO, CONFIG_STM32F7F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; @@ -303,11 +304,11 @@ void stm32_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an overcurrent condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New overcurrent interrupt handler * arg - The argument provided for the interrupt handler * - * Returned value: + * Returned Value: * Zero (OK) is returned on success. Otherwise, a negated errno value is returned * to indicate the nature of the failure. * diff --git a/configs/stm32l476vg-disco/src/stm32_usb.c b/configs/stm32l476vg-disco/src/stm32_usb.c index 0f51871e1ac000c2b642404a000ac534b19b1a16..60858f581ab843e8a16f96309232eb3a6919afa7 100644 --- a/configs/stm32l476vg-disco/src/stm32_usb.c +++ b/configs/stm32l476vg-disco/src/stm32_usb.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -237,9 +238,9 @@ int stm32l4_usbhost_initialize(void) uvdbg("Start usbhost_waiter\n"); - pid = task_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO, - CONFIG_STM32L4DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO, + CONFIG_STM32L4DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } @@ -300,10 +301,10 @@ void stm32l4_usbhost_vbusdrive(int iface, bool enable) * Setup to receive an interrupt-level callback if an over current condition is * detected. * - * Input Parameter: + * Input Parameters: * handler - New over current interrupt handler * - * Returned value: + * Returned Value: * Old over current interrupt handler * ************************************************************************************/ diff --git a/configs/stm32l476vg-disco/src/stm32_userleds.c b/configs/stm32l476vg-disco/src/stm32_userleds.c index 4bee92bde819ff5eae619be1400a5184582639bb..f1b27fb26f5e845a52f9e4b3ae583bcfd5fe2bf9 100644 --- a/configs/stm32l476vg-disco/src/stm32_userleds.c +++ b/configs/stm32l476vg-disco/src/stm32_userleds.c @@ -192,11 +192,11 @@ void board_userled(int led, bool ledon) switch (led) { case BOARD_LED_RED: - stm32l4_gpiowrite(GPIO_LED_RED, ldeon); + stm32l4_gpiowrite(GPIO_LED_RED, ledon); break; case BOARD_LED_GRN: - stm32l4_gpiowrite(GPIO_LED_GRN, ldeon); + stm32l4_gpiowrite(GPIO_LED_GRN, ledon); break; } } diff --git a/configs/sure-pic32mx/src/pic32mx_appinit.c b/configs/sure-pic32mx/src/pic32mx_appinit.c index b668e512cb0075ad283dd8349b49044a1b1d7a01..3bb9398a92817fa4601a0b8da799375ef0f6a260 100644 --- a/configs/sure-pic32mx/src/pic32mx_appinit.c +++ b/configs/sure-pic32mx/src/pic32mx_appinit.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -318,9 +319,9 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)nsh_waiter, (FAR char * const *)NULL); return pid < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/configs/teensy-lc/src/kl_spi.c b/configs/teensy-lc/src/kl_spi.c index efd1c96ce37e89286fe16c031b484c9bd8a4394a..17193881f49ef4bd4fc410517d6549af3959bce3 100644 --- a/configs/teensy-lc/src/kl_spi.c +++ b/configs/teensy-lc/src/kl_spi.c @@ -124,7 +124,7 @@ void weak_function kl_spidev_initialize(void) * devid - Identifies the (logical) device * selected - TRUE:Select the device, FALSE:De-select the device * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -156,7 +156,7 @@ void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, * Input Parameters: * devid - Identifies the (logical) device * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ @@ -187,7 +187,7 @@ uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) * devid - Identifies the (logical) device * cmd - Determines where command or data should be selected. * - * Returned Values: + * Returned Value: * Bit-encoded SPI status (see include/nuttx/spi/spi.h. * ****************************************************************************/ diff --git a/configs/u-blox-c027/src/lpc17_ubxmdm.c b/configs/u-blox-c027/src/lpc17_ubxmdm.c index bd165b96d2282fec664a95040f0c54e10bd6a704..2e333a8fcb9bc8a5eeeb5fa4cabbafce25f6e2cb 100644 --- a/configs/u-blox-c027/src/lpc17_ubxmdm.c +++ b/configs/u-blox-c027/src/lpc17_ubxmdm.c @@ -281,7 +281,7 @@ static int lpc17_ioctl(FAR struct ubxmdm_lower* lower, * Input Parameters: * usb_used - enables the USB sense pin if 'true' * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ diff --git a/configs/viewtool-stm32f107/README.txt b/configs/viewtool-stm32f107/README.txt index 3bb13a31662fe44d58a9e6d8a65299d7e258174e..42faf94f79d1f7035bd0038fa2b12bb8754bcb90 100644 --- a/configs/viewtool-stm32f107/README.txt +++ b/configs/viewtool-stm32f107/README.txt @@ -630,12 +630,6 @@ Configurations 6. USB support is disabled by default. See the section above entitled, "USB Interface" - STATUS. The first time I build the configuration, I get some undefined - external references. No idea why. Simply cleaning the apps/ directory - and rebuilding fixes the problem: - - make apps_clean all - nsh: This configuration directory provide the basic NuttShell (NSH). diff --git a/configs/viewtool-stm32f107/netnsh/defconfig b/configs/viewtool-stm32f107/netnsh/defconfig index 131d3b620b1411e2f1af273fa71fe3536e182cb1..72a2921d02a37728a11669132f7b9af700ccd88e 100644 --- a/configs/viewtool-stm32f107/netnsh/defconfig +++ b/configs/viewtool-stm32f107/netnsh/defconfig @@ -1,5 +1,4 @@ # CONFIG_NSH_ARGCAT is not set -# CONFIG_NSH_CMDOPT_DF_H is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set CONFIG_ARCH_BOARD_VIEWTOOL_STM32F107=y @@ -23,9 +22,15 @@ CONFIG_NET_ARP_SEND=y CONFIG_NET_BROADCAST=y CONFIG_NET_ETH_MTU=650 CONFIG_NET_ETH_TCP_RECVWNDO=624 +CONFIG_NET_HOSTNAME="Viewtool-STM32F107" CONFIG_NET_ICMP_SOCKET=y CONFIG_NET_ICMP=y +CONFIG_NET_ICMPv6_NEIGHBOR=y +CONFIG_NET_ICMPv6_SOCKET=y +CONFIG_NET_ICMPv6=y +CONFIG_NET_IPv6=y CONFIG_NET_MAX_LISTENPORTS=40 +CONFIG_NET_ROUTE=y CONFIG_NET_SOCKOPTS=y CONFIG_NET_TCP_CONNS=40 CONFIG_NET_TCP_WRITE_BUFFERS=y @@ -56,9 +61,9 @@ CONFIG_SCHED_HPWORK=y CONFIG_SCHED_HPWORKPRIORITY=192 CONFIG_SCHED_HPWORKSTACKSIZE=1024 CONFIG_SDCLONE_DISABLE=y -CONFIG_START_DAY=21 -CONFIG_START_MONTH=9 -CONFIG_START_YEAR=2009 +CONFIG_START_DAY=23 +CONFIG_START_MONTH=1 +CONFIG_START_YEAR=2018 CONFIG_STM32_ETHMAC=y CONFIG_STM32_JTAG_FULL_ENABLE=y CONFIG_STM32_PHYSR_100MBPS=0x0000 @@ -70,6 +75,7 @@ CONFIG_STM32_PWR=y CONFIG_STM32_RMII_EXTCLK=y CONFIG_STM32_USART1=y CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_PING6=y CONFIG_TASK_NAME_SIZE=0 CONFIG_USART1_SERIAL_CONSOLE=y CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/configs/viewtool-stm32f107/src/stm32_bringup.c b/configs/viewtool-stm32f107/src/stm32_bringup.c index cba3798e88923c41333c4f3d8922ae03f0ad6662..97ca12b9861ebc06089589c3c743ba04f5be1424 100644 --- a/configs/viewtool-stm32f107/src/stm32_bringup.c +++ b/configs/viewtool-stm32f107/src/stm32_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/viewtool-stm32f107/src/stm32_bringup.c * - * Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -165,6 +165,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_CAN /* Initialize CAN and register the CAN driver. */ diff --git a/configs/viewtool-stm32f107/src/stm32_mpl115a.c b/configs/viewtool-stm32f107/src/stm32_mpl115a.c index c6a1b9e6343896c4149fa841e27584cc2faf7578..2e78e2e5ac4a3bb895501a0fffae4f694f43901e 100644 --- a/configs/viewtool-stm32f107/src/stm32_mpl115a.c +++ b/configs/viewtool-stm32f107/src/stm32_mpl115a.c @@ -67,7 +67,7 @@ * Description: * Initialize and register the MPL115A Pressure Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/press0" * * Returned Value: diff --git a/configs/viewtool-stm32f107/src/stm32_touchscreen.c b/configs/viewtool-stm32f107/src/stm32_touchscreen.c index 8d6bc3c2593288dcdee3b0ba4d6b55f73a18834f..39130e789322948eb04a6939c2c095a94a55edbb 100644 --- a/configs/viewtool-stm32f107/src/stm32_touchscreen.c +++ b/configs/viewtool-stm32f107/src/stm32_touchscreen.c @@ -239,13 +239,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -256,75 +255,38 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct spi_dev_s *dev; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ - - if (!initialized) - { - /* Configure the XPT2046 interrupt pin as an input */ + /* Configure the XPT2046 interrupt pin as an input */ - (void)stm32_configgpio(GPIO_LCDTP_IRQ); + (void)stm32_configgpio(GPIO_LCDTP_IRQ); - /* Get an instance of the SPI interface for the touchscreen chip select */ + /* Get an instance of the SPI interface for the touchscreen chip select */ - dev = stm32_spibus_initialize(TSC_DEVNUM); - if (!dev) - { - ierr("ERROR: Failed to initialize SPI%d\n", TSC_DEVNUM); - return -ENODEV; - } - - /* Initialize and register the SPI touchscreen device */ - - ret = ads7843e_register(dev, &g_tscinfo.config, CONFIG_ADS7843E_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - /* up_spiuninitialize(dev); */ - return -ENODEV; - } + dev = stm32_spibus_initialize(TSC_DEVNUM); + if (!dev) + { + ierr("ERROR: Failed to initialize SPI%d\n", TSC_DEVNUM); + return -ENODEV; + } - /* Now we are initialized */ + /* Initialize and register the SPI touchscreen device */ - initialized = true; + ret = ads7843e_register(dev, &g_tscinfo.config, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + /* up_spiuninitialize(dev); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen XPT2046 device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/viewtool-stm32f107/src/viewtool_stm32f107.h b/configs/viewtool-stm32f107/src/viewtool_stm32f107.h index 8ec579e14070321e3bf1ac70a34112b182de7e1e..7aaa0f011469be9f52e36138ffa9225311be9b09 100644 --- a/configs/viewtool-stm32f107/src/viewtool_stm32f107.h +++ b/configs/viewtool-stm32f107/src/viewtool_stm32f107.h @@ -1,7 +1,7 @@ /**************************************************************************** * configs/viewtool-stm32f107/src/viewtool_stm32f107.h * - * Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -348,8 +348,8 @@ void stm32_led_initialize(void); * Name: stm32_usbdev_initialize * * Description: - * Called from stm32_usbdev_initialize very early in initialization to setup USB-related - * GPIO pins for the Viewtool STM32F107 board. + * Called from stm32_usbdev_initialize very early in initialization to + * setup USB-related GPIO pins for the Viewtool STM32F107 board. * ****************************************************************************/ @@ -357,6 +357,27 @@ void stm32_led_initialize(void); void weak_function stm32_usbdev_initialize(void); #endif +/**************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************** * Name: stm32_sdinitialize * @@ -386,7 +407,7 @@ int stm32_can_setup(void); * Description: * Initialize and register the MPL115A Pressure Sensor driver. * - * Input parameters: + * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/press0" * * Returned Value: diff --git a/configs/xmc4500-relax/include/board.h b/configs/xmc4500-relax/include/board.h index 7190d1c9394207a94fefc239799bc7fa0b4035aa..0dfd182eb6c1097fb17996dd99618e3618d224de 100644 --- a/configs/xmc4500-relax/include/board.h +++ b/configs/xmc4500-relax/include/board.h @@ -82,158 +82,153 @@ #define BOARD_XTAL_FREQUENCY 12000000 /* 12MHz XTAL */ #undef BOARD_RTC_XTAL_FRQUENCY /* 32.768KHz RTC XTAL not available on the Relax Lite */ - -#if defined(BOARD_FCPU_144MHZ) -/* Default clock initialization - * - * fXTAL = 12Mhz - * -> fPLL = (fXTAL / (2 * 1) * 48) = 288MHz - * -> fSYS = (fPLL / 1) = 288MHz - * -> fCPU = (fSYS / 2) = 144MHz - * -> fPERIPH = (fCPU / 1) = 144MHz - * -> fCCU = (fSYS / 2) = 144MHz - * -> fETH = 72MHz (REVISIT) - * -> fUSB = 48MHz (REVISIT) - * -> fEBU = 72MHz (REVISIT) - * - * fUSBPLL Disabled, only enabled if SCU_CLK_USBCLKCR_USBSEL_USBPLL is selected - * - * fOFI = 24MHz - * -> fWDT = 24MHz (REVISIT) +/* + * TODO: enable the RTC osc, use RTC for time/date */ /* Select the external crystal as the PLL clock source */ -# define BOARD_PLL_CLOCKSRC_XTAL 1 /* PLL Clock source == external crystal */ +# define BOARD_PLL_CLOCKSRC_XTAL 1 /* PLL Clock source == extnernal crystal */ # undef BOARD_PLL_CLOCKSRC_OFI /* PLL Clock source != internal fast oscillator */ /* PLL Configuration: * - * fPLL = (fPLLSRC / (pdiv * k2div) * ndiv + * fXTAL = 12Mhz + * 260 MHz <= fVCO <= 520 MHz * - * fPLL = (12000000 / (2 * 1)) * 48 - * = 288MHz + * fVCO = fXTAL * ndiv / pdiv + * fPLL = fVCO / k2div + * fSYS = fPLL / sysdiv + * fETH = fSYS / 2 (fixed div by 2) + * fCCU = fSYS / ccudiv (div by 1 or 2) + * fCPU = fSYS / cpudiv (div by 1 or 2) + * fPERIPH = fCPU / pbdiv (div by 1 or 2) */ -# define BOARD_ENABLE_PLL 1 -# define BOARD_PLL_PDIV 2 -# define BOARD_PLL_NDIV 48 -# define BOARD_PLL_K2DIV 1 -# define BOARD_PLL_FREQUENCY 288000000 +# define BOARD_ENABLE_PLL 1 /* enable the PLL */ +# define CPU_FREQ 120 /* MHz */ + +/* TODO: Automate PLL calculations */ -/* System frequency, fSYS, is divided down from PLL output */ +#if CPU_FREQ == 120 +/* + * 120 MHz + * + * fVCO = 12MHz * 40 / 2 = 480MHz + * fPLL = 480MHz / 2 = 240MHz + * fSYS = fPLL / 2 = 120MHz + * fCCU = fSYS / 2 = 60MHz + * fCPU = fSYS / 1 = 120MHz + * fPB = fCPU / 2 = 60MHz + * fETH = fSYS / 2 = 60MHz + */ -# define BOARD_SYSDIV 1 /* PLL Output divider to get fSYS */ -# define BOARD_SYS_FREQUENCY 288000000 +# define BOARD_PLL_NDIV 40 +# define BOARD_PLL_PDIV 1 +# define BOARD_PLL_K2DIV 4 +# define BOARD_PLL_SYSDIV 1 +# define BOARD_PLL_CPUDIV 1 +# define BOARD_PLL_PBDIV 2 +# define BOARD_PLL_CCUDIV 2 +# define BOARD_PLL_EBUDIV 4 + +#elif CPU_FREQ == 144 +/* + * 144 MHz + * + * fVCO = 12MHz * 36 / 1 = 432MHz + * fPLL = 432MHz / 3 = 144MHz + * fSYS = fPLL / 1 = 144MHz + * fCCU = fSYS / 2 = 72MHz + * fCPU = fSYS / 1 = 144MHz + * fPB = fCPU / 2 = 72MHz + * fETH = fSYS / 2 = 72MHz + */ -/* CPU frequency, fCPU, may be divided down from system frequency */ +# define BOARD_PLL_NDIV 36 +# define BOARD_PLL_PDIV 1 +# define BOARD_PLL_K2DIV 3 +# define BOARD_PLL_SYSDIV 1 +# define BOARD_PLL_CPUDIV 1 +# define BOARD_PLL_PBDIV 2 +# define BOARD_PLL_CCUDIV 2 +# define BOARD_PLL_EBUDIV 2 -# define BOARD_CPUDIV_ENABLE 1 /* Enable PLL divide by 2 for fCPU */ -# define BOARD_CPU_FREQUENCY 144000000 +#else +# error "Illegal or Unsupported CPU Frequency" +#endif -/* CCU frequency may be divided down from system frequency */ -# define BOARD_CCUDIV_ENABLE 1 /* Enable PLL div by 2 */ -# define BOARD_CCU_FREQUENCY 144000000 +# define BOARD_CCUDIV_ENABLE (BOARD_PLL_CCUDIV - 1) +# define BOARD_CPUDIV_ENABLE (BOARD_PLL_CPUDIV - 1) -/* Watchdog clock settings */ +# define BOARD_VCO_FREQUENCY (BOARD_XTAL_FREQUENCY * BOARD_PLL_NDIV / BOARD_PLL_PDIV) +# define BOARD_PLL_FREQUENCY (BOARD_VCO_FREQUENCY / BOARD_PLL_K2DIV) +# define BOARD_SYS_FREQUENCY (BOARD_PLL_FREQUENCY / BOARD_PLL_SYSDIV) +# define BOARD_CCU_FREQUENCY (BOARD_SYS_FREQUENCY / BOARD_PLL_CCUDIV) +# define BOARD_CPU_FREQUENCY (BOARD_SYS_FREQUENCY / BOARD_PLL_CPUDIV) +# define BOARD_PERIPH_FREQUENCY (BOARD_CPU_FREQUENCY / BOARD_PLL_PBDIV) +# define BOARD_ETH_FREQUENCY (BOARD_SYS_FREQUENCY / 2) # define BOARD_WDT_SOURCE WDT_CLKSRC_FOFI # define BOARD_WDTDIV 1 # define BOARD_WDT_FREQUENCY 24000000 -/* EBU frequency may be divided down from system frequency */ - -# define BOARD_EBUDIV 2 /* fSYS / 2 */ -# define BOARD_EBU_FREQUENCY 72000000 - -/* EXT clock settings */ - # define BOARD_EXT_SOURCE EXT_CLKSRC_FPLL -# define BOARD_EXTDIV 289 /* REVISIT */ -# define BOARD_EXT_FREQUENCY 498270 /* REVISIT */ +# define BOARD_PLL_ECKDIV 480 /* [1,512] */ -/* The peripheral clock, fPERIPH, derives from fCPU with no division */ +# define kHz_1 1000 +# define MHz_1 (kHz_1 * kHz_1) +# define MHz_50 ( 50 * MHz_1) +# define MHz_260 (260 * MHz_1) +# define MHz_520 (520 * MHz_1) -# define BOARD_PBDIV 1 /* No division */ -# define BOARD_PERIPH_FREQUENCY 144000000 + /* range check VCO frequency */ +# if (BOARD_VCO_FREQUENCY < MHz_260) +# error "VCO freq must be >= 260 MHz" +# endif -#elif defined(BOARD_FCPU_120MHZ) -/* Default clock initialization - * - * fXTAL = 12Mhz - * -> fPLL = (fXTAL / (2 * 4) * 80) = 120 - * -> fSYS = (fPLL / 1) = 120MHz - * -> fCPU = (fSYS / 1) = 120MHz - * -> fPERIPH = (fCPU / 1) = 120MHz - * -> fCCU = (fSYS / 1) = 120MHz - * -> fETH = 60MHz (REVISIT) - * -> fUSB = 48MHz (REVISIT) - * -> fEBU = 60MHz (REVISIT) - * - * fUSBPLL Disabled, only enabled if SCU_CLK_USBCLKCR_USBSEL_USBPLL is selected - * - * fOFI = 24MHz - * -> fWDT = 24MHz (REVISIT) - */ +# if (BOARD_VCO_FREQUENCY > MHz_520) +# error "VCO freq must be <= 520 MHz" +# endif -/* Select the external crystal as the PLL clock source */ - -# define BOARD_PLL_CLOCKSRC_XTAL 1 /* PLL Clock source == extnernal crystal */ -# undef BOARD_PLL_CLOCKSRC_OFI /* PLL Clock source != internal fast oscillator */ - -/* PLL Configuration: - * - * fPLL = (fPLLSRC / (pdiv * k2div) * ndiv - * - * fPLL = (12000000 / (2 * 4)) * 80 - * = 120MHz - */ - -# define BOARD_ENABLE_PLL 1 -# define BOARD_PLL_PDIV 2 -# define BOARD_PLL_NDIV 80 -# define BOARD_PLL_K2DIV 4 -# define BOARD_PLL_FREQUENCY 120000000 - -/* System frequency, fSYS, is divided down from PLL output */ + /* range check Ethernet MAC frequency */ +# if (BOARD_ETH_FREQUENCY <= MHz_50) +# error "ETH freq must be > 50 MHz" +# endif -# define BOARD_SYSDIV 1 /* No division */ -# define BOARD_SYS_FREQUENCY 120000000 -/* CPU frequency, fCPU, may be divided down from system frequency */ -# define BOARD_CPUDIV_ENABLE 0 /* No divison */ -# define BOARD_CPU_FREQUENCY 120000000 - -/* CCU frequency may be divided down from system frequency */ - -# define BOARD_CCUDIV_ENABLE 0 /* No divison */ -# define BOARD_CCU_FREQUENCY 120000000 - -/* Watchdog clock setting */ - -# define BOARD_WDT_SOURCE WDT_CLKSRC_FOFI -# define BOARD_WDTDIV 1 -# define BOARD_WDT_FREQUENCY 24000000 +/* check ccudiv cpudiv pbdiv against Table 11-5 + * of XMC4500 User Manual + */ +#define CLKDIV_INDEX (4 * (BOARD_PLL_CCUDIV-1) + \ + 2 * (BOARD_PLL_CPUDIV-1) + \ + (BOARD_PLL_PBDIV-1) ) -/* EBU frequency may be divided down from system frequency */ +#if (CLKDIV_INDEX == 3) || (CLKDIV_INDEX == 4) || (CLKDIV_INDEX > 6) +# error "Illegal combination of dividers! Ref: Table 11-5 of UM" +#endif -# define BOARD_EBUDIV 2 /* fSYS/2 */ -# define BOARD_EBU_FREQUENCY 60000000 /* EXT clock settings */ +#define BOARD_EXTCKL_ENABLE 1 /* 0 disables output */ +#if BOARD_EXTCKL_ENABLE +# define EXTCLK_PIN_P0_8 8 +# define EXTCLK_PIN_P1_15 15 +# define BOARD_EXTCLK_PIN EXTCLK_PIN_P0_8 # define BOARD_EXT_SOURCE EXT_CLKSRC_FPLL -# define BOARD_EXTDIV 289 /* REVISIT */ -# define BOARD_EXT_FREQUENCY 415225 /* REVISIT */ +# define BOARD_EXT_FREQUENCY (250 * kHz_1) /* Desired output freq */ +# define BOARD_EXTDIV (BOARD_PLL_FREQUENCY / BOARD_EXT_FREQUENCY) -/* The peripheral clock, fPERIPH, derives from fCPU with no division */ - -# define BOARD_PBDIV 1 /* No division */ -# define BOARD_PERIPH_FREQUENCY 120000000 +/* range check EXTDIV */ +# if BOARD_EXTDIV > 512 +# error "EXTCLK Divisor out of range!" +# endif #endif + /* Standby clock source selection * * BOARD_STDBY_CLOCKSRC_OSI - Internal 32.768KHz slow oscillator diff --git a/configs/zp214xpa/src/lpc2148_spi1.c b/configs/zp214xpa/src/lpc2148_spi1.c index a7b479082bd72ef2e4b5811a1a81ea3062cf5b7b..f9c1cc269349b32de956e8b550d7ae0f98367e1b 100644 --- a/configs/zp214xpa/src/lpc2148_spi1.c +++ b/configs/zp214xpa/src/lpc2148_spi1.c @@ -569,7 +569,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw * Description: * Initialize the selected SPI port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has mutiple SPI interfaces) * * Returned Value: diff --git a/crypto/aes.c b/crypto/aes.c index e7c638f71897da335aedfb16a2c82378a8f89175..4aa5cd1c1373af98b8dfe8650b0224fdff3ac393 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -543,7 +543,7 @@ static void aes_decr(FAR uint8_t *state, FAR const uint8_t *expanded_key) * Public Functions ****************************************************************************/ - /**************************************************************************** +/**************************************************************************** * Name: aes_encrypt * * Description: @@ -555,7 +555,7 @@ static void aes_decr(FAR uint8_t *state, FAR const uint8_t *expanded_key) * key AES128 key of size 16 bytes * state 16 bytes of plain text and cipher text * - * Returned Value + * Returned Value: * None * ****************************************************************************/ @@ -580,7 +580,7 @@ void aes_encrypt(FAR uint8_t *state, FAR const uint8_t *key) * key AES128 key of size 16 bytes * state 16 bytes of plain text and cipher text * - * Returned Value + * Returned Value: * None * ****************************************************************************/ diff --git a/drivers/analog/ad5410.c b/drivers/analog/ad5410.c index 679edf2c5f25ffdc7ddd393d0746dcfb11237195..ab8609480e735dc4e5a5468d4543bad67f6dae57 100644 --- a/drivers/analog/ad5410.c +++ b/drivers/analog/ad5410.c @@ -270,7 +270,7 @@ static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg) * Description: * Initialize the selected DAC port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple DAC interfaces) * * Returned Value: diff --git a/drivers/analog/ads1255.c b/drivers/analog/ads1255.c index 408dd92a29bdab43058cb038dbcd3153b4f9fc67..460f35e380d1c372776c0042b9bb0844f95512d9 100644 --- a/drivers/analog/ads1255.c +++ b/drivers/analog/ads1255.c @@ -502,7 +502,7 @@ static int adc_interrupt(int irq, void *context, FAR void *arg) * Description: * Initialize the selected adc port * - * Input Parameter: + * Input Parameters: * Port number (for hardware that has multiple adc interfaces) * * Returned Value: diff --git a/drivers/analog/dac.c b/drivers/analog/dac.c index 7e028e26f5e496fbff0b65a7288fb5462945b313..bfc2468463553c8d40ed33f8e8ded4b7102c81c8 100644 --- a/drivers/analog/dac.c +++ b/drivers/analog/dac.c @@ -465,7 +465,7 @@ static int dac_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Description: * Called from the DAC interrupt handler at the completion of a send operation. * - * Return: + * Returned Value: * OK on success; a negated errno on failure. * ************************************************************************************/ diff --git a/drivers/audio/cs43l22.c b/drivers/audio/cs43l22.c index be90d84c562321743fda1547653a717560538a38..ad09df65ec804def88b5322fad42337583b5eb30 100644 --- a/drivers/audio/cs43l22.c +++ b/drivers/audio/cs43l22.c @@ -209,7 +209,7 @@ static const struct audio_ops_s g_audioops = /**************************************************************************** * Name: cs43l22_readreg * - * Description + * Description: * Read the specified 16-bit register from the CS43L22 device. * ****************************************************************************/ @@ -1206,8 +1206,8 @@ static int cs43l22_start(FAR struct audio_lowerhalf_s *dev) /**************************************************************************** * Name: cs43l22_stop * - * Description: Stop the configured operation (audio streaming, volume - * disabled, etc.). + * Description: + * Stop the configured operation (audio streaming, volume disabled, etc.). * ****************************************************************************/ @@ -1244,7 +1244,8 @@ static int cs43l22_stop(FAR struct audio_lowerhalf_s *dev) /**************************************************************************** * Name: cs43l22_pause * - * Description: Pauses the playback. + * Description: + * Pauses the playback. * ****************************************************************************/ @@ -1273,7 +1274,8 @@ static int cs43l22_pause(FAR struct audio_lowerhalf_s *dev) /**************************************************************************** * Name: cs43l22_resume * - * Description: Resumes the playback. + * Description: + * Resumes the playback. * ****************************************************************************/ @@ -1306,7 +1308,8 @@ static int cs43l22_resume(FAR struct audio_lowerhalf_s *dev) /**************************************************************************** * Name: cs43l22_enqueuebuffer * - * Description: Enqueue an Audio Pipeline Buffer for playback/ processing. + * Description: + * Enqueue an Audio Pipeline Buffer for playback/ processing. * ****************************************************************************/ @@ -1356,7 +1359,8 @@ static int cs43l22_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, /**************************************************************************** * Name: cs43l22_cancelbuffer * - * Description: Called when an enqueued buffer is being cancelled. + * Description: + * Called when an enqueued buffer is being cancelled. * ****************************************************************************/ @@ -1370,7 +1374,8 @@ static int cs43l22_cancelbuffer(FAR struct audio_lowerhalf_s *dev, /**************************************************************************** * Name: cs43l22_ioctl * - * Description: Perform a device ioctl + * Description: + * Perform a device ioctl * ****************************************************************************/ @@ -1424,7 +1429,8 @@ static int cs43l22_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd, /**************************************************************************** * Name: cs43l22_reserve * - * Description: Reserves a session (the only one we have). + * Description: + * Reserves a session (the only one we have). * ****************************************************************************/ @@ -1469,7 +1475,8 @@ static int cs43l22_reserve(FAR struct audio_lowerhalf_s *dev) /**************************************************************************** * Name: cs43l22_release * - * Description: Releases the session (the only one we have). + * Description: + * Releases the session (the only one we have). * ****************************************************************************/ diff --git a/drivers/audio/cs43l22.h b/drivers/audio/cs43l22.h index f2ec078e1093cc52433d7f61ad5ac915e33afb17..ce83523527b1d30ab6b70fee1c0194e9fb8cb069 100644 --- a/drivers/audio/cs43l22.h +++ b/drivers/audio/cs43l22.h @@ -374,7 +374,7 @@ extern const uint8_t g_fllratio[CS43L22_NFLLRATIO]; /**************************************************************************** * Name: cs43l22_readreg * - * Description + * Description: * Read the specified 8-bit register from the CS43L22 device. * ****************************************************************************/ diff --git a/drivers/audio/tone.c b/drivers/audio/tone.c index bc5e5740c14acd576d306b22c4ab68543f8c412c..d0dfb4d33bd2ab97e6f12ba7613f0a242afee914 100644 --- a/drivers/audio/tone.c +++ b/drivers/audio/tone.c @@ -922,7 +922,7 @@ static ssize_t tone_write(FAR struct file *filep, FAR const char *buffer, * be used by application code. * * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name of PWM driver * as "/dev/tone0". diff --git a/drivers/audio/wm8776.c b/drivers/audio/wm8776.c index c9a9ebebcc88e804afcad37dd2f049780e594e3c..81c77fac0a173e000264bc4eeb7dc31a20f0c3f1 100644 --- a/drivers/audio/wm8776.c +++ b/drivers/audio/wm8776.c @@ -566,7 +566,7 @@ static void wm8776_senddone(FAR struct i2s_dev_s *i2s, CONFIG_WM8776_MSG_PRIO); if (ret < 0) { - auderr("ERROR: mq_send failed: %d\n", errno); + auderr("ERROR: mq_send failed: %d\n", get_errno()); } } @@ -913,7 +913,7 @@ static int wm8776_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, CONFIG_WM8776_MSG_PRIO); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); auderr("ERROR: mq_send failed: %d\n", errcode); diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c index 50fb2a7045d3e67087f461883a1d7f10230e417c..d917a8ee359cce532382b7bdbc7da63abb3ca7e8 100644 --- a/drivers/audio/wm8904.c +++ b/drivers/audio/wm8904.c @@ -247,7 +247,7 @@ const uint8_t g_fllratio[WM8904_NFLLRATIO] = /**************************************************************************** * Name: wm8904_readreg * - * Description + * Description: * Read the specified 16-bit register from the WM8904 device. * ****************************************************************************/ diff --git a/drivers/audio/wm8904.h b/drivers/audio/wm8904.h index e51d247c5f33ee01b846bab9198ab88d7da5e983..0ba1e16c9ffadf0c85b2cfb71efd10962702023c 100644 --- a/drivers/audio/wm8904.h +++ b/drivers/audio/wm8904.h @@ -1118,7 +1118,7 @@ extern const uint8_t g_fllratio[WM8904_NFLLRATIO]; /**************************************************************************** * Name: wm8904_readreg * - * Description + * Description: * Read the specified 16-bit register from the WM8904 device. * ****************************************************************************/ diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c index 84fbc81034fc53c47b1a6b954ef250ccec19fbf4..f9b8181e6cd5956e8a8d3731eee69289c37fe67a 100644 --- a/drivers/bch/bchdev_driver.c +++ b/drivers/bch/bchdev_driver.c @@ -314,7 +314,7 @@ static ssize_t bch_read(FAR struct file *filep, FAR char *buffer, size_t len) } /**************************************************************************** - * Name:bch_write + * Name: bch_write ****************************************************************************/ static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer, size_t len) diff --git a/drivers/can/can.c b/drivers/can/can.c index 7a590d5a73b114e5a00e991bf0e790d9961fc0f9..6232f70ee867996b7c340d8abf6bb4095963d814 100644 --- a/drivers/can/can.c +++ b/drivers/can/can.c @@ -239,7 +239,7 @@ static void can_pollnotify(FAR struct can_dev_s *dev, pollevent_t eventset) * standard CAN. In CAN FD mode, the values 9 to 15 are encoded to values * in the range 12 to 64. * - * Input Parameter: + * Input Parameters: * dlc - the DLC value to convert to a byte count * * Returned Value: @@ -288,7 +288,7 @@ static uint8_t can_dlc2bytes(uint8_t dlc) * standard CAN. In CAN FD mode, the values 9 to 15 are encoded to values * in the range 12 to 64. * - * Input Parameter: + * Input Parameters: * nbytes - the byte count to convert to a DLC value * * Returned Value: diff --git a/drivers/can/mcp2515.c b/drivers/can/mcp2515.c index 3b68c4d43b9d1dc22cd330f2e6a270e9258433ac..b8ce91bfeb70ad8abb8596591810e7789d26dfa1 100644 --- a/drivers/can/mcp2515.c +++ b/drivers/can/mcp2515.c @@ -2369,7 +2369,7 @@ static int mcp2515_interrupt(FAR struct mcp2515_config_s *config, FAR void *arg) * Description: * MCP2515 hardware initialization * - * Input Parameter: + * Input Parameters: * priv - A pointer to the private data structure for this MCP2515 peripheral * * Returned Value: @@ -2483,7 +2483,7 @@ static int mcp2515_hw_initialize(struct mcp2515_can_s *priv) * Description: * Initialize the selected MCP2515 CAN Bus Controller over SPI * - * Input Parameter: + * Input Parameters: * config - The configuration structure passed by the board. * * Returned Value: @@ -2554,7 +2554,7 @@ FAR struct mcp2515_can_s *mcp2515_instantiate(FAR struct mcp2515_config_s *confi * Description: * Initialize the selected MCP2515 CAN Bus Controller over SPI * - * Input Parameter: + * Input Parameters: * config - The configuration structure passed by the board. * * Returned Value: diff --git a/drivers/contactless/pn532.c b/drivers/contactless/pn532.c index 6f1d8fb531465e6ef9fd5e0533f7de63a8d26cc8..b62e5fa9f2c4df382ea0d3c14bffbeb08494c776 100644 --- a/drivers/contactless/pn532.c +++ b/drivers/contactless/pn532.c @@ -927,8 +927,8 @@ static int _close(FAR struct file *filep) * Description: * This routine is called when the device is read. * - * Returns TAG id as string to buffer. - * or -EIO if no TAG found + * Returned Value: + * TAG id as string to buffer or -EIO if no TAG found * ****************************************************************************/ diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index f2ea39ce1b1c307991f52162804e587253f6aa76..cbb6747c9e366794db4b6221cf6f6f771878c67b 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -5,11 +5,11 @@ if EEPROM config SPI_EE_25XX - bool "Microchip 25xxNNN / Atmel AT25NNN EEPROM devices" + bool "Microchip 25xxNNN / Atmel AT25NNN / ST M95NNN SPI EEPROM devices" default n depends on SPI ---help--- - This selection enables support for the Microchip/Atmel SPI EEPROM + This selection enables support for the Microchip/Atmel/ST SPI EEPROM devices if SPI_EE_25XX @@ -20,4 +20,22 @@ config EE25XX_SPIMODE depends on SPI_EE_25XX endif # SPI_EE_25XX + +config I2C_EE_24XX + bool "Microchip 24xxNNN / Atmel AT24NNN / ST M24NNN I2C EEPROM devices" + default n + depends on I2C + ---help--- + This selection enables support for the Microchip/Atmel/ST I2C EEPROM + devices + +if I2C_EE_24XX + +config EE24XX_FREQUENCY + int "I2C EEPROM frequency (100000 or 400000)" + default 100000 + depends on I2C_EE_24XX + +endif # I2C_EE_24XX + endif # EEPROM diff --git a/drivers/eeprom/Make.defs b/drivers/eeprom/Make.defs index afbebea625c340ff9bcad2d38ef4c44c5711a226..475399886eb8ebbf0a87261eac98f93e30545822 100644 --- a/drivers/eeprom/Make.defs +++ b/drivers/eeprom/Make.defs @@ -37,12 +37,18 @@ ifeq ($(CONFIG_EEPROM),y) -# Include the Microchip/Atmel xx25xx driver +# Include the Microchip/Atmel/ST xx25xx driver for SPI ifeq ($(CONFIG_SPI_EE_25XX),y) CSRCS += spi_xx25xx.c endif +# Include the Microchip/Atmel/ST xx24xx driver for I2C + +ifeq ($(CONFIG_I2C_EE_24XX),y) +CSRCS += i2c_xx24xx.c +endif + # Include build support DEPPATH += --dep-path eeprom diff --git a/drivers/eeprom/i2c_xx24xx.c b/drivers/eeprom/i2c_xx24xx.c new file mode 100644 index 0000000000000000000000000000000000000000..944e14e8564f69e53fe00787c4703e9270404da1 --- /dev/null +++ b/drivers/eeprom/i2c_xx24xx.c @@ -0,0 +1,772 @@ +/**************************************************************************** + * drivers/eeprom/i2c_xx24xx.c + * + * Copyright (C) 2018 Sebastien Lorquet. All rights reserved. + * Author: Sebastien Lorquet + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* This is a driver for I2C EEPROMs that use the same commands as the + * xx24xx. + * + * The following devices should be supported: + * + * Manufacturer Device Bytes PgSize AddrLen DevAddr + * Microchip + * 24xx00 16 1 1 1010000 Special case + * 24xx01 128 8 1 1010000 + * 24xx02 256 8 1 1010000 + * 24xx04 512 16 1 101000P + * 24xx08 1024 16 1 10100PP + * 24xx16 2048 16 1 1010PPP + * 24xx32 4096 32 2 1010AAA + * 24xx64 8192 32 2 1010AAA + * 24xx128 16384 64 2 1010AAA + * 24xx256 32768 64 2 1010AAA + * 24xx512 65536 128 2 1010AAA + * 24xx1025 131072 128 2 1010PAA Special case: address bit is shifted. + * 24xx1026 131072 128 2 1010AAP + * + * Atmel + * AT24C01 128 8 1 1010AAA + * AT24C02 256 8 1 1010AAA + * AT24C04 512 16 1 1010AAP P bits = word address + * AT24C08 1024 16 1 1010APP + * AT24C16 2048 16 1 1010PPP + * AT24C32 4096 32 2 1010AAA + * AT24C64 8192 32 2 1010AAA + * AT24C128 16384 64 2 10100AA + * AT24C256 32768 64 2 10100AA + * AT24C512 65536 128 2 10100AA + * AT24C1024 131072 256 2 10100AP + * + * ST Microelectronics + * M24C01 128 16 1 1010AAA + * M24C02 256 16 1 1010AAA + * M24C04 512 16 1 1010AAP + * M24C08 1024 16 1 1010APP + * M24C16 2048 16 1 1010PPP + * M24C32 4096 32 2 1010AAA ID pages supported as a separate device + * M24C64 8192 32 2 1010AAA + * M24128 16384 64 2 1010AAA + * M24256 32768 64 2 1010AAA + * M24512 65536 128 2 1010AAA + * M24M01 131072 256 2 1010AAP + * M24M02 262144 256 2 1010APP + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_EE24XX_FREQUENCY +#define CONFIG_EE24XX_FREQUENCY 100000 +#endif + +/**************************************************************************** + * Types + ****************************************************************************/ + +/* Device geometry description, compact form (2 bytes per entry) */ + +struct ee24xx_geom_s +{ + uint8_t bytes : 4; /* Power of two of 128 bytes (0:128 ... 11:262144) */ + uint8_t pagesize : 4; /* Power of two of 8 bytes (0:8 1:16 2:32 3:64 etc) */ + uint8_t addrlen : 4; /* Nr of bytes in command address field */ + uint8_t abits : 3; /* Nr of Address MSBits in the i2c device address LSBs*/ + uint8_t special : 1; /* Special device: uchip 24xx00 (total 16 bytes) + * or 24xx1025 (shifted P bits) */ +}; + +/* Private data attached to the inode */ + +struct ee24xx_dev_s +{ + /* Bus management */ + + struct i2c_master_s *i2c; /* I2C device where the EEPROM is attached */ + uint32_t freq; /* I2C bus speed */ + uint8_t addr; /* 7-bit unshifted I2C device address */ + + /* Driver management */ + + sem_t sem; /* file write access serialization */ + uint8_t refs; /* Nr of times the device has been opened */ + bool readonly; /* Flags */ + + /* Expanded from geometry */ + + uint32_t size; /* total bytes in device */ + uint16_t pgsize; /* write block size, in bytes */ + uint16_t addrlen; /* number of bytes in data addresses */ + uint16_t haddrbits; /* Number of bits in high address part */ + uint16_t haddrshift; /* bit-shift of high address part */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int ee24xx_open(FAR struct file *filep); +static int ee24xx_close(FAR struct file *filep); +static off_t ee24xx_seek(FAR struct file *filep, off_t offset, int whence); +static ssize_t ee24xx_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t ee24xx_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +static int ee24xx_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Supported device geometries. + * One geometry can fit more than one device. + * The user will use an enum'ed index from include/eeprom/i2c_xx24xx.h + */ + +static const struct ee24xx_geom_s g_ee24xx_devices[] = +{ + /* Microchip devices */ + +/* by pg al ab sp device bytes page alen */ + { 0, 1, 1, 0, 1}, /* 24xx00 16 1 1 Ridiculously small device */ + { 0, 0, 1, 0, 0}, /* 24xx01 128 8 1 */ + { 1, 0, 1, 0, 0}, /* 24xx02 256 8 1 */ + { 2, 1, 1, 1, 0}, /* 24xx04 512 16 1 */ + { 3, 1, 1, 2, 0}, /* 24xx08 1024 16 1 */ + { 4, 1, 1, 3, 0}, /* 24xx16 2048 16 1 */ + { 5, 2, 2, 0, 0}, /* 24xx32 4096 32 2 */ + { 6, 2, 2, 0, 0}, /* 24xx64 8192 32 2 */ + { 7, 3, 2, 0, 0}, /* 24xx128 16384 64 2 */ + { 8, 3, 2, 0, 0}, /* 24xx256 32768 64 2 */ + { 9, 4, 2, 0, 0}, /* 24xx512 65536 128 2 */ + {10, 4, 2, 1, 1}, /* 24xx1025 131072 128 2 Shifted address, todo */ + {10, 4, 2, 1, 0}, /* 24xx1026 131072 128 2 */ + + /* STM devices */ + + { 0, 1, 1, 0, 0}, /* M24C01 128 16 1 */ + { 1, 1, 1, 0, 0}, /* M24C02 256 16 1 */ + {11, 5, 2, 2, 0}, /* M24M02 262144 256 2 */ +}; + +/* Driver operations */ + +static const struct file_operations ee24xx_fops = +{ + ee24xx_open, /* open */ + ee24xx_close, /* close */ + ee24xx_read, /* read */ + ee24xx_write, /* write */ + ee24xx_seek, /* seek */ + ee24xx_ioctl /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + , 0 /* poll */ +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ee24xx_waitwritecomplete + * + * Use ACK polling to detect the completion of the write operation. + * Returns TRUE if write is complete (device replies to ACK). + * Note: The device always replies an ACK for the control byte, the polling + * shall be done using the ACK for the memory address byte. Read or write does + * not matter. + * Note: We should sleep a bit between retries, the write time is around 5 ms, + * but the bus is slow, so, a few retries at most will happen. + * + ****************************************************************************/ + +static int ee24xx_waitwritecomplete(FAR struct ee24xx_dev_s *eedev, + uint32_t memaddr) +{ + struct i2c_msg_s msgs[1]; + int ret; + int retries = 100; + uint8_t adr; + uint32_t addr_hi = (memaddr >> (eedev->addrlen << 3)); + + msgs[0].frequency = eedev->freq; + msgs[0].addr = eedev->addr | (addr_hi & ((1 << eedev->haddrbits) - 1)); + msgs[0].flags = I2C_M_READ; + msgs[0].buffer = &adr; + msgs[0].length = 1; + + do + { + ret = I2C_TRANSFER(eedev->i2c, msgs, 1); + retries--; + } + while(ret != 0 && retries > 0); + + return ret; +} + +/**************************************************************************** + * Name: ee24xx_writepage + * + * Description: Write data to the EEPROM, NOT crossing page boundaries. + * To avoid allocating a buffer to prepend the address, we are using 2 I2C + * messages while avoiding beginning the second one with a restart condition. + * + ****************************************************************************/ + +static int ee24xx_writepage(FAR struct ee24xx_dev_s *eedev, uint32_t memaddr, + FAR const char *buffer, size_t len) +{ + + struct i2c_msg_s msgs[2]; + uint8_t maddr[2]; + uint32_t addr_hi = (memaddr >> (eedev->addrlen << 3)); + + /* Write data address */ + + maddr[0] = memaddr >> 8; + maddr[1] = memaddr & 0xFF; + + msgs[0].frequency = eedev->freq; + msgs[0].addr = eedev->addr | (addr_hi & ((1 << eedev->haddrbits) - 1)); + msgs[0].flags = 0; + msgs[0].buffer = eedev->addrlen==2 ? &maddr[0] : &maddr[1]; + msgs[0].length = eedev->addrlen; + + /* Write data without a restart nor a control byte */ + + msgs[1].frequency = msgs[0].frequency; + msgs[1].addr = msgs[0].addr; + msgs[1].flags = I2C_M_NORESTART; + msgs[1].buffer = (uint8_t*)buffer; + msgs[1].length = len; + + return I2C_TRANSFER(eedev->i2c, msgs, 2); +} + +/**************************************************************************** + * Name: ee24xx_semtake + * + * Acquire a resource to access the device. + * The purpose of the semaphore is to block tasks that try to access the + * EEPROM while another task is actively using it. + * + ****************************************************************************/ + +static void ee24xx_semtake(FAR struct ee24xx_dev_s *eedev) +{ + /* Take the semaphore (perhaps waiting) */ + + while (sem_wait(&eedev->sem) != 0) + { + /* The only case that an error should occur here is if + * the wait was awakened by a signal. + */ + + DEBUGASSERT(errno == EINTR); + } +} + +/**************************************************************************** + * Name: ee24xx_semgive + * + * Release a resource to access the device. + * + ****************************************************************************/ + +static inline void ee24xx_semgive(FAR struct ee24xx_dev_s *eedev) +{ + sem_post(&eedev->sem); +} + +/**************************************************************************** + * Driver Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ee24xx_open + * + * Description: Open the block device + * + ****************************************************************************/ + +static int ee24xx_open(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct ee24xx_dev_s *eedev; + int ret = OK; + + DEBUGASSERT(inode && inode->i_private); + eedev = (FAR struct ee24xx_dev_s *)inode->i_private; + ee24xx_semtake(eedev); + + /* Increment the reference count */ + + if ((eedev->refs + 1) == 0) + { + ret = -EMFILE; + } + else + { + eedev->refs += 1; + } + + ee24xx_semgive(eedev); + return ret; +} + +/**************************************************************************** + * Name: ee24xx_close + * + * Description: Close the block device + * + ****************************************************************************/ + +static int ee24xx_close(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct ee24xx_dev_s *eedev; + int ret = OK; + + DEBUGASSERT(inode && inode->i_private); + eedev = (FAR struct ee24xx_dev_s *)inode->i_private; + ee24xx_semtake(eedev); + + /* Decrement the reference count. I want the entire close operation + * to be atomic wrt other driver operations. + */ + + if (eedev->refs == 0) + { + ret = -EIO; + } + else + { + eedev->refs -= 1; + } + + ee24xx_semgive(eedev); + return ret; +} + +/**************************************************************************** + * Name: ee24xx_seek + * + * Remark: Copied from bchlib + * + ****************************************************************************/ + +static off_t ee24xx_seek(FAR struct file *filep, off_t offset, int whence) +{ + FAR struct ee24xx_dev_s *eedev; + off_t newpos; + int ret; + FAR struct inode *inode = filep->f_inode; + + DEBUGASSERT(inode && inode->i_private); + eedev = (FAR struct ee24xx_dev_s *)inode->i_private; + ee24xx_semtake(eedev); + + /* Determine the new, requested file position */ + + switch (whence) + { + case SEEK_CUR: + newpos = filep->f_pos + offset; + break; + + case SEEK_SET: + newpos = offset; + break; + + case SEEK_END: + newpos = eedev->size + offset; + break; + + default: + /* Return EINVAL if the whence argument is invalid */ + + ee24xx_semgive(eedev); + return -EINVAL; + } + + /* Opengroup.org: + * + * "The lseek() function shall allow the file offset to be set beyond the end + * of the existing data in the file. If data is later written at this point, + * subsequent reads of data in the gap shall return bytes with the value 0 + * until data is actually written into the gap." + * + * We can conform to the first part, but not the second. But return EINVAL if + * + * "...the resulting file offset would be negative for a regular file, block + * special file, or directory." + */ + + if (newpos >= 0) + { + filep->f_pos = newpos; + ret = newpos; + finfo("SEEK newpos %d\n",newpos); + } + else + { + ret = -EINVAL; + } + + ee24xx_semgive(eedev); + return ret; +} + +/**************************************************************************** + * Name: ee24xx_read + ****************************************************************************/ + +static ssize_t ee24xx_read(FAR struct file *filep, FAR char *buffer, + size_t len) +{ + FAR struct ee24xx_dev_s *eedev; + FAR struct inode *inode = filep->f_inode; + struct i2c_msg_s msgs[2]; + uint8_t addr[2]; + uint32_t addr_hi; + int ret; + + DEBUGASSERT(inode && inode->i_private); + eedev = (FAR struct ee24xx_dev_s *)inode->i_private; + + ee24xx_semtake(eedev); + + /* trim len if read would go beyond end of device */ + + if ((filep->f_pos + len) > eedev->size) + { + len = eedev->size - filep->f_pos; + } + + if (len == 0) + { + /* We are at end of file */ + + ret = 0; + goto done; + } + + /* Write data address */ + + finfo("READ %d bytes at pos %d\n", len, filep->f_pos); + + addr_hi = (filep->f_pos >> (eedev->addrlen << 3)); + + addr[0] = (filep->f_pos) >> 8; + addr[1] = (filep->f_pos) & 0xFF; + + msgs[0].frequency = eedev->freq; + msgs[0].addr = eedev->addr | (addr_hi & ((1 << eedev->haddrbits) - 1)); + msgs[0].flags = 0; + msgs[0].buffer = eedev->addrlen==2 ? &addr[0] : &addr[1]; + msgs[0].length = eedev->addrlen; + + /* Read data */ + + msgs[1].frequency = msgs[0].frequency; + msgs[1].addr = msgs[0].addr; + msgs[1].flags = I2C_M_READ; + msgs[1].buffer = (uint8_t*)buffer; + msgs[1].length = len; + + ret = I2C_TRANSFER(eedev->i2c, msgs, 2); + if (ret < 0) + { + goto done; + } + + ret = len; + + /* Update the file position */ + + filep->f_pos += len; + +done: + ee24xx_semgive(eedev); + return ret; +} + +/**************************************************************************** + * Name: ee24xx_write + ****************************************************************************/ + +static ssize_t ee24xx_write(FAR struct file *filep, FAR const char *buffer, + size_t len) +{ + FAR struct ee24xx_dev_s *eedev; + size_t cnt; + int pageoff; + FAR struct inode *inode = filep->f_inode; + int ret = -EACCES; + int savelen; + + DEBUGASSERT(inode && inode->i_private); + eedev = (FAR struct ee24xx_dev_s *)inode->i_private; + + if (eedev->readonly) + { + return ret; + } + + /* Forbid writes past the end of the device */ + + if (filep->f_pos >= eedev->size) + { + return -EFBIG; + } + + finfo("Entering with len=%d\n", len); + + /* Clamp len to avoid crossing the end of the memory */ + + if ((len + filep->f_pos) > eedev->size) + { + len = eedev->size - filep->f_pos; + finfo("Len clamped to %d\n", len); + } + + savelen = len; /* save number of bytes written */ + + ee24xx_semtake(eedev); + + /* Writes can't happen in a row like the read does. + * The EEPROM is made of pages, and write sequences + * cannot cross page boundaries. So every time the last + * byte of a page is programmed, a separate I2C transaction + * required to continue writing. + */ + + /* First, write some page-unaligned data */ + + pageoff = filep->f_pos & (eedev->pgsize - 1); + cnt = eedev->pgsize - pageoff; + if (cnt > len) + { + cnt = len; + } + + if (pageoff > 0) + { + finfo("First %d unaligned bytes at %d (pageoff %d)\n", cnt, filep->f_pos, + pageoff); + + ret = ee24xx_writepage(eedev, filep->f_pos, buffer, cnt); + if (ret < 0) + { + ferr("write failed, ret = %d\n", ret); + goto done; + } + + ret = ee24xx_waitwritecomplete(eedev, filep->f_pos); + if (ret < 0) + { + ferr("writecomplete failed, ret = %d\n", ret); + goto done; + } + + len -= cnt; + buffer += cnt; + filep->f_pos += cnt; + } + + /* Then, write remaining bytes at page-aligned addresses */ + + while (len > 0) + { + cnt = len; + if (cnt > eedev->pgsize) + { + cnt = eedev->pgsize; + } + + finfo("Aligned page write for %d bytes at %d\n", cnt, filep->f_pos); + + ret = ee24xx_writepage(eedev, filep->f_pos, buffer, cnt); + if (ret < 0) + { + ferr("write failed, ret = %d\n", ret); + goto done; + } + + ret = ee24xx_waitwritecomplete(eedev, filep->f_pos); + if (ret < 0) + { + ferr("writecomplete failed, ret = %d\n", ret); + goto done; + } + + len -= cnt; + buffer += cnt; + filep->f_pos += cnt; + } + + ret = savelen; + +done: + ee24xx_semgive(eedev); + return ret; +} + +/**************************************************************************** + * Name: ee24xx_ioctl + * + * Description: TODO: Erase a sector/page/device or read device ID / MAC. + * This is completely optional. + * + ****************************************************************************/ + +static int ee24xx_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + FAR struct ee24xx_dev_s *eedev; + FAR struct inode *inode = filep->f_inode; + int ret = 0; + + DEBUGASSERT(inode && inode->i_private); + eedev = (FAR struct ee24xx_dev_s *)inode->i_private; + + switch (cmd) + { + default: + (void)eedev; + ret = -EINVAL; + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ee24xx_initialize + * + * Description: Bind a EEPROM driver to an I2C bus. The user MUST provide + * a description of the device geometry, since it is not possible to read + * this information from the device (contrary to the SPI flash devices). + * + ****************************************************************************/ + +int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr, + FAR char *devname, int devtype, int readonly) +{ + FAR struct ee24xx_dev_s *eedev; + + /* Check device type early */ + + if ((devtype < 0) || + (devtype >= sizeof(g_ee24xx_devices) / sizeof(g_ee24xx_devices[0]))) + { + return -EINVAL; + } + + eedev = kmm_zalloc(sizeof(struct ee24xx_dev_s)); + + if (!eedev) + { + return -ENOMEM; + } + + sem_init(&eedev->sem, 0, 1); + + eedev->freq = CONFIG_EE24XX_FREQUENCY; + eedev->i2c = bus; + eedev->addr = devaddr; + eedev->readonly = !!readonly; + + /* Expand device geometry from compacted info */ + + eedev->size = 128 << g_ee24xx_devices[devtype].bytes; + eedev->pgsize = 8 << g_ee24xx_devices[devtype].pagesize; + eedev->addrlen = g_ee24xx_devices[devtype].addrlen; + eedev->haddrbits = g_ee24xx_devices[devtype].abits; + eedev->haddrshift = 0; + + /* Apply special properties */ + + if (g_ee24xx_devices[devtype].special) + { + if (devtype == EEPROM_24xx00) + { + /* Ultra small 16-byte EEPROM */ + + eedev->size = 16; + + /* The device only has BYTE write, + * which is emulated with 1-byte pages + */ + + eedev->pgsize = 1; + } + else if (devtype == EEPROM_24xx1025) + { + /* Microchip alien part where the address MSB is << 2 bits */ + + ferr("Device 24xx1025 is not supported for the moment, TODO.\n"); + + eedev->haddrshift = 2; + free(eedev); + return -ENODEV; + } + } + + finfo("EEPROM device %s, %d bytes, %d per page, addrlen %d, %s\n", + devname, eedev->size, eedev->pgsize, eedev->addrlen, + eedev->readonly ? "readonly" : ""); + + return register_driver(devname, &ee24xx_fops, 0666, eedev); +} diff --git a/drivers/input/ads7843e.c b/drivers/input/ads7843e.c index 195aaa026065f09ad852c4a58694004953d6ab71..225d33e765ad5ff12bc986820ed3d8c3df3558d4 100644 --- a/drivers/input/ads7843e.c +++ b/drivers/input/ads7843e.c @@ -225,7 +225,7 @@ static void ads7843e_unlock(FAR struct spi_dev_s *spi) /**************************************************************************** * Name: ads7843e_sendcmd * - * Description. + * Description: * The command/data sequences is as follows: * * DCLK @@ -607,7 +607,8 @@ static void ads7843e_worker(FAR void *arg) * later. */ - wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv); + (void)wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, + (uint32_t)priv); goto ignored; } else @@ -974,7 +975,7 @@ errout: } /**************************************************************************** - * Name:ads7843e_ioctl + * Name: ads7843e_ioctl ****************************************************************************/ static int ads7843e_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/drivers/input/ajoystick.c b/drivers/input/ajoystick.c index bed67d18901fc39e5232628ce466cd65d9ef306f..233807ddd0d1997f5084533d1a3186ee499ede60 100644 --- a/drivers/input/ajoystick.c +++ b/drivers/input/ajoystick.c @@ -842,7 +842,7 @@ errout_with_dusem: * lower - An instance of the platform-specific analog joystick lower * half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/drivers/input/button_upper.c b/drivers/input/button_upper.c index c172ecfa1dc6faecbd31bb8ad2cead3e5f1473af..b60e77f60d99a7d028a4bd32871a910609bcf03b 100644 --- a/drivers/input/button_upper.c +++ b/drivers/input/button_upper.c @@ -823,7 +823,7 @@ errout_with_dusem: * minor device number. * lower - An instance of the platform-specific button lower half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/drivers/input/djoystick.c b/drivers/input/djoystick.c index 6ada3f76e1ebdda0f1bcbadf942de1dfc8948a30..3854e22c93d923ee3f2d8a48be3f824e5b6c8200 100644 --- a/drivers/input/djoystick.c +++ b/drivers/input/djoystick.c @@ -837,7 +837,7 @@ errout_with_dusem: * lower - An instance of the platform-specific discrete joystick lower * half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/drivers/input/ft5x06.c b/drivers/input/ft5x06.c index 25bd5f1551403291a1fb61898ce5991eb02d2a20..0afc495662249b63f851fd8cbf8479a96fe1b179 100644 --- a/drivers/input/ft5x06.c +++ b/drivers/input/ft5x06.c @@ -364,15 +364,9 @@ static void ft5x06_data_worker(FAR void *arg) } #ifdef CONFIG_FT5X06_POLLMODE - /* Exit, re-starting the poll (unless there is no longer any task waiting - * for touch data). - */ + /* Exit, re-starting the poll. */ - if (priv->nwaiters > 0) - { - (void)wd_start(priv->polltimer, priv->delay, ft5x06_poll_timeout, 1, - priv); - } + (void)wd_start(priv->polltimer, priv->delay, ft5x06_poll_timeout, 1, priv); #else /* Exit, re-enabling FT5x06 interrupts */ @@ -398,14 +392,11 @@ static void ft5x06_poll_timeout(int argc, wdparm_t arg1, ...) * required to protected the work queue. */ - if (priv->nwaiters > 0) + DEBUGASSERT(priv->work.worker == NULL); + ret = work_queue(HPWORK, &priv->work, ft5x06_data_worker, priv, 0); + if (ret != 0) { - DEBUGASSERT(priv->work.worker == NULL); - ret = work_queue(HPWORK, &priv->work, ft5x06_data_worker, priv, 0); - if (ret != 0) - { - ierr("ERROR: Failed to queue work: %d\n", ret); - } + ierr("ERROR: Failed to queue work: %d\n", ret); } } #endif @@ -682,25 +673,6 @@ static ssize_t ft5x06_waitsample(FAR struct ft5x06_dev_s *priv, priv->nwaiters++; -#ifdef CONFIG_FT5X06_POLLMODE - /* The poll timer is stopped when there are no waiters. So we may - * need to restart with at the maximum rate. - */ - - if (priv->nwaiters == 1) - { - priv->delay = POLL_MINDELAY; - - ret = wd_start(priv->polltimer, priv->delay, ft5x06_poll_timeout, - 1, priv); - if (ret < 0) - { - ierr("ERROR: nxsem_wait failed: %d\n", ret); - goto errout; - } - } -#endif - /* Wait for a change in the FT5x06 state */ ret = nxsem_wait(&priv->waitsem); @@ -1005,7 +977,7 @@ errout: } /**************************************************************************** - * Name:ft5x06_ioctl + * Name: ft5x06_ioctl ****************************************************************************/ static int ft5x06_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/drivers/input/max11802.c b/drivers/input/max11802.c index 1e40178df0fed6249cf68764c9c4c48f31eb708a..435ea30d2162d20a3855d80d389ebacd144315c0 100644 --- a/drivers/input/max11802.c +++ b/drivers/input/max11802.c @@ -592,8 +592,8 @@ static void max11802_worker(FAR void *arg) iinfo("Previous pen up event still in buffer\n"); max11802_notify(priv); - wd_start(priv->wdog, MAX11802_WDOG_DELAY, max11802_wdog, 1, - (uint32_t)priv); + (void)wd_start(priv->wdog, MAX11802_WDOG_DELAY, max11802_wdog, 1, + (uint32_t)priv); goto ignored; } else @@ -632,8 +632,8 @@ static void max11802_worker(FAR void *arg) /* Continue to sample the position while the pen is down */ - wd_start(priv->wdog, MAX11802_WDOG_DELAY, max11802_wdog, 1, - (uint32_t)priv); + (void)wd_start(priv->wdog, MAX11802_WDOG_DELAY, max11802_wdog, 1, +i (uint32_t)priv); /* Check if data is valid */ @@ -981,7 +981,7 @@ errout: } /**************************************************************************** - * Name:max11802_ioctl + * Name: max11802_ioctl ****************************************************************************/ static int max11802_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/drivers/input/mxt.c b/drivers/input/mxt.c index af0f3bff985d8ddbd90efbf6889dd95abda9e8e2..37a6467ffa9900fa439feeaf517da9b909c51423 100644 --- a/drivers/input/mxt.c +++ b/drivers/input/mxt.c @@ -1499,7 +1499,7 @@ errout: } /**************************************************************************** - * Name:mxt_ioctl + * Name: mxt_ioctl ****************************************************************************/ static int mxt_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/drivers/input/nunchuck.c b/drivers/input/nunchuck.c index ccd591802a637a4cbb40423be9326ed01d963bf6..b1b2df93f3e54e6ea7844e18eb43fffa2c47d9f6 100644 --- a/drivers/input/nunchuck.c +++ b/drivers/input/nunchuck.c @@ -567,7 +567,7 @@ static int nunchuck_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * minor device number. * i2c - An instance of the platform-specific I2C connected to Nunchuck. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/drivers/input/tsc2007.c b/drivers/input/tsc2007.c index 65c57304b01c81db52553d4fc05218d76ce355d5..fdaec441122066a8c792e98e4c58518e72597919 100644 --- a/drivers/input/tsc2007.c +++ b/drivers/input/tsc2007.c @@ -1029,7 +1029,7 @@ errout: } /**************************************************************************** - * Name:tsc2007_ioctl + * Name: tsc2007_ioctl ****************************************************************************/ static int tsc2007_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/drivers/lcd/Kconfig b/drivers/lcd/Kconfig index 3cb4769d14da70a011670e5788ee922503826277..364cc185ce11b8750d56ecca4698dfeb37fb77de 100644 --- a/drivers/lcd/Kconfig +++ b/drivers/lcd/Kconfig @@ -395,7 +395,6 @@ config LCD_UG2864HSWEG01 config LCD_UG2832HSWEG04 bool "UG-2832HSWEG04 OLED Display Module (SSD1306)" default n - depends on !LCD_UG2864HSWEG01 select LCD_SSD1306 ---help--- OLED Display Module, UG-UG2832HSWEG04, Univision Technology Inc @@ -412,7 +411,6 @@ config LCD_UG2832HSWEG04 config LCD_DD12864WO4A bool "DD-12864WO-4A OLED Display Module" default n - depends on !LCD_UG2864HSWEG01 && !LCD_UG2832HSWEG04 select LCD_SSD1306 select SPI_CMDDATA ---help--- @@ -427,6 +425,18 @@ config LCD_DD12864WO4A Required SPI driver settings: SPI_CMDDATA - Include support for cmd/data selection. +config LCD_HILETGO + bool "HiletGO 128x64 OLED" + default n + select LCD_SSD1306 + select SPI_CMDDATA + ---help--- + HiletGo 129x64 OLED Display Module, featuring an SSD1306. + + Required LCD driver settings: + LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted. + LCD_MAXPOWER should be 1: 0=off, 1=on + config LCD_SSD1306 bool @@ -482,9 +492,11 @@ if LCD_SSD1306_I2C config SSD1306_I2CADDR int "SSD1306 I2C Address" - default 120 + default 60 ---help--- - I2C Address of SSD1306 + 7-bit I2C Address of SSD1306. Typical addresses are 0x3c (60) or + 0x3d (61). NOTE that these correspond to the 8-bit addresses + 0x78 or 0x7a that you may see in documentation. config SSD1306_I2CFREQ int "SSD1306 I2C Frequency" diff --git a/drivers/lcd/ili9341.c b/drivers/lcd/ili9341.c index ad31db450e947cefdaf17135c84f6f3be8451728..b55404fb2c783b671deb7a3385d3cc493cb2c600 100644 --- a/drivers/lcd/ili9341.c +++ b/drivers/lcd/ili9341.c @@ -532,7 +532,7 @@ static struct ili9341_dev_s g_lcddev[CONFIG_LCD_ILI9341_NINTERFACES] = * Parameters: * dev - Reference to private driver structure * - * Return Value: + * Returned Value: * * Horicontal resolution * @@ -560,7 +560,7 @@ static inline uint16_t ili9341_getxres(FAR struct ili9341_dev_s *dev) * Parameter: * dev - Reference to private driver structure * - * Return Value: + * Returned Value: * * Vertical resolution * diff --git a/drivers/lcd/lcd_framebuffer.c b/drivers/lcd/lcd_framebuffer.c index 369d774a214b9e754a9224b4e5c4b91bbaea7032..b97b10d25ed84ca6fb8b0079e67b1219c6c32a4b 100644 --- a/drivers/lcd/lcd_framebuffer.c +++ b/drivers/lcd/lcd_framebuffer.c @@ -51,7 +51,6 @@ #include #include #include -#include #ifdef CONFIG_LCD_FRAMEBUFFER @@ -451,7 +450,7 @@ static int lcdfb_setcursor(FAR struct fb_vtable_s *vtable, * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -598,7 +597,7 @@ errout_with_state: * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/drivers/lcd/pcd8544.h b/drivers/lcd/pcd8544.h index 9b03af94078874884cf09ade44e39b9134c57281..8bbf36c0e1e97b2575eae7507668c38be5d95894 100644 --- a/drivers/lcd/pcd8544.h +++ b/drivers/lcd/pcd8544.h @@ -1,6 +1,5 @@ /************************************************************************************** * drivers/lcd/pcd8544.h - * * Definitions for the PCD8544 LCD Display * * Copyright (C) 2017 Alan Carvalho de Assis. All rights reserved. diff --git a/drivers/lcd/ssd1306.h b/drivers/lcd/ssd1306.h index 415f0cf94931fa2889a4def9367b9facc5ed8477..787ec92312962ff5edb3a13e3e10fb1fdf4fce88 100644 --- a/drivers/lcd/ssd1306.h +++ b/drivers/lcd/ssd1306.h @@ -65,7 +65,8 @@ #endif #if !defined(CONFIG_LCD_SH1106_OLED_132) && !defined(CONFIG_LCD_UG2864HSWEG01) && \ - !defined(CONFIG_LCD_UG2832HSWEG04) && !defined(CONFIG_LCD_DD12864WO4A) + !defined(CONFIG_LCD_UG2832HSWEG04) && !defined(CONFIG_LCD_DD12864WO4A) && \ + !defined(CONFIG_LCD_HILETGO) # error "Unknown and unsupported SSD1306 LCD" #endif @@ -171,6 +172,13 @@ # define SSD1306_DEV_PAGES 8 /* 8 pages */ # define SSD1306_DEV_CMNPAD 0x12 /* COM configuration */ # undef IS_SSD1309 +#elif defined(CONFIG_LCD_HILETGO) +# define SSD1306_DEV_NATIVE_XRES 128 /* Only 128 of 132 columns supported */ +# define SSD1306_DEV_NATIVE_YRES 64 /* 8 pages each 8 rows */ +# define SSD1306_DEV_XOFFSET 0 /* Offset to logical column 0 */ +# define SSD1306_DEV_PAGES 8 /* 8 pages */ +# define SSD1306_DEV_CMNPAD 0x12 /* COM configuration */ +# undef IS_SSD1309 #elif defined(CONFIG_LCD_DD12864WO4A) # define SSD1306_DEV_NATIVE_XRES 128 /* 128 of 128 columns used */ # define SSD1306_DEV_NATIVE_YRES 64 /* 8 pages each 8 rows */ @@ -275,7 +283,7 @@ struct ssd1306_dev_s #ifdef CONFIG_LCD_SSD1306_SPI FAR struct spi_dev_s *spi; /* Cached SPI device reference */ #else - FAR struct i2c_master_s *i2c; /* Cached SPI device reference */ + FAR struct i2c_master_s *i2c; /* Cached I2C device reference */ uint8_t addr; /* 7-bit I2C address */ #endif uint8_t contrast; /* Current contrast setting */ diff --git a/drivers/lcd/ssd1306_base.c b/drivers/lcd/ssd1306_base.c index 9c3817f6067f5c9cbb73846455aaaa94c83ccc5c..6c98742264514b068c17c6965ca77cbc03458626 100644 --- a/drivers/lcd/ssd1306_base.c +++ b/drivers/lcd/ssd1306_base.c @@ -1,5 +1,5 @@ /************************************************************************************** - * drivers/lcd/ssd1306.c + * drivers/lcd/ssd1306_base.c * Driver for Univision UG-2864HSWEG01 OLED display or UG-2832HSWEG04 both with the * Univision SSD1306 controller in SPI mode and Densitron DD-12864WO-4A with SSD1309 * in SPI mode. diff --git a/drivers/leds/rgbled.c b/drivers/leds/rgbled.c index 0ba2229bdb424b627221adca4d92484669ae508e..1bb4e89f724e1e02374c4686788c1d609a8f17a7 100644 --- a/drivers/leds/rgbled.c +++ b/drivers/leds/rgbled.c @@ -420,7 +420,7 @@ static ssize_t rgbled_write(FAR struct file *filep, FAR const char *buffer, * be used by application code. * * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name all PWM drivers * as "/dev/rgdbled0", "/dev/rgbled1", etc. where the driver path diff --git a/drivers/leds/userled_upper.c b/drivers/leds/userled_upper.c index f851f33cce43452ca208f9a16c80aab221d8cbbd..ef414cda8124e29d22405ef7db2c87a0492ed631 100644 --- a/drivers/leds/userled_upper.c +++ b/drivers/leds/userled_upper.c @@ -527,7 +527,7 @@ static int userled_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * minor device number. * lower - An instance of the platform-specific LED lower half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/drivers/loop/losetup.c b/drivers/loop/losetup.c index 32c2f4d4374ac00b4e134492fcc4273e2a713c41..0a18eaff9255da42f48cffa7f8ddb9c5ff7f9591 100644 --- a/drivers/loop/losetup.c +++ b/drivers/loop/losetup.c @@ -234,7 +234,7 @@ static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer, FAR struct loop_struct_s *dev; ssize_t nbytesread; off_t offset; - int ret; + off_t ret; DEBUGASSERT(inode && inode->i_private); dev = (FAR struct loop_struct_s *)inode->i_private; @@ -249,10 +249,9 @@ static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer, offset = start_sector * dev->sectsize + dev->offset; ret = file_seek(&dev->devfile, offset, SEEK_SET); - if (ret == (off_t)-1) + if (ret < 0) { - ferr("ERROR: Seek failed for offset=%d: %d\n", - (int)offset, get_errno()); + ferr("ERROR: Seek failed for offset=%d: %d\n", (int)offset, (int)ret); return -EIO; } @@ -290,7 +289,7 @@ static ssize_t loop_write(FAR struct inode *inode, FAR struct loop_struct_s *dev; ssize_t nbyteswritten; off_t offset; - int ret; + off_t ret; DEBUGASSERT(inode && inode->i_private); dev = (FAR struct loop_struct_s *)inode->i_private; @@ -299,10 +298,9 @@ static ssize_t loop_write(FAR struct inode *inode, offset = start_sector * dev->sectsize + dev->offset; ret = file_seek(&dev->devfile, offset, SEEK_SET); - if (ret == (off_t)-1) + if (ret < 0) { - ferr("ERROR: Seek failed for offset=%d: %d\n", - (int)offset, get_errno()); + ferr("ERROR: Seek failed for offset=%d: %d\n", (int)offset, (int)ret); } /* Then write the requested number of sectors to that position */ @@ -440,7 +438,7 @@ int losetup(FAR const char *devname, FAR const char *filename, { /* If that fails, then try to open the device read-only */ - fd = open(filename, O_RDWR); + fd = open(filename, O_RDONLY); if (fd < 0) { ret = -get_errno(); diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 3d89028701010345b3e1c48a1ba48659df40af4c..9cb491feb7def6eb024f3cab47c8ab65c43af3c4 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -1895,6 +1895,25 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, } } + /* If Controller does not need DMA setup before the write then send CMD25 + * now. + */ + + if ((priv->caps & SDIO_CAPS_DMABEFOREWRITE) == 0) + { + /* Send CMD25, WRITE_MULTIPLE_BLOCK, and verify that good R1 status + * is returned + */ + + mmcsd_sendcmdpoll(priv, MMCSD_CMD25, offset); + ret = mmcsd_recvR1(priv, MMCSD_CMD25); + if (ret != OK) + { + ferr("ERROR: mmcsd_recvR1 for CMD25 failed: %d\n", ret); + return ret; + } + } + /* Configure SDIO controller hardware for the write transfer */ SDIO_BLOCKSETUP(priv->dev, priv->blocksize, nblocks); @@ -1923,24 +1942,30 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, priv->wrbusy = true; - /* Send CMD25, WRITE_MULTIPLE_BLOCK, and verify that good R1 status - * is returned - */ + /* If Controller needs DMA setup before write then only send CMD25 now. */ - mmcsd_sendcmdpoll(priv, MMCSD_CMD25, offset); - ret = mmcsd_recvR1(priv, MMCSD_CMD25); - if (ret != OK) + if ((priv->caps & SDIO_CAPS_DMABEFOREWRITE) != 0) { - ferr("ERROR: mmcsd_recvR1 for CMD25 failed: %d\n", ret); - return ret; + /* Send CMD25, WRITE_MULTIPLE_BLOCK, and verify that good R1 status + * is returned + */ + + mmcsd_sendcmdpoll(priv, MMCSD_CMD25, offset); + ret = mmcsd_recvR1(priv, MMCSD_CMD25); + if (ret != OK) + { + ferr("ERROR: mmcsd_recvR1 for CMD25 failed: %d\n", ret); + return ret; + } } /* Wait for the transfer to complete */ - ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR, nblocks * MMCSD_BLOCK_WDATADELAY); + ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR, + nblocks * MMCSD_BLOCK_WDATADELAY); if (ret != OK) { - ferr("ERROR: CMD18 transfer failed: %d\n", ret); + ferr("ERROR: CMD25 transfer failed: %d\n", ret); return ret; } diff --git a/drivers/mtd/at24xx.c b/drivers/mtd/at24xx.c index f08cec9d618adf963773c00ff311bce6916e8617..a09b948db2cfd5fa493618e9d67b763f6080e0c6 100644 --- a/drivers/mtd/at24xx.c +++ b/drivers/mtd/at24xx.c @@ -86,9 +86,9 @@ /* Get the part configuration based on the size configuration */ -#if CONFIG_AT24XX_SIZE == 2 /* AT24C02: 2Kbits = 256; 16 * 16 = 256 */ -# define AT24XX_NPAGES 16 -# define AT24XX_PAGESIZE 16 +#if CONFIG_AT24XX_SIZE == 2 /* AT24C02: 2Kbits = 256; 32 * 8 = 256 */ +# define AT24XX_NPAGES 32 +# define AT24XX_PAGESIZE 8 # define AT24XX_ADDRSIZE 1 #elif CONFIG_AT24XX_SIZE == 4 /* AT24C04: 4Kbits = 512B; 32 * 16 = 512 */ # define AT24XX_NPAGES 32 diff --git a/drivers/mtd/hamming.c b/drivers/mtd/hamming.c index 95d192db11f2360ac514e3a8d2460e9c725ba32f..7628e9d4d0113a7f50c997ae80c0a941f0be71eb 100644 --- a/drivers/mtd/hamming.c +++ b/drivers/mtd/hamming.c @@ -65,7 +65,7 @@ * Input Parameters: * bytes - The byte to use. * - * Returned Values: + * Returned Value: * Returns the number of bits set to '1' in the given byte. * ****************************************************************************/ @@ -95,7 +95,7 @@ static unsigned int hamming_bitsinbyte(uint8_t byte) * Input Parameters: * code - Hamming code * - * Returned Values: + * Returned Value: * Returns the number of bits set to '1' in the given hamming code. * ****************************************************************************/ @@ -117,7 +117,7 @@ static uint8_t hamming_bitsincode256(FAR uint8_t *code) * data - Data buffer to calculate code * code - Pointer to a buffer where the code should be stored * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -272,7 +272,7 @@ static void hamming_compute256(FAR const uint8_t *data, FAR uint8_t *code) * data - Data buffer to check * original - Hamming code to use for verifying the data * - * Returned Values: + * Returned Value: * Zero on success, otherwise returns a HAMMING_ERROR_ code. * ****************************************************************************/ @@ -372,7 +372,7 @@ static int hamming_verify256(FAR uint8_t *data, FAR const uint8_t *original) * size - Data size in bytes * code - Codes buffer * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -408,7 +408,7 @@ void hamming_compute256x(FAR const uint8_t *data, size_t size, uint8_t *code) * size - Size of the data in bytes * code - Original codes * - * Returned Values: + * Returned Value: * Return 0 if the data is correct, HAMMING_ERROR_SINGLEBIT if one or more * block(s) have had a single bit corrected, or either HAMMING_ERROR_ECC * or HAMMING_ERROR_MULTIPLEBITS. diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index 9a0d4077c13c2fb9c3698c723c2eefd6205746e5..32a2a72e59343fc28eb206d1172c6983d0d82d83 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -336,7 +336,7 @@ errout: * * Locates the first config entry, even if it is empty. * - * Returns: + * Returned Value: * offset to the start of the entry. * ****************************************************************************/ @@ -435,7 +435,7 @@ static int mtdconfig_findfirstentry(FAR struct mtdconfig_struct_s *dev, * * Locates the next config entry starting at offset, even if it is empty. * - * Returns: + * Returned Value: * offset to the start of the next entry. * ****************************************************************************/ @@ -562,7 +562,7 @@ read_next: * method of consolidation is used when only a single erase * block is available in the partition. * - * Returns: + * Returned Value: * offset to the next available entry (after consolidation).. * ****************************************************************************/ @@ -719,7 +719,7 @@ errout: * erased block. It erases all blocks to the end of the * partition as it goes. * - * Returns: + * Returned Value: * offset to the next available entry (after consolidation).. * ****************************************************************************/ diff --git a/drivers/mtd/mtd_nand.c b/drivers/mtd/mtd_nand.c index 8394af67de61a869d55b6e5b6063d394c66ffe3e..09586f7e1ca67d0132f255782333222c2522b303 100644 --- a/drivers/mtd/mtd_nand.c +++ b/drivers/mtd/mtd_nand.c @@ -372,7 +372,7 @@ static uint32_t nand_chipid(struct nand_raw_s *raw) * block Number of block to erase * scrub True: Erase bad blocks * - * Returned Value + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ @@ -438,13 +438,13 @@ static int nand_eraseblock(FAR struct nand_dev_s *nand, off_t block, * Reads the data area (only) of a page of a NAND FLASH into the * provided buffer. * - * Input parameters: + * Input Parameters: * nand - Upper-half, NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * - * Returned value. + * Returned Value: * OK is returned in success; a negated errno value is returned on failure. * ****************************************************************************/ @@ -493,13 +493,13 @@ static int nand_readpage(FAR struct nand_dev_s *nand, off_t block, * Writes the data area (only) of a page into NAND FLASH from the * provided buffer. * - * Input parameters: + * Input Parameters: * nand - Upper-half, NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * - * Returned value. + * Returned Value: * OK is returned in success; a negated errno value is returned on failure. * ****************************************************************************/ @@ -836,7 +836,7 @@ static int nand_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg) * Description: * Probe and initialize NAND. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * cmdaddr - NAND command address base * addraddr - NAND address address base @@ -844,7 +844,7 @@ static int nand_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg) * model - A pointer to the model data (probably in the raw MTD * driver instance. * - * Returned value. + * Returned Value: * A non-NULL MTD driver intstance is returned on success. NULL is * returned on any failaure. * diff --git a/drivers/mtd/mtd_nandecc.c b/drivers/mtd/mtd_nandecc.c index e22bc23175a69553a457c13ba92cdb11b5c0a880..47fb3b31be248d983d2f9ac1a612b67ef1ebbbfa 100644 --- a/drivers/mtd/mtd_nandecc.c +++ b/drivers/mtd/mtd_nandecc.c @@ -75,14 +75,14 @@ * the spare area. If a buffer pointer is NULL, then the corresponding area * is not saved. * - * Input parameters: + * Input Parameters: * nand - Upper-half, NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in success; a negated errno value is returned on failure. * ****************************************************************************/ @@ -166,14 +166,14 @@ int nandecc_readpage(FAR struct nand_dev_s *nand, off_t block, * If no spare buffer is provided, the spare area is still written with the * ECC information calculated on the data buffer. * - * Input parameters: + * Input Parameters: * nand - Upper-half, NAND FLASH interface * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer containing the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in success; a negated errno value is returned on failure. * ****************************************************************************/ diff --git a/drivers/mtd/mtd_nandmodel.c b/drivers/mtd/mtd_nandmodel.c index cd3c324c9c3c033f76b5c8cf15a8ad38f56d6d66..2b9c09472badc4561548eb7cd704f5de0b6dccd4 100644 --- a/drivers/mtd/mtd_nandmodel.c +++ b/drivers/mtd/mtd_nandmodel.c @@ -76,7 +76,7 @@ * chipid Identifier returned by the Nand(id1|(id2<<8)|(id3<<16)|(id4<<24)). * model nand_model_s instance to update with the model parameters. * - * Returned Values: + * Returned Value: * OK is returned on success; -ENODEV is returned on failure. * ****************************************************************************/ @@ -186,7 +186,7 @@ int nandmodel_find(FAR const struct nand_model_s *modeltab, size_t size, * page Stores the first accessed page number inside the first block. * offset Stores the byte offset inside the first accessed page. * - * Returned Values: + * Returned Value: * OK on success; -EPIPE on failure. * ****************************************************************************/ @@ -252,7 +252,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * size of spare area in bytes * ****************************************************************************/ diff --git a/drivers/mtd/mtd_nandscheme.c b/drivers/mtd/mtd_nandscheme.c index cf0557f22ab1fbb85eda8754479eebbb0882e7ce..17269bb09d20690d07d5a1ed12693f02fc8e5c97 100644 --- a/drivers/mtd/mtd_nandscheme.c +++ b/drivers/mtd/mtd_nandscheme.c @@ -182,7 +182,7 @@ const struct nand_scheme_s g_nand_sparescheme4096 = * spare Spare area buffer. * marker Pointer to the variable to store the bad block marker. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -206,7 +206,7 @@ void nandscheme_readbadblockmarker(FAR const struct nand_scheme_s *scheme, * spare Spare area buffer. * marker Bad block marker to write. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -228,7 +228,7 @@ void nandscheme_writebadblockmarker(FAR const struct nand_scheme_s *scheme, * spare Spare area buffer. * ecc ECC buffer. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -255,7 +255,7 @@ void nandscheme_readecc(FAR const struct nand_scheme_s *scheme, * spare Spare area buffer. * ecc ECC buffer. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -285,7 +285,7 @@ void nandscheme_writeecc(FAR const struct nand_scheme_s *scheme, * size Number of extra bytes to read. * offset Index where to read the first extra byte. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -318,7 +318,7 @@ void nandscheme_readextra(FAR const struct nand_scheme_s *scheme, * size Number of extra bytes to write. * offset Index where to write the first extra byte. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -349,7 +349,7 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme, * size Number of extra bytes to write. * offset Index where to write the first extra byte. * - * Returned Values: + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/drivers/mtd/mtd_partition.c b/drivers/mtd/mtd_partition.c index f8438cdd97640e9f2f3e65ea7bd7c01eb032ea49..54c88e981624972d151e37f5fd1f9b066fcc8817 100644 --- a/drivers/mtd/mtd_partition.c +++ b/drivers/mtd/mtd_partition.c @@ -767,7 +767,7 @@ static int part_procfs_stat(const char *relpath, struct stat *buf) * partitions, that mutual exclusion would be provided by the file system * above the FLASH driver. * - * Input parameters: + * Input Parameters: * mtd - The MTD device to be partitioned * firstblock - The offset in bytes to the first block * nblocks - The number of blocks in the partition diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index b6cfa6dfb74a3dcc3da3269a18b9d419b5e7d46a..c55c222a99c54e8d6cd90ef82c717076f99d361f 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -1948,7 +1948,7 @@ int dm9x_initialize(void) #endif g_dm9x[0].dm_dev.d_private = (FAR void *)g_dm9x; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ g_dm9x[0].dm_txpoll = wd_create(); /* Create periodic poll timer */ g_dm9x[0].dm_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 23c4c77067144434aff3299df8f8e1cc462f8a8c..9c45d4b115bc9a9fcc9bc3c11ef2001f892fcacd 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -2632,7 +2632,7 @@ int enc_initialize(FAR struct spi_dev_s *spi, #endif priv->dev.d_private = priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index 5c2b590e2e5253ddd4738dc8b5cb72b2d4b9b2b0..31732a0b68793985d35db1d7236a53ca4755a045 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -2815,7 +2815,7 @@ int enc_initialize(FAR struct spi_dev_s *spi, #endif priv->dev.d_private = priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 9acc93d643b8b4bdf2aebf8fa7844c3362627413..cb7749706f2d15ffc08d0d58579ed7cf9314c918 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -1554,7 +1554,7 @@ int ftmac100_initialize(int intf) #endif priv->ft_dev.d_private = (FAR void *)g_ftmac100; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->ft_txpoll = wd_create(); /* Create periodic poll timer */ priv->ft_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/slip.c b/drivers/net/slip.c index f9a30b64eafd59f06d49823510c27903edcf14f4..6d882a416e8526b148ec015aec86c97f76c3c4d4 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -971,15 +972,15 @@ int slip_initialize(int intf, FAR const char *devname) slip_ifdown(&priv->dev); - /* Start the SLIP receiver task */ + /* Start the SLIP receiver kernel thread */ snprintf(buffer, 8, "%d", intf); argv[0] = buffer; argv[1] = NULL; - priv->rxpid = task_create("rxslip", CONFIG_NET_SLIP_DEFPRIO, - CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_rxtask, - (FAR char * const *)argv); + priv->rxpid = kthread_create("rxslip", CONFIG_NET_SLIP_DEFPRIO, + CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_rxtask, + (FAR char * const *)argv); if (priv->rxpid < 0) { nerr("ERROR: Failed to start receiver task\n"); @@ -990,11 +991,11 @@ int slip_initialize(int intf, FAR const char *devname) slip_semtake(priv); - /* Start the SLIP transmitter task */ + /* Start the SLIP transmitter kernel thread */ - priv->txpid = task_create("txslip", CONFIG_NET_SLIP_DEFPRIO, - CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_txtask, - (FAR char * const *)argv); + priv->txpid = kthread_create("txslip", CONFIG_NET_SLIP_DEFPRIO, + CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_txtask, + (FAR char * const *)argv); if (priv->txpid < 0) { nerr("ERROR: Failed to start receiver task\n"); diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c index 9dbded1e1ef940f1df335de2b14b5a9404d4cfbd..db5419125dbfd218a287a88981f1d45e0466930f 100644 --- a/drivers/net/telnet.c +++ b/drivers/net/telnet.c @@ -690,7 +690,7 @@ static ssize_t telnet_read(FAR struct file *filep, FAR char *buffer, size_t len) } while (ret == 0); - /* Return: + /* Returned Value: * * ret > 0: The number of characters copied into the user buffer by * telnet_receive(). @@ -783,7 +783,7 @@ static ssize_t telnet_write(FAR struct file *filep, FAR const char *buffer, size * session - On input, contains the socket descriptor that represents the * new telnet connection. On output, it holds the path to the new Telnet driver. * - * Return: + * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ @@ -863,7 +863,7 @@ static int telnet_session(FAR struct telnet_session_s *session) priv->td_minor); ret = stat(session->ts_devpath, &statbuf); - DEBUGASSERT(ret >= 0 || errno == ENOENT); + DEBUGASSERT(ret >= 0 || get_errno() == ENOENT); } while (ret >= 0 && start != g_telnet_common.tc_minor); @@ -978,7 +978,7 @@ static int common_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Parameters: * None * - * Return: + * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 6c5beeba5e0b199538479c8a7ebd32aa722959b9..f397f847df447cc3a035f7a03b5e2ece7edec6aa 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -891,7 +891,7 @@ static int tun_dev_init(FAR struct tun_device_s *priv, FAR struct file *filep, nxsem_setprotocol(&priv->read_wait_sem, SEM_PRIO_NONE); - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ diff --git a/drivers/pipes/fifo.c b/drivers/pipes/fifo.c index 43afa5556f99faf79120c70a39c846fe3926147e..6a8905a6a20893f4c17598468c2ecc1d88f5817a 100644 --- a/drivers/pipes/fifo.c +++ b/drivers/pipes/fifo.c @@ -97,13 +97,13 @@ static const struct file_operations fifo_fops = * the NuttX FIFOs are based in in-memory, circular buffers, the ability * to control the size of those buffers is critical for system tuning. * - * Inputs: + * Input Parameters: * pathname - The full path to the FIFO instance to attach to or to create * (if not already created). * mode - Ignored for now * bufsize - The size of the in-memory, circular buffer in bytes. * - * Return: + * Returned Value: * 0 is returned on success; otherwise, -1 is returned with errno set * appropriately. * diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index b32ef965e9b57505ee4fba9e163bf3ca508865e5..f3a98e6351900e12551a71d01aa5a64f5ce6a5f9 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -177,12 +177,12 @@ static int pipe_close(FAR struct file *filep) * the NuttX FIFOs are based in in-memory, circular buffers, the ability * to control the size of those buffers is critical for system tuning. * - * Inputs: + * Input Parameters: * fd[2] - The user provided array in which to catch the pipe file * descriptors * bufsize - The size of the in-memory, circular buffer in bytes. * - * Return: + * Returned Value: * 0 is returned on success; otherwise, -1 is returned with errno set * appropriately. * diff --git a/drivers/power/battery_charger.c b/drivers/power/battery_charger.c index 0bacbd90e3769331da1909aec9375fd13a315ef2..5467f4909390b2c6b68bfd931da67e399e737363 100644 --- a/drivers/power/battery_charger.c +++ b/drivers/power/battery_charger.c @@ -270,12 +270,12 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, * Register a lower half battery driver with the common, upper-half * battery driver. * - * Input parameters: + * Input Parameters: * devpath - The location in the pseudo-filesystem to create the driver. * Recommended standard is "/dev/bat0", "/dev/bat1", etc. * dev - An instance of the battery state structure . * - * Returned value: + * Returned Value: * Zero on success or a negated errno value on failure. * ****************************************************************************/ diff --git a/drivers/power/battery_gauge.c b/drivers/power/battery_gauge.c index ab97489188bb40a4e36eb2811050c11c311dac13..9936147be1653dc9438e3bed22197f54584313f6 100644 --- a/drivers/power/battery_gauge.c +++ b/drivers/power/battery_gauge.c @@ -233,12 +233,12 @@ static int bat_gauge_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Register a lower half battery driver with the common, upper-half * battery driver. * - * Input parameters: + * Input Parameters: * devpath - The location in the pseudo-filesystem to create the driver. * Recommended standard is "/dev/bat0", "/dev/bat1", etc. * dev - An instance of the battery state structure . * - * Returned value: + * Returned Value: * Zero on success or a negated errno value on failure. * ****************************************************************************/ diff --git a/drivers/power/pm.h b/drivers/power/pm.h index 472b42a9485a9accd5cb3a555246140cd4d82d16..03e405910b26130641ab8dca1a3f14aa0146fc4d 100644 --- a/drivers/power/pm.h +++ b/drivers/power/pm.h @@ -76,7 +76,7 @@ /**************************************************************************** * Name: pm_lock * - * Descripton: + * Description: * Lock the power management registry. NOTE: This function may return * an error if a signal is received while what (errno == EINTR). * @@ -87,7 +87,7 @@ /**************************************************************************** * Name: pm_unlock * - * Descripton: + * Description: * Unlock the power management registry. * ****************************************************************************/ diff --git a/drivers/power/pm_initialize.c b/drivers/power/pm_initialize.c index 83b67645f7d5949f221eec9cecd7c97eefdac848..bb777f9865c2fdf589efbf890819c35a21541bfd 100644 --- a/drivers/power/pm_initialize.c +++ b/drivers/power/pm_initialize.c @@ -70,10 +70,10 @@ struct pm_global_s g_pmglobals; * other device drivers are initialize (since they may attempt to register * with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/drivers/power/pm_register.c b/drivers/power/pm_register.c index b33dab6962d0a5e25d93903dcc36763216987442..060463135856de6714b6cf3081d3e81304a04339 100644 --- a/drivers/power/pm_register.c +++ b/drivers/power/pm_register.c @@ -59,11 +59,11 @@ * This function is called by a device driver in order to register to * receive power management event callbacks. * - * Input parameters: + * Input Parameters: * callbacks - An instance of struct pm_callback_s providing the driver * callback functions. * - * Returned value: + * Returned Value: * Zero (OK) on success; otherwise a negater errno value is returned. * ****************************************************************************/ diff --git a/drivers/power/powerled.c b/drivers/power/powerled.c index 52996d4919c5e116c50079ddd080c38594730bdd..a915fc0a5502f666d3c8ddfae4f875da2aa6d7e4 100644 --- a/drivers/power/powerled.c +++ b/drivers/power/powerled.c @@ -413,7 +413,7 @@ int powerled_register(FAR const char *path, FAR struct powerled_dev_s *dev, FAR DEBUGASSERT(dev->ops->fault_clean != NULL); DEBUGASSERT(dev->ops->ioctl != NULL); - /* Initialize the HRTIM device structure */ + /* Initialize the powerled device structure */ dev->ocount = 0; diff --git a/drivers/power/smps.c b/drivers/power/smps.c index f019949d72503d73913299bb18c8b5c1c2358f9a..3eb040fedc29f49c3d5108538ecc3bebb296fd7b 100644 --- a/drivers/power/smps.c +++ b/drivers/power/smps.c @@ -506,7 +506,7 @@ int smps_register(FAR const char *path, FAR struct smps_dev_s *dev, FAR void *lo DEBUGASSERT(dev->ops->fault_clean != NULL); DEBUGASSERT(dev->ops->ioctl != NULL); - /* Initialize the HRTIM device structure */ + /* Initialize the SMPS device structure */ dev->ocount = 0; diff --git a/drivers/pwm.c b/drivers/pwm.c index 44d644cc64f70727010aa7de49dcc6fb0ee1f9dd..085c3065e9e5bb47b61773d86332c0efba362d70 100644 --- a/drivers/pwm.c +++ b/drivers/pwm.c @@ -568,7 +568,7 @@ static int pwm_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * When this function is called, the "lower half" driver should be in the * reset state (as if the shutdown() method had already been called). * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registered in the NuttX pseudo- * filesystem. The recommended convention is to name all PWM drivers * as "/dev/pwm0", "/dev/pwm1", etc. where the driver path differs only @@ -641,7 +641,7 @@ int pwm_register(FAR const char *path, FAR struct pwm_lowerhalf_s *dev) * interface using the handle that was previously passed to the * start() method * - * Input parameters: + * Input Parameters: * handle - This is the handle that was provided to the lower-half * start() method. * diff --git a/drivers/ramdisk.c b/drivers/ramdisk.c index b31e1f0dd9dd8f01a12487230045766bb7e1bbbf..842c36cd9dbe280247c97e486b2ced2d57a3d1a5 100644 --- a/drivers/ramdisk.c +++ b/drivers/ramdisk.c @@ -428,14 +428,14 @@ static int rd_unlink(FAR struct inode *inode) * Description: * Non-standard function to register a ramdisk or a romdisk * - * Input Parmeters: + * Input Parameters: * minor: Selects suffix of device named /dev/ramN, N={1,2,3...} * nsectors: Number of sectors on device * sectize: The size of one sector * rdflags: See RDFLAG_* definitions * buffer: RAM disk backup memory * - * Returned Valued: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/drivers/sensors/Kconfig b/drivers/sensors/Kconfig index cfff74ff632e8f28a35a59ebd471c7d3dd3bc897..b04e4224956fcc6dd1619e5da8140ddfec6b0e59 100644 --- a/drivers/sensors/Kconfig +++ b/drivers/sensors/Kconfig @@ -160,6 +160,13 @@ config LIS3DSH ---help--- Enable driver support for the STMicro LIS3DSH 3-Axis accelerometer. +config LIS3DH + bool "STMicro LIS3DH 3-Axis accelerometer support" + default n + select SPI + ---help--- + Enable driver support for the STMicro LIS3DH 3-Axis accelerometer. + config LIS331DL bool "STMicro LIS331DL device support" default n @@ -338,6 +345,34 @@ config ADXL345_REGDEBUG endif # SENSORS_ADXL345 +config SENSORS_MAX44009 + bool "Maxim MAX44009 ALS sensor" + default n + select I2C + ---help--- + Enables MAX44009 Ambient Light Sensor + +if SENSORS_MAX44009 + +config MAX44009_I2C_FREQUENCY + int "MAX44009 I2C frequency" + default 400000 + range 1 400000 + +config DEBUG_MAX44009 + bool "Enable debug support for the MAX44009" + default n + ---help--- + Enables debug support for the MAX44009 + +config MAX44009_NPOLLWAITERS + int "Number of waiters to poll" + default 1 + ---help--- + Number of waiters to poll + +endif # SENSORS_MAX44009 + config SENSORS_MAX31855 bool "Maxim MAX31855 Driver" default n diff --git a/drivers/sensors/Make.defs b/drivers/sensors/Make.defs index 42b6e6f0b8f0c0922c6234bd8af1f161267ef4ea..5b27819f8d7dc1592ca5fe0842a634288b362665 100644 --- a/drivers/sensors/Make.defs +++ b/drivers/sensors/Make.defs @@ -105,6 +105,10 @@ ifeq ($(CONFIG_SENSORS_LM92),y) CSRCS += lm92.c endif +ifeq ($(CONFIG_SENSORS_MAX44009),y) + CSRCS += max44009.c +endif + ifeq ($(CONFIG_SENSORS_MB7040),y) CSRCS += mb7040.c endif @@ -142,6 +146,10 @@ ifeq ($(CONFIG_LIS3DSH),y) CSRCS += lis3dsh.c endif +ifeq ($(CONFIG_LIS3DH),y) + CSRCS += lis3dh.c +endif + ifeq ($(CONFIG_SENSORS_MAX31855),y) CSRCS += max31855.c endif diff --git a/drivers/sensors/bmp180.c b/drivers/sensors/bmp180.c index d18d14e9ab213baa421ad322946a6bc1e8703731..5b4ae52645e88663a7324d7c188f6e4956c63b8d 100644 --- a/drivers/sensors/bmp180.c +++ b/drivers/sensors/bmp180.c @@ -318,7 +318,7 @@ static int bmp180_checkid(FAR struct bmp180_dev_s *priv) devid = bmp180_getreg8(priv, BMP180_DEVID); sninfo("devid: 0x%02x\n", devid); - if (devid != (uint16_t) DEVID) + if (devid != (uint16_t)DEVID) { /* ID is not Correct */ diff --git a/drivers/sensors/lis2dh.c b/drivers/sensors/lis2dh.c index 502246ee52b7b9f602de71b458a1c8c6ae3e078c..8efe51f133ffee083a07579de4c497e69589818b 100644 --- a/drivers/sensors/lis2dh.c +++ b/drivers/sensors/lis2dh.c @@ -1664,7 +1664,13 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) int32_t diff_msec; uint8_t value; + /* Prefer monotonic for timeout calculation when enabled. */ + +#ifdef CONFIG_CLOCK_MONOTONIC (void)clock_gettime(CLOCK_MONOTONIC, &start); +#else + (void)clock_gettime(CLOCK_REALTIME, &start); +#endif /* Reboot to reset chip. */ @@ -1689,7 +1695,11 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) break; } +#ifdef CONFIG_CLOCK_MONOTONIC (void)clock_gettime(CLOCK_MONOTONIC, &curr); +#else + (void)clock_gettime(CLOCK_REALTIME, &curr); +#endif diff_msec = (curr.tv_sec - start.tv_sec) * 1000; diff_msec += (curr.tv_nsec - start.tv_nsec) / (1000 * 1000); diff --git a/drivers/sensors/lis3dh.c b/drivers/sensors/lis3dh.c new file mode 100644 index 0000000000000000000000000000000000000000..af66ceec4da80af88f0d3df9eca5d9bd781041a6 --- /dev/null +++ b/drivers/sensors/lis3dh.c @@ -0,0 +1,1032 @@ +/**************************************************************************** + * drivers/sensors/lis3dh.c + * + * Copyright (C) 2018 Extent3D. All rights reserved. + * Author: Matt Thompson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#if defined(CONFIG_SPI) && defined(CONFIG_LIS3DH) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LIS3DH_QUEUE_MAX 32 +#define LIS3DH_FIFOBUF_SIZE ((32 * 6) + 1) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct lis3dh_dev_s +{ + FAR struct lis3dh_config_s *config; /* Driver configuration */ + FAR struct spi_dev_s *spi; /* Pointer to the SPI instance */ + struct work_s work; /* Work Queue */ + uint8_t power_mode; /* The power mode used to determine mg/digit */ + uint8_t odr; /* The current output data rate */ + sem_t readsem; /* Read notification semaphore */ + uint8_t fifobuf[LIS3DH_FIFOBUF_SIZE]; /* Raw FIFO buffer */ + struct lis3dh_sensor_data_s queue[LIS3DH_QUEUE_MAX]; + sem_t queuesem; /* Queue exclusive lock */ + uint8_t queue_rpos; /* Queue read position */ + uint8_t queue_wpos; /* Queue write position */ + uint8_t queue_count; /* Number of elements in the queue */ +}; + +struct lis3dh_sample_s +{ + int16_t x; + int16_t y; + int16_t z; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void lis3dh_read_register(FAR struct lis3dh_dev_s *dev, + uint8_t const reg_addr, uint8_t *reg_data); +static void lis3dh_write_register(FAR struct lis3dh_dev_s *dev, + uint8_t const reg_addr, + uint8_t const reg_data); +static void lis3dh_reset(FAR struct lis3dh_dev_s *dev); +static int lis3dh_ident(FAR struct lis3dh_dev_s *dev); +static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev); +static int lis3dh_interrupt_handler(int irq, FAR void *context, FAR void *arg); +static void lis3dh_worker(FAR void *arg); +static int lis3dh_irq_enable(FAR struct lis3dh_dev_s *dev, bool enable); +static int lis3dh_fifo_enable(FAR struct lis3dh_dev_s *dev); + +static int lis3dh_open(FAR struct file *filep); +static int lis3dh_close(FAR struct file *filep); +static ssize_t lis3dh_read(FAR struct file *, FAR char *buffer, + size_t buflen); +static ssize_t lis3dh_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +static int lis3dh_ioctl(FAR struct file *filep, int cmd, unsigned long arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations g_lis3dh_fops = +{ + lis3dh_open, + lis3dh_close, + lis3dh_read, + lis3dh_write, + NULL, + lis3dh_ioctl +#ifndef CONFIG_DISABLE_POLL + , NULL +#endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , NULL +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lis3dh_read_register + * + * Description: + * Read a single register from the LIS3DH sensor. + * + * Input Parameters: + * dev - Pointer to device driver instance + * reg_addr - LIS3DH register address + * reg_data - Pointer to uint8_t where read value will be stored + * + ****************************************************************************/ + +static void lis3dh_read_register(FAR struct lis3dh_dev_s *dev, + uint8_t const reg_addr, uint8_t * reg_data) +{ + uint8_t buffer[2]; + + /* Lock the SPI bus so that only one device can access it at the same time */ + + SPI_LOCK(dev->spi, true); + + /* Set CS to low which selects the LIS3DH */ + + SPI_SELECT(dev->spi, dev->config->spi_devid, true); + + buffer[0] = reg_addr | 0x80; + buffer[1] = 0; + SPI_EXCHANGE(dev->spi, buffer, buffer, 2); + *reg_data = buffer[1]; + + /* Set CS to high which deselects the LIS3DH */ + + SPI_SELECT(dev->spi, dev->config->spi_devid, false); + + /* Unlock the SPI bus */ + + SPI_LOCK(dev->spi, false); +} + +/**************************************************************************** + * Name: lis3dh_write_register + * + * Description: + * Write a single register to the LIS3DH sensor. + * + * Input Parameters: + * dev - Pointer to device driver instance + * reg_addr - LIS3DH register address + * reg_data - Value to write into the specified register address + * + ****************************************************************************/ + +static void lis3dh_write_register(FAR struct lis3dh_dev_s *dev, + uint8_t const reg_addr, + uint8_t const reg_data) +{ + uint8_t buffer[2]; + + /* Lock the SPI bus so that only one device can access it at the same time */ + + SPI_LOCK(dev->spi, true); + + /* Set CS to low which selects the LIS3DH */ + + SPI_SELECT(dev->spi, dev->config->spi_devid, true); + + buffer[0] = reg_addr; + buffer[1] = reg_data; + SPI_EXCHANGE(dev->spi, buffer, buffer, 2); + + /* Set CS to high which deselects the LIS3DH */ + + SPI_SELECT(dev->spi, dev->config->spi_devid, false); + + /* Unlock the SPI bus */ + + SPI_LOCK(dev->spi, false); +} + +/**************************************************************************** + * Name: lis3dh_reset + * + * Description: + * Perform a software reset of the LIS3DH sensor. + * + * Input Parameters: + * dev - Pointer to device driver instance + * + ****************************************************************************/ + +static void lis3dh_reset(FAR struct lis3dh_dev_s *dev) +{ + lis3dh_write_register(dev, LIS3DH_CTRL_REG5, LIS3DH_CTRL_REG5_BOOT); + up_mdelay(100); +} + +/**************************************************************************** + * Name: lis3dh_ident + * + * Description: + * Identify an LIS3DH sensor on the SPI bus using the WHO_AM_I register. + * + * Input Parameters: + * dev - Pointer to device driver instance + * + * Returned Value: + * OK if the device responded with the correct ID + * -ENODEV if the device did not respond with the correct ID + * + ****************************************************************************/ + +static int lis3dh_ident(FAR struct lis3dh_dev_s *dev) +{ + uint8_t reg; + lis3dh_read_register(dev, LIS3DH_WHO_AM_I, ®); + + if (reg == LIS3DH_DEVICE_ID) + { + return OK; + } + + return -ENODEV; +} + +/**************************************************************************** + * Name: lis3dh_queue_lock + * + * Description: + * Locks exclusive access to the ring buffer queue + * + * Input Parameters: + * dev - Pointer to device driver instance + * + ****************************************************************************/ + +static void lis3dh_queue_lock(FAR struct lis3dh_dev_s *dev) +{ + int ret; + + ret = nxsem_wait(&dev->queuesem); + if (ret < 0) + { + snerr("ERROR: queuesem wait error: %d\n", ret); + return; + } +} + +/**************************************************************************** + * Name: lis3dh_queue_unlock + * + * Description: + * Unlocks exclusive acccess to the ring buffer queue + * + * Input Parameters: + * dev - Pointer to device driver instance + * + ****************************************************************************/ + +static void lis3dh_queue_unlock(FAR struct lis3dh_dev_s *dev) +{ + nxsem_post(&dev->queuesem); +} + +/**************************************************************************** + * Name: lis3dh_queue_push + * + * Description: + * Push a sensor measurement into the queue + * + * Input Parameters: + * dev - Pointer to device driver instance + * + ****************************************************************************/ + +static int lis3dh_queue_push(FAR struct lis3dh_dev_s *dev, + struct lis3dh_sensor_data_s *data) +{ + lis3dh_queue_lock(dev); + if (dev->queue_count >= LIS3DH_QUEUE_MAX) + { + lis3dh_queue_unlock(dev); + return -ENOMEM; + } + + dev->queue_wpos++; + dev->queue[dev->queue_wpos % LIS3DH_QUEUE_MAX] = *data; + + dev->queue_count++; + lis3dh_queue_unlock(dev); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_queue_pop + * + * Description: + * Pops a sensor measurement from the queue + * + * Input Parameters: + * dev - Pointer to device driver instance + * + * Returned Value: + * OK if a measurement was successfully dequeued + * -EAGAIN if the queue is empty + * + ****************************************************************************/ + +static int lis3dh_queue_pop(FAR struct lis3dh_dev_s *dev, + struct lis3dh_sensor_data_s *data) +{ + lis3dh_queue_lock(dev); + if (dev->queue_count == 0) + { + lis3dh_queue_unlock(dev); + return -EAGAIN; + } + + dev->queue_rpos++; + *data = dev->queue[dev->queue_rpos % LIS3DH_QUEUE_MAX]; + + dev->queue_count--; + + lis3dh_queue_unlock(dev); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_read_fifo + * + * Description: + * Reads the FIFO from the LIS3DH sensor, and pushes to the internal queue. + * + * Input Parameters: + * dev - Pointer to device driver instance + * + * Returned Value: + * + ****************************************************************************/ + +static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev) +{ + uint8_t fifosrc; + uint8_t count; + int i; + + /* Lock the SPI bus */ + + SPI_LOCK(dev->spi, true); + + /* Read the FIFO source register */ + + dev->fifobuf[0] = LIS3DH_FIFO_SRC_REG | 0x80; + dev->fifobuf[1] = 0; + + SPI_SELECT(dev->spi, dev->config->spi_devid, true); + SPI_EXCHANGE(dev->spi, dev->fifobuf, dev->fifobuf, 2); + SPI_SELECT(dev->spi, dev->config->spi_devid, false); + + fifosrc = dev->fifobuf[1]; + + count = fifosrc & 0x1f; + + if (fifosrc & LIS3DH_FIFO_SRC_REG_OVRN_FIFO) + { + snerr("FIFO overrun\n"); + } + + memset(dev->fifobuf, 0, LIS3DH_FIFOBUF_SIZE); + dev->fifobuf[0] = LIS3DH_OUT_X_L | 0xC0; + + SPI_SELECT(dev->spi, dev->config->spi_devid, true); + SPI_EXCHANGE(dev->spi, dev->fifobuf, dev->fifobuf, 1 + count*6); + SPI_SELECT(dev->spi, dev->config->spi_devid, false); + + /* Unlock the SPI bus */ + + SPI_LOCK(dev->spi, false); + + for (i = 0; i < count; i++) + { + struct lis3dh_sensor_data_s data; + uint16_t x_raw; + uint16_t y_raw; + uint16_t z_raw; + + int16_t x_acc; + int16_t y_acc; + int16_t z_acc; + + x_raw = (uint16_t)dev->fifobuf[(i*6)+1] | + (uint16_t)dev->fifobuf[(i*6)+2] << 8; + + y_raw = (uint16_t)dev->fifobuf[(i*6)+3] | + (uint16_t)dev->fifobuf[(i*6)+4] << 8; + + z_raw = (uint16_t)dev->fifobuf[(i*6)+5] | + (uint16_t)dev->fifobuf[(i*6)+6] << 8; + + /* The sensor left justifies the data in the register, so we must + * shift it to the right depending on the selected power mode + */ + + switch (dev->power_mode) + { + case LIS3DH_POWER_LOW: /* 8 bit measurements */ + x_acc = (int16_t)x_raw >> 8; + y_acc = (int16_t)y_raw >> 8; + z_acc = (int16_t)z_raw >> 8; + + data.x_acc = (float)x_acc * 0.016; + data.y_acc = (float)y_acc * 0.016; + data.z_acc = (float)z_acc * 0.016; + break; + + case LIS3DH_POWER_NORMAL: /* 10 bit measurements */ + x_acc = (int16_t)x_raw >> 6; + y_acc = (int16_t)y_raw >> 6; + z_acc = (int16_t)z_raw >> 6; + + data.x_acc = (float)x_acc * 0.004; + data.y_acc = (float)y_acc * 0.004; + data.z_acc = (float)z_acc * 0.004; + break; + + case LIS3DH_POWER_HIGH: /* 12 bit measurements */ + x_acc = (int16_t)x_raw >> 4; + y_acc = (int16_t)y_raw >> 4; + z_acc = (int16_t)z_raw >> 4; + + data.x_acc = (float)x_acc * 0.001; + data.y_acc = (float)y_acc * 0.001; + data.z_acc = (float)z_acc * 0.001; + break; + + default: + snerr("Unknown power mode\n"); + return -EINVAL; + } + + if (lis3dh_queue_push(dev, &data) == OK) + { + nxsem_post(&dev->readsem); + } + } + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_interrupt_handler + * + * Description: + * Interrupt service routine, queues work on high priority work queue. + * + * Input Parameters: + * irq - Interrupt request number + * context - Context pointer + * arg - Pointer to device driver instance + * + * Returned Value: + * Returns OK to indicate the interrupt has been serviced. + * + ****************************************************************************/ + +static int lis3dh_interrupt_handler(int irq, FAR void *context, FAR void *arg) +{ + /* The interrupt handler is called when the FIFO watermark is reached */ + + FAR struct lis3dh_dev_s *priv = (FAR struct lis3dh_dev_s *)arg; + int ret; + + DEBUGASSERT(priv != NULL); + + if (work_available(&priv->work)) + { + ret = work_queue(HPWORK, &priv->work, lis3dh_worker, priv, 0); + if (ret < 0) + { + snerr("ERROR: Failed to queue work: %d\n", ret); + return ret; + } + } + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_worker + * + * Description: + * Worker callback executed from high priority work queue. + * Performs reading the FIFO from the sensor and pushing samples to + * the internal device driver queue. + * + * Input Parameters: + * arg - Pointer to device driver instance + * + ****************************************************************************/ + +static void lis3dh_worker(FAR void *arg) +{ + FAR struct lis3dh_dev_s *priv = (FAR struct lis3dh_dev_s *)(arg); + + DEBUGASSERT(priv != NULL); + + /* Read the FIFO and fill the queue */ + + lis3dh_read_fifo(priv); +} + +/**************************************************************************** + * Name: lis3dh_set_power_mode + * + * Description: + * Sets the power mode of the sensor. + * + * Input Parameters: + * dev - Pointer to device driver instance + * power_mode - LIS3DH_POWER_* + * + * Returned Value: + * OK - Power mode was set successfully + * -EINVAL - Invalid power mode argument + * + ****************************************************************************/ + +static int lis3dh_set_power_mode(FAR struct lis3dh_dev_s *dev, + uint8_t power_mode) +{ + uint8_t ctrl1; + uint8_t ctrl4; + + switch (power_mode) + { + case LIS3DH_POWER_LOW: + lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1); + lis3dh_read_register(dev, LIS3DH_CTRL_REG4, &ctrl4); + + ctrl1 |= LIS3DH_CTRL_REG1_LPEN; + ctrl4 &= ~LIS3DH_CTRL_REG4_HR; + + lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1); + lis3dh_write_register(dev, LIS3DH_CTRL_REG4, ctrl4); + break; + + case LIS3DH_POWER_NORMAL: + lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1); + lis3dh_read_register(dev, LIS3DH_CTRL_REG4, &ctrl4); + + ctrl1 &= ~LIS3DH_CTRL_REG1_LPEN; + ctrl4 &= ~LIS3DH_CTRL_REG4_HR; + + lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1); + lis3dh_write_register(dev, LIS3DH_CTRL_REG4, ctrl4); + break; + + case LIS3DH_POWER_HIGH: + lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1); + lis3dh_read_register(dev, LIS3DH_CTRL_REG4, &ctrl4); + + ctrl1 &= ~LIS3DH_CTRL_REG1_LPEN; + ctrl4 |= LIS3DH_CTRL_REG4_HR; + + lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1); + lis3dh_write_register(dev, LIS3DH_CTRL_REG4, ctrl4); + break; + + default: + return -EINVAL; + break; + } + + dev->power_mode = power_mode; + sninfo("Power mode set to %d\n", power_mode); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_set_odr + * + * Description: + * Sets the output data rate of the sensor. + * + * Input Parameters: + * dev - Pointer to device driver instance + * odr - LIS3DH_ODR_* + * + * Returned Value: + * OK - Power mode was set successfully + * -EINVAL - Invalid odr argument + * + ****************************************************************************/ + +static int lis3dh_set_odr(FAR struct lis3dh_dev_s *dev, uint8_t odr) +{ + uint8_t ctrl1; + + if (odr > LIS3DH_CTRL_REG1_ODR_LP_5376HZ) + { + return -EINVAL; + } + + lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1); + ctrl1 |= LIS3DH_CTRL_REG1_ODR(odr) & LIS3DH_CTRL_REG1_ODR_MASK; + lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1); + + /* Cache the current ODR in the device structure */ + + dev->odr = odr; + sninfo("Output data rate set to %d\n", odr); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_irq_enable + * + * Description: + * Enable or disable sensor interrupt generation on FIFO watermark. + * + * Input Parameters: + * dev - Pointer to device driver instance + * enable - Boolean to enable or disable the interrupt generation + * + * Returned Value: + * OK - Interrupt generation register written. + * + ****************************************************************************/ + +static int lis3dh_irq_enable(FAR struct lis3dh_dev_s *dev, bool enable) +{ + uint8_t reg; + + reg = 0; + + if (enable == true) + { + reg = LIS3DH_CTRL_REG3_I1_WTM; + } + + lis3dh_write_register(dev, LIS3DH_CTRL_REG3, reg); + return OK; +} + +/**************************************************************************** + * Name: lis3dh_irq_enable + * + * Description: + * Enable or disable sensor interrupt generation on FIFO watermark. + * + * Input Parameters: + * dev - Pointer to device driver instance + * enable - Boolean to enable or disable the interrupt generation + * + * Returned Value: + * OK - Interrupt generation register written. + * + ****************************************************************************/ + +static int lis3dh_fifo_enable(FAR struct lis3dh_dev_s *dev) +{ + uint8_t reg; + lis3dh_write_register(dev, LIS3DH_FIFO_CTRL_REG, + LIS3DH_FIFO_CTRL_REG_MODE_STREAM | 28); + + lis3dh_read_register(dev, LIS3DH_CTRL_REG5, ®); + reg |= LIS3DH_CTRL_REG5_FIFO_EN; + lis3dh_write_register(dev, LIS3DH_CTRL_REG5, reg); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_enable + * + * Description: + * Enable sensor measurements into the on-chip FIFO. + * + * Input Parameters: + * priv - Pointer to device driver instance + * + * Returned Value: + * OK - Sensor measurements enabled. + * + ****************************************************************************/ + +static int lis3dh_enable(FAR struct lis3dh_dev_s *priv) +{ + uint8_t reg; + + /* Select the default power mode */ + + lis3dh_set_power_mode(priv, LIS3DH_POWER_NORMAL); + + /* Select the default output data rate */ + + lis3dh_set_odr(priv, LIS3DH_ODR_1344HZ); + + reg = LIS3DH_CTRL_REG4_BDU | LIS3DH_CTRL_REG4_FS_2G; + lis3dh_write_register(priv, LIS3DH_CTRL_REG4, reg); + + lis3dh_fifo_enable(priv); + + /* Enable X, Y, and Z axes */ + + lis3dh_read_register(priv, LIS3DH_CTRL_REG1, ®); + reg |= LIS3DH_CTRL_REG1_ZEN | LIS3DH_CTRL_REG1_YEN | LIS3DH_CTRL_REG1_XEN; + lis3dh_write_register(priv, LIS3DH_CTRL_REG1, reg); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_open + * + * Description: + * Character device open call. + * + * Input Parameters: + * filep - Pointer to struct file + * + * Returned Value: + * -ENODEV - Device was not identified on the SPI bus. + * OK - Sensor device was opened successfully. + * + ****************************************************************************/ + +static int lis3dh_open(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct lis3dh_dev_s *priv = inode->i_private; + + DEBUGASSERT(priv != NULL); + + /* Perform a reset */ + + lis3dh_reset(priv); + if (lis3dh_ident(priv) < 0) + { + snerr("ERROR: Failed to identify LIS3DH on SPI bus\n"); + return -ENODEV; + } + + /* Attach the interrupt line */ + + (priv->config->irq_attach)(priv->config, lis3dh_interrupt_handler, priv); + + /* Enable interrupt generation on the sensor */ + + lis3dh_irq_enable(priv, true); + + /* Enable measurements on the sensor */ + + if (lis3dh_enable(priv) < 0) + { + snerr("ERROR: Failed to enable LIS3DH\n"); + return -ENODEV; + } + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_close + * + * Description: + * Character device close call. + * + * Input Parameters: + * filep - Pointer to struct file + * + * Returned Value: + * OK - Sensor device was closed successfully. + * + ****************************************************************************/ + +static int lis3dh_close(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct lis3dh_dev_s *priv = inode->i_private; + + DEBUGASSERT(priv != NULL); + + /* Perform a reset */ + + lis3dh_reset(priv); + + /* Detach the interrupt line */ + + (priv->config->irq_detach)(priv->config); + + return OK; +} + +/**************************************************************************** + * Name: lis3dh_read + * + * Description: + * Character device read call. Blocks until requested buffer size is full. + * + * Input Parameters: + * filep - Pointer to struct file + * buffer - Pointer to user buffer + * buflen - Size of user buffer in bytes + * + * Returned Value: + * Returns the number of bytes written to the buffer. + * -EINVAL - Supplied buffer length invalid + * + ****************************************************************************/ + +static ssize_t lis3dh_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct lis3dh_dev_s *priv = inode->i_private; + FAR struct lis3dh_sensor_data_s *data; + int count; + int remain; + + DEBUGASSERT(priv != NULL); + + if ((buflen % sizeof(FAR struct lis3dh_sensor_data_s)) != 0) + { + snerr("ERROR: Provided buffer must be multiple of sensor data size\n"); + return -EINVAL; + } + + /* Get the number of samples the user has requested */ + + count = buflen / sizeof(struct lis3dh_sensor_data_s); + + /* Cast a pointer into the user buffer */ + + data = (FAR struct lis3dh_sensor_data_s *)buffer; + + for (remain=count;remain > 0;remain--) + { + + /* Wait for data to be available in the queue */ + + nxsem_wait(&priv->readsem); + + /* Pop a sample off of the queue */ + + lis3dh_queue_pop(priv, data); + + data++; + } + + return count * sizeof(struct lis3dh_sensor_data_s); +} + +/**************************************************************************** + * Name: lis3dh_write + * + * Description: + * Character device write call. Not supported. + * + * Input Parameters: + * filep - Pointer to struct file + * buffer - Pointer to user buffer + * buflen - Size of user buffer in bytes + * + * Returned Value: + * -ENOSYS + * + ****************************************************************************/ + +static ssize_t lis3dh_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen) +{ + return -ENOSYS; +} + +/**************************************************************************** + * Name: lis3dh_ioctl + * + * Description: + * Character device ioctl call. Sets device parameters. + * + * Input Parameters: + * filep - Pointer to struct file + * cmd - SNIOC_* + * arg - ioctl specific argument + * + * Returned Value: + * OK - The command was executed successfully. + * -ENOTTY - The request command is not applicable to the driver. + * + ****************************************************************************/ + +static int lis3dh_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct lis3dh_dev_s *priv = inode->i_private; + int ret = OK; + + switch (cmd) + { + case SNIOC_SET_POWER_MODE: + ret = lis3dh_set_power_mode(priv, arg); + break; + + case SNIOC_SET_DATA_RATE: + ret = lis3dh_set_odr(priv, arg); + break; + + default: + snerr("ERROR: Unrecognized cmd: %d\n", cmd); + ret = -ENOTTY; + break; + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lis3dh_register + * + * Description: + * Register the LIS3DH character device at the specified device path + * + * Input Parameters: + * devpath - Full path of device node to register ie "/dev/accel0" + * spi - SPI bus device instance + * config - Driver instance configuration structure + * + * Returned Value: + * OK on success or a negative errno value on failure. + * + ****************************************************************************/ + +int lis3dh_register(FAR const char *devpath, FAR struct spi_dev_s *spi, + FAR struct lis3dh_config_s *config) +{ + FAR struct lis3dh_dev_s *priv; + int ret; + + DEBUGASSERT(spi != NULL); + + /* Initialize the LIS3DH device structure */ + + priv = (FAR struct lis3dh_dev_s *)kmm_malloc(sizeof(struct lis3dh_dev_s)); + if (priv == NULL) + { + snerr("ERROR: Failed to allocate instance\n"); + return -ENOMEM; + } + + priv->config = config; + priv->spi = spi; + priv->work.worker = NULL; + priv->queue_count = 0; + + /* Initialize queue semaphore */ + + nxsem_init(&priv->queuesem, 0, 1); + + /* Initialize read notification semaphore */ + + nxsem_init(&priv->readsem, 0, 0); + nxsem_setprotocol(&priv->readsem, SEM_PRIO_NONE); + + /* Setup SPI frequency and mode */ + + SPI_SETFREQUENCY(spi, LIS3DH_SPI_FREQUENCY); + SPI_SETMODE(spi, LIS3DH_SPI_MODE); + + /* Register the character driver */ + + ret = register_driver(devpath, &g_lis3dh_fops, 0666, priv); + if (ret < 0) + { + snerr("ERROR: Failed to register driver: %d\n", ret); + kmm_free(priv); + nxsem_destroy(&priv->queuesem); + nxsem_destroy(&priv->readsem); + return ret; + } + + return OK; +} + +#endif /* CONFIG_SPI && CONFIG_LIS3DH */ diff --git a/drivers/sensors/max44009.c b/drivers/sensors/max44009.c new file mode 100644 index 0000000000000000000000000000000000000000..eaf67249346baa91463c299edb84fc7362636573 --- /dev/null +++ b/drivers/sensors/max44009.c @@ -0,0 +1,957 @@ +/**************************************************************************** + * drivers/sensors/max44009.c + * + * Copyright (C) 2014-2018 Haltian Ltd. All rights reserved. + * Authors: Dmitry Nikolaev + * Juha Niskanen + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_MAX44009 +# define max44009_dbg(x, ...) _info(x, ##__VA_ARGS__) +#else +# define max44009_dbg(x, ...) sninfo(x, ##__VA_ARGS__) +#endif + +#ifndef CONFIG_MAX44009_I2C_FREQUENCY +# define CONFIG_MAX44009_I2C_FREQUENCY 400000 +#endif + +/* Registers */ + +#define MAX44009_INT_STS 0x0 +#define MAX44009_INT_EN 0x01 +#define MAX44009_CONFIG 0x02 +#define MAX44009_LUX_HBYTE 0x03 +#define MAX44009_LUX_LBYTE 0x04 +#define MAX44009_UP_THRESH_BYTE 0x05 +#define MAX44009_LOW_THRESH_BYTE 0x06 +#define MAX44009_THRESH_TIMER 0x07 + +/* Other constants */ + +#define MAX44009_I2C_RETRIES 10 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct max44009_dev_s +{ + FAR struct max44009_config_s *config; + sem_t dev_sem; + FAR struct i2c_master_s *i2c; + uint8_t addr; + uint8_t cref; + bool int_pending; +#ifndef CONFIG_DISABLE_POLL + struct pollfd *fds[CONFIG_MAX44009_NPOLLWAITERS]; +#endif +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int max44009_open(FAR struct file *filep); +static int max44009_close(FAR struct file *filep); +static ssize_t max44009_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t max44009_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +static int max44009_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +#ifndef CONFIG_DISABLE_POLL +static int max44009_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup); +#endif + +static int max44009_read_data(FAR struct max44009_dev_s *priv, + FAR struct max44009_data_s *data); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations g_alsops = +{ + max44009_open, /* open */ + max44009_close, /* close */ + max44009_read, /* read */ + max44009_write, /* write */ + NULL, /* seek */ + max44009_ioctl /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + , max44009_poll /* poll */ +#endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , NULL /* unlink */ +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int max44009_do_transfer(FAR struct max44009_dev_s *dev, + FAR struct i2c_msg_s *msgv, + size_t nmsg) +{ + int ret = -EIO; + int retries; + + for (retries = 0; retries < MAX44009_I2C_RETRIES; retries++) + { + ret = I2C_TRANSFER(dev->i2c, msgv, nmsg); + if (ret >= 0) + { + return 0; + } + else + { +#ifdef CONFIG_I2C_RESET + /* Some error. Try to reset I2C bus and keep trying. */ + + if (retries == MAX44009_I2C_RETRIES - 1) + { + break; + } + + ret = I2C_RESET(dev->i2c); + if (ret < 0) + { + max44009_dbg("I2C_RESET failed: %d\n", ret); + return ret; + } +#endif + } + } + + max44009_dbg("xfer failed: %d\n", ret); + return ret; +} + +static int max44009_write_reg8(FAR struct max44009_dev_s *dev, + FAR const uint8_t *command) +{ + struct i2c_msg_s msgv[2] = + { + { + .frequency = CONFIG_MAX44009_I2C_FREQUENCY, + .addr = dev->addr, + .flags = 0, + .buffer = (void *)&command[0], + .length = 1 + }, + { + .frequency = CONFIG_MAX44009_I2C_FREQUENCY, + .addr = dev->addr, + .flags = I2C_M_NORESTART, + .buffer = (void *)&command[1], + .length = 1 + } + }; + + return max44009_do_transfer(dev, msgv, 2); +} + +static int max44009_read_reg8(FAR struct max44009_dev_s *dev, + FAR uint8_t *command, + FAR uint8_t *value) +{ + struct i2c_msg_s msgv[2] = + { + { + .frequency = CONFIG_MAX44009_I2C_FREQUENCY, + .addr = dev->addr, + .flags = 0, + .buffer = command, + .length = 1 + }, + { + .frequency = CONFIG_MAX44009_I2C_FREQUENCY, + .addr = dev->addr, + .flags = I2C_M_READ, + .buffer = value, + .length = 1 + } + }; + + return max44009_do_transfer(dev, msgv, 2); +} + +static int max44009_open(FAR struct file *filep) +{ + FAR struct inode *inode; + FAR struct max44009_dev_s *priv; + unsigned int use_count; + int ret; + + DEBUGASSERT(filep); + inode = filep->f_inode; + + DEBUGASSERT(inode && inode->i_private); + priv = (FAR struct max44009_dev_s *)inode->i_private; + + do + { + ret = nxsem_wait(&priv->dev_sem); + + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + DEBUGASSERT(ret == OK || ret == -EINTR); + } + while (ret == -EINTR); + + use_count = priv->cref + 1; + if (use_count == 1) + { + /* First user, do power on. */ + + ret = priv->config->set_power(priv->config, true); + if (ret < 0) + { + max44009_dbg("Cannot power on sensor: %d\n", ret); + goto out_sem; + } + + priv->config->irq_enable(priv->config, true); + priv->cref = use_count; + } + else + { + DEBUGASSERT(use_count < UINT8_MAX && use_count > priv->cref); + + priv->cref = use_count; + ret = 0; + } + + max44009_dbg("Sensor is powered on\n"); + +out_sem: + nxsem_post(&priv->dev_sem); + return ret; +} + +static int max44009_close(FAR struct file *filep) +{ + FAR struct inode *inode; + FAR struct max44009_dev_s *priv; + int use_count; + int ret; + + DEBUGASSERT(filep); + inode = filep->f_inode; + + DEBUGASSERT(inode && inode->i_private); + priv = (FAR struct max44009_dev_s *)inode->i_private; + + do + { + ret = nxsem_wait(&priv->dev_sem); + + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + DEBUGASSERT(ret == OK || ret == -EINTR); + } + while (ret == -EINTR); + + use_count = priv->cref - 1; + if (use_count == 0) + { + priv->config->irq_enable(priv->config, false); + + /* Last user, do power off. */ + + (void)priv->config->set_power(priv->config, false); + priv->cref = use_count; + } + else + { + DEBUGASSERT(use_count > 0); + + priv->cref = use_count; + } + + max44009_dbg("CLOSED\n"); + nxsem_post(&priv->dev_sem); + return OK; +} + +static ssize_t max44009_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) +{ + FAR struct inode *inode; + FAR struct max44009_dev_s *priv; + ssize_t length = 0; + int ret; + struct max44009_data_s data; + + DEBUGASSERT(filep); + inode = filep->f_inode; + + DEBUGASSERT(inode && inode->i_private); + priv = (FAR struct max44009_dev_s *)inode->i_private; + + do + { + ret = nxsem_wait(&priv->dev_sem); + + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + DEBUGASSERT(ret == OK || ret == -EINTR); + } + while (ret == -EINTR); + + ret = max44009_read_data(priv, &data); + if (ret < 0) + { + max44009_dbg("failed to read the sensor\n"); + } + else + { + /* This interface is mainly intended for easy debugging in nsh. */ + + length = snprintf(buffer, buflen, "%u.%03hu", data.lux, data.mlux); + if (length > buflen) + { + length = buflen; + } + } + + nxsem_post(&priv->dev_sem); + return length; +} + +static ssize_t max44009_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen) +{ + ssize_t length = 0; + return length; +} + +static int max44009_set_interrupt_bit(FAR struct max44009_dev_s *priv, + bool is_activated) +{ + int ret; + uint8_t cmd[2]; + + cmd[0] = MAX44009_INT_EN; + cmd[1] = is_activated ? (1 << 0) : 0; + + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set interrupt bit\n"); + } + + return ret; +} + +static int max44009_set_manual_mode(FAR struct max44009_dev_s *priv, + bool is_manual) +{ + int ret; + uint8_t value = 0; + const uint8_t manual_bit = (1 << 6); + uint8_t cmd[2]; + + cmd[0] = MAX44009_CONFIG; + ret = max44009_read_reg8(priv, &cmd[0], &value); + if (ret < 0) + { + max44009_dbg("Cannot read config register\n"); + goto fail; + } + + if (is_manual) + { + value |= manual_bit; + } + else + { + value &= ~manual_bit; + } + + cmd[1] = value; + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set manual bit in config register\n"); + } + +fail: + return ret; +} + +static int max44009_set_continuous_mode(FAR struct max44009_dev_s *priv, + bool is_cont) +{ + int ret; + uint8_t value = 0; + const uint8_t cont_bit = (1 << 7); + uint8_t cmd[2]; + + cmd[0] = MAX44009_CONFIG; + ret = max44009_read_reg8(priv, &cmd[0], &value); + if (ret < 0) + { + max44009_dbg("Cannot read config register\n"); + goto fail; + } + + if (is_cont) + { + value |= cont_bit; + } + else + { + value &= ~cont_bit; + } + + cmd[1] = value; + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set cont bit in config register\n"); + } + +fail: + return ret; +} + +static int max44009_set_current_div_ratio(FAR struct max44009_dev_s *priv, + bool is_cdr) +{ + int ret; + uint8_t value = 0; + const uint8_t cdr_bit = (1 << 3); + uint8_t cmd[2]; + + cmd[0] = MAX44009_CONFIG; + ret = max44009_read_reg8(priv, &cmd[0], &value); + if (ret < 0) + { + max44009_dbg("Cannot read config register\n"); + goto fail; + } + + if (is_cdr) + { + value |= cdr_bit; + } + else + { + value &= ~cdr_bit; + } + + cmd[1] = value; + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set cdr bit in config register\n"); + } + +fail: + return ret; +} + +static int max44009_set_integration_time(FAR struct max44009_dev_s *priv, + enum max44009_integration_time_e + integration_time) +{ + int ret; + uint8_t value = 0; + const uint8_t tim_bits = integration_time << 0; + const uint8_t tim_mask = 0x07; + uint8_t cmd[2]; + + cmd[0] = MAX44009_CONFIG; + ret = max44009_read_reg8(priv, &cmd[0], &value); + if (ret < 0) + { + max44009_dbg("Cannot read config register\n"); + goto fail; + } + + value &= ~tim_mask; + value |= tim_bits; + + cmd[1] = value; + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set tim bits in config register\n"); + } + +fail: + return ret; +} + +static int max44009_set_threshold_timer(FAR struct max44009_dev_s *priv, + uint8_t threshold_timer) +{ + int ret; + uint8_t cmd[2]; + + cmd[0] = MAX44009_THRESH_TIMER; + cmd[1] = threshold_timer; + + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Threshold timer cannot be set\n"); + } + + return ret; +} + +static int max44009_set_threshold(FAR struct max44009_dev_s *priv, + FAR struct max44009_threshold_s *settings) +{ + int ret; + uint8_t cmd[2]; + + cmd[0] = MAX44009_UP_THRESH_BYTE; + cmd[1] = settings->upper_threshold; + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set upper threshold\n"); + goto fail; + } + + cmd[0] = MAX44009_LOW_THRESH_BYTE; + cmd[1] = settings->lower_threshold; + ret = max44009_write_reg8(priv, cmd); + if (ret < 0) + { + max44009_dbg("Cannot set lower threshold\n"); + goto fail; + } + + ret = max44009_set_threshold_timer(priv, settings->threshold_timer); + if (ret < 0) + { + max44009_dbg("Cannot set threshold timer\n"); + goto fail; + } + + ret = max44009_set_interrupt_bit(priv, true); + if (ret < 0) + { + max44009_dbg("Cannot set interrupt\n"); + goto fail; + } + +fail: + return ret; +} + +static int max44009_selftest(FAR struct max44009_dev_s *priv, + FAR struct max44009_data_s * data) +{ + int ret; + uint8_t reg_addr = MAX44009_THRESH_TIMER; + uint8_t value = 0; + + ret = max44009_set_threshold_timer(priv, data->test_value); + if (ret < 0) + { + max44009_dbg("Cannot write test-value\n"); + goto fail; + } + + ret = max44009_read_reg8(priv, ®_addr, &value); + if (ret < 0) + { + max44009_dbg("Cannot read written value\n"); + goto fail; + } + + if (value != data->test_value) + { + max44009_dbg("Test failed\n"); + ret = -EIO; + } + +fail: + return ret; +} + +static int max44009_init_device(FAR struct max44009_dev_s *priv, + FAR struct max44009_init_s * settings) +{ + int ret; + + ret = max44009_set_manual_mode(priv, settings->is_manual); + if (ret < 0) + { + max44009_dbg("Cannot init manual mode\n"); + goto fail; + } + + ret = max44009_set_continuous_mode(priv, settings->is_cont); + if (ret < 0) + { + max44009_dbg("Cannot init cont mode\n"); + goto fail; + } + + if (settings->is_manual) + { + ret = max44009_set_current_div_ratio(priv, settings->is_cdr); + if (ret < 0) + { + max44009_dbg("Cannot init cdr mode\n"); + goto fail; + } + + ret = max44009_set_integration_time(priv, settings->integr_time); + if (ret < 0) + { + max44009_dbg("Cannot init tim mode\n"); + goto fail; + } + } + +fail: + return ret; +} + +static int max44009_read_data(FAR struct max44009_dev_s *priv, + FAR struct max44009_data_s *data) +{ + int ret; + uint8_t lvalue; + uint8_t hvalue; + uint8_t reg_addr; + uint32_t val; + + reg_addr = MAX44009_INT_STS; + ret = max44009_read_reg8(priv, ®_addr, &hvalue); + if (ret < 0) + { + max44009_dbg("Cannot read interrupt status register\n"); + } + + reg_addr = MAX44009_LUX_HBYTE; + ret = max44009_read_reg8(priv, ®_addr, &hvalue); + if (ret < 0) + { + max44009_dbg("Cannot read high bits from lux register\n"); + return ret; + } + + /* LUX HBYTE has (starting with MSB): E3.E2.E1.E0.M7.M6.M5.M4 + * LUX LBYTE has : --.--.--.--.M3.M2.M1.M0 + * + * E[3..0] = Exponent, M[7..0]: Mantissa. + * + * Lux can be calculated as (full resolution): (M[7..0] << E[3..0]) * 0.045. + * + * Lux can also be calculated using only HBYTE: + * (M[7..4] << E[3..0]) * 0.72 + * == (M[7..4] << E[3..0]) * 2^4 * 0.045 + * == (M[7..4] << E[3..0]) * (1 << 4) * 0.045 + * == (M[7..4] << (E[3..0] + 4)) * 0.045 + */ + + reg_addr = MAX44009_LUX_LBYTE; + ret = max44009_read_reg8(priv, ®_addr, &lvalue); + if (ret < 0) + { + max44009_dbg("Cannot read low bits from lux register\n"); + return ret; + } + + /* Merge HBYTE and LBYTE to 16-bit integer: + * --.--.--.--.E3.E2.E1.E0.M7.M6.M5.M4.M3.M2.M1.M0 */ + + data->raw_value = (hvalue << 4) | (lvalue & 0xf); + + /* Add raw value to entropy pool. */ + + add_sensor_randomness(data->raw_value); + + /* Convert raw value to lux and millilux. */ + + val = data->raw_value & 0xff; + val = val << ((data->raw_value & 0x0f00) >> 8); + + /* lux is the raw output multiplied by 0.045. */ + + data->lux = (val * 45) / 1000; + data->mlux = (val * 45) % 1000; + + return ret; +} + +static int max44009_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + FAR struct inode *inode; + FAR struct max44009_dev_s *priv; + int ret; + + DEBUGASSERT(filep); + inode = filep->f_inode; + + DEBUGASSERT(inode && inode->i_private); + priv = (FAR struct max44009_dev_s *)inode->i_private; + + do + { + ret = nxsem_wait(&priv->dev_sem); + + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + DEBUGASSERT(ret == OK || ret == -EINTR); + } + while (ret == -EINTR); + + switch (cmd) + { + case SNIOC_INIT: + ret = max44009_init_device(priv, (FAR struct max44009_init_s *)arg); + break; + + case SNIOC_THRESHOLD: + ret = max44009_set_threshold(priv, + (FAR struct max44009_threshold_s *)arg); + break; + + case SNIOC_READ_RAW_DATA: + case SNIOC_READ_CONVERT_DATA: + ret = max44009_read_data(priv, (FAR struct max44009_data_s *)arg); + break; + + case SNIOC_START_SELFTEST: + ret = max44009_selftest(priv, (FAR struct max44009_data_s *)arg); + break; + + default: + ret = -ENOTTY; + break; + } + + nxsem_post(&priv->dev_sem); + return ret; +} + +#ifndef CONFIG_DISABLE_POLL +static void max44009_notify(FAR struct max44009_dev_s *priv) +{ + DEBUGASSERT(priv != NULL); + + int i; + + /* If there are threads waiting on poll() for data to become available, + * then wake them up now. NOTE: we wake up all waiting threads because we + * do not know that they are going to do. If they all try to read the + * data, then some make end up blocking after all. + */ + + for (i = 0; i < CONFIG_MAX44009_NPOLLWAITERS; i++) + { + FAR struct pollfd *fds = priv->fds[i]; + if (fds) + { + fds->revents |= POLLIN; + max44009_dbg("Report events: %02x\n", fds->revents); + nxsem_post(fds->sem); + priv->int_pending = false; + } + } +} + +static int max44009_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup) +{ + FAR struct inode *inode; + FAR struct max44009_dev_s *priv; + int ret; + int i; + + DEBUGASSERT(filep && fds); + inode = filep->f_inode; + + DEBUGASSERT(inode && inode->i_private); + priv = (FAR struct max44009_dev_s *)inode->i_private; + + do + { + ret = nxsem_wait(&priv->dev_sem); + + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + DEBUGASSERT(ret == OK || ret == -EINTR); + } + while (ret == -EINTR); + + if (setup) + { + /* Ignore waits that do not include POLLIN */ + + if ((fds->events & POLLIN) == 0) + { + ret = -EDEADLK; + goto out; + } + + /* This is a request to set up the poll. Find an available slot for the + * poll structure reference */ + + for (i = 0; i < CONFIG_MAX44009_NPOLLWAITERS; i++) + { + /* Find an available slot */ + + if (!priv->fds[i]) + { + /* Bind the poll structure and this slot */ + + priv->fds[i] = fds; + fds->priv = &priv->fds[i]; + break; + } + } + + if (i >= CONFIG_MAX44009_NPOLLWAITERS) + { + fds->priv = NULL; + ret = -EBUSY; + goto out; + } + if (priv->int_pending) + { + max44009_notify(priv); + } + } + else if (fds->priv) + { + /* This is a request to tear down the poll. */ + + struct pollfd **slot = (struct pollfd **)fds->priv; + DEBUGASSERT(slot != NULL); + + /* Remove all memory of the poll setup */ + + *slot = NULL; + fds->priv = NULL; + } +out: + nxsem_post(&priv->dev_sem); + return ret; +} +#endif /* !CONFIG_DISABLE_POLL */ + +static int max44009_int_handler(int irq, FAR void *context, FAR void *arg) +{ + FAR struct max44009_dev_s *priv = (FAR struct max44009_dev_s *)arg; + irqstate_t flags; + + DEBUGASSERT(priv != NULL); + + flags = enter_critical_section(); + priv->int_pending = true; + leave_critical_section(flags); +#ifndef CONFIG_DISABLE_POLL + max44009_notify(priv); +#endif + max44009_dbg("MAX44009 interrupt\n"); + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int max44009_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, + uint8_t addr, FAR struct max44009_config_s *config) +{ + struct max44009_dev_s *priv; + int ret; + + priv = kmm_zalloc(sizeof(struct max44009_dev_s)); + if (!priv) + { + max44009_dbg("Memory cannot be allocated for ALS sensor\n"); + return -ENOMEM; + } + + priv->addr = addr; + priv->i2c = i2c; + priv->config = config; + nxsem_init(&priv->dev_sem, 0, 1); + + ret = register_driver(devpath, &g_alsops, 0666, priv); + max44009_dbg("Registered with %d\n", ret); + if (ret < 0) + { + kmm_free(priv); + max44009_dbg("Error occurred during the driver registering\n"); + return ret; + } + + priv->config->irq_attach(priv->config, max44009_int_handler, priv); + priv->config->irq_enable(priv->config, false); + return ret; +} diff --git a/drivers/sensors/qencoder.c b/drivers/sensors/qencoder.c index be5879ac257e227122ce89ce577b3be432a63e12..6649bf0ab393337bcab4c208c850ae5b6c8ab273 100644 --- a/drivers/sensors/qencoder.c +++ b/drivers/sensors/qencoder.c @@ -236,7 +236,7 @@ errout: /************************************************************************************ * Name: qe_read * - * Description:O + * Description: * A dummy read method. This is provided only to satsify the VFS layer. * ************************************************************************************/ diff --git a/drivers/sensors/zerocross.c b/drivers/sensors/zerocross.c index 3f01650f17863719ab60cd40db32a6201aaadd27..e2260ec0423f533c30d9fe9b08e04798449d83d4 100644 --- a/drivers/sensors/zerocross.c +++ b/drivers/sensors/zerocross.c @@ -370,7 +370,7 @@ errout_with_exclsem: /**************************************************************************** * Name: zc_read * - * Description:O + * Description: * A dummy read method. This is provided only to satsify the VFS layer. * ****************************************************************************/ diff --git a/drivers/serial/tcdrain.c b/drivers/serial/tcdrain.c index 1dcdf456bb77d863d1a343dcecab31f968cf3e15..5171aedf72da8431079f2cbb1245dff6535528ae 100644 --- a/drivers/serial/tcdrain.c +++ b/drivers/serial/tcdrain.c @@ -55,7 +55,7 @@ /**************************************************************************** * Name: tcdrain * - * Descripton: + * Description: * Function for draining the output buffer of a terminal/serial device * * Input Parameters: diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index 3ba4a4f0569d28feb363f955d3a649de0b819b80..79918be449c75b8664d24c7be6efe3559e7134a6 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -518,7 +518,7 @@ static inline void u16550_enablebreaks(FAR struct u16550_s *priv, /**************************************************************************** * Name: u16550_divisor * - * Descrption: + * Description: * Select a divider to produce the BAUD from the UART_CLK. * * BAUD = UART_CLK / (16 * DL), or diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 8c650282bce6e1fdc083d1834be49b50356417d8..06c0a1e81fd9c447babaf140f2b7bd5093d198d3 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c @@ -528,7 +528,7 @@ static int spi_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, /**************************************************************************** * Name: spi_create_bitbang * - * Descripton: + * Description: * Create an instance of the SPI bit-bang driver. * ****************************************************************************/ diff --git a/drivers/syslog/syslog_emergstream.c b/drivers/syslog/syslog_emergstream.c index 8347c15a8e5d961c231b0a8ede30f7dfd9d3074b..e7aef97e2330fbea1ad19eb5cafc979601c3e746 100644 --- a/drivers/syslog/syslog_emergstream.c +++ b/drivers/syslog/syslog_emergstream.c @@ -97,7 +97,7 @@ static void emergstream_putc(FAR struct lib_outstream_s *this, int ch) * Initializes a stream for use with the configured emergency syslog * interface. Only accessible from with the OS SYSLOG logic. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_outstream_s to be initialized. * diff --git a/drivers/syslog/syslog_stream.c b/drivers/syslog/syslog_stream.c index a14a5d4f12ae20a9d88a45ba42a5875f7f46840b..e3e2b1b57ddaf914052bf64a016b1cd5ebb2d3ed 100644 --- a/drivers/syslog/syslog_stream.c +++ b/drivers/syslog/syslog_stream.c @@ -79,7 +79,7 @@ static int syslogstream_flush(FAR struct lib_syslogstream_s *stream) (size_t)iob->io_len); if (nbytes < 0) { - ret = -get_errno(); + ret = (int)nbytes; } else { @@ -172,18 +172,18 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch) */ ret = syslog_putc(ch); - if (ret != EOF) + if (ret >= 0) { this->nput++; return; } - /* The special errno value -EINTR means that syslog_putc() was + /* The special return value -EINTR means that syslog_putc() was * awakened by a signal. This is not a real error and must be * ignored in this context. */ } - while (get_errno() == -EINTR); + while (ret == -EINTR); } } } @@ -199,7 +199,7 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch) * Initializes a stream for use with the configured syslog interface. * Only accessible from with the OS SYSLOG logic. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * @@ -245,7 +245,7 @@ void syslogstream_create(FAR struct lib_syslogstream_s *stream) * Description: * Free resources held by the syslog stream. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * diff --git a/drivers/timers/ds3231.c b/drivers/timers/ds3231.c index 4f1e2a1c9f5b0ede1c4d0948b9078a604421b450..113fb977433dfe974e9809f458894daceb8dc325 100644 --- a/drivers/timers/ds3231.c +++ b/drivers/timers/ds3231.c @@ -321,7 +321,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) ret = I2C_TRANSFER(g_ds3231.i2c, msg, 4); if (ret < 0) { - rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret) + rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret); return ret; } } @@ -415,7 +415,7 @@ int up_rtc_settime(FAR const struct timespec *tp) return -EAGAIN; } - rtc_dumptime(tp, "Setting time"); + rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec); /* Get the broken out time */ @@ -430,18 +430,18 @@ int up_rtc_settime(FAR const struct timespec *tp) #ifdef CONFIG_LIBC_LOCALTIME if (localtime_r(&newtime, &newtm) == NULL) { - rtcerr("ERROR: localtime_r failed\n") + rtcerr("ERROR: localtime_r failed\n"); return -EINVAL; } #else if (gmtime_r(&newtime, &newtm) == NULL) { - rtcerr("ERROR: gmtime_r failed\n") + rtcerr("ERROR: gmtime_r failed\n"); return -EINVAL; } #endif - rtc_dumptime(&tm, "New time"); + rtc_dumptime(&newtm, "New time"); /* Construct the message */ /* Write starting with the seconds regiser */ @@ -536,7 +536,7 @@ int up_rtc_settime(FAR const struct timespec *tp) ret = I2C_TRANSFER(g_ds3231.i2c, msg, 3); if (ret < 0) { - rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret) + rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret); return ret; } } diff --git a/drivers/timers/oneshot.c b/drivers/timers/oneshot.c index 404bb2a1d4f8f0b519d46a4c94c12a7cf6f2908d..8de9a3ef32baf9d3dcb1478cf00002f5adbac394 100644 --- a/drivers/timers/oneshot.c +++ b/drivers/timers/oneshot.c @@ -179,7 +179,7 @@ static int oneshot_close(FAR struct file *filep) /************************************************************************************ * Name: oneshot_read * - * Description:O + * Description: * A dummy read method. This is provided only to satsify the VFS layer. * ************************************************************************************/ diff --git a/drivers/timers/rtc.c b/drivers/timers/rtc.c index f38979ee50be9b2055638fc54afd85f5db8f918f..380bb35419b66085dd3f66eb3c79878f8e7ab556 100644 --- a/drivers/timers/rtc.c +++ b/drivers/timers/rtc.c @@ -784,7 +784,7 @@ static int rtc_unlink(FAR struct inode *inode) * provided to this function. The resulting RTC driver will be registered * at /dev/rtcN where N is the minor number provided to this function. * - * Input parameters: + * Input Parameters: * minor - The minor number of the RTC device. The N in /dev/rtcN * lower - The lower half driver instance. * diff --git a/drivers/timers/timer.c b/drivers/timers/timer.c index d760a2c4c64e7598b268f372bb59aba7eb3970a6..6bb4edeb1962d788d87140dc07459615d607f20a 100644 --- a/drivers/timers/timer.c +++ b/drivers/timers/timer.c @@ -431,7 +431,7 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * When this function is called, the "lower half" driver should be in the * disabled state (as if the stop() method had already been called). * - * Input parameters: + * Input Parameters: * dev path - The full path to the driver to be registers in the NuttX * pseudo-filesystem. The recommended convention is to name all timer * drivers as "/dev/tc0", "/dev/tc1", etc. where the driver @@ -508,7 +508,7 @@ errout: * This function can be called to disable and unregister the timer * device driver. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was returned by timer_register() * * Returned Value: @@ -552,7 +552,7 @@ void timer_unregister(FAR void *handle) * to handle timer expirations. This is a strictly OS internal interface * and may NOT be used by appliction code. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was returned by timer_register() * callback - The new timer interrupt callback * arg - Argument to be provided with the callback diff --git a/drivers/timers/watchdog.c b/drivers/timers/watchdog.c index 06208e49dd0305d1efbdbfab1974d0f45099e443..a1a29fbaf4b81ef12ef3eb6ff1dec4a3b3269b79 100644 --- a/drivers/timers/watchdog.c +++ b/drivers/timers/watchdog.c @@ -439,7 +439,7 @@ static int wdog_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * When this function is called, the "lower half" driver should be in the * disabled state (as if the stop() method had already been called). * - * Input parameters: + * Input Parameters: * dev path - The full path to the driver to be registers in the NuttX * pseudo-filesystem. The recommended convention is to name all watchdog * drivers as "/dev/watchdog0", "/dev/watchdog1", etc. where the driver @@ -518,7 +518,7 @@ errout: * This function can be called to disable and unregister the watchdog * device driver. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was returned by watchdog_register() * * Returned Value: diff --git a/drivers/usbdev/cdcacm.c b/drivers/usbdev/cdcacm.c index 7593156a9161bbce73f4199220ba1158d521c060..4cd4256f1626595a3b709d8d2cf0bf4c698e24cf 100644 --- a/drivers/usbdev/cdcacm.c +++ b/drivers/usbdev/cdcacm.c @@ -2638,7 +2638,7 @@ static void cdcuart_rxint(FAR struct uart_dev_s *dev, bool enable) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * dev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is @@ -2869,7 +2869,7 @@ static bool cdcuart_txempty(FAR struct uart_dev_s *dev) * Register USB serial port (and USB serial console if so configured) and * return the class object. * - * Input Parameter: + * Input Parameters: * minor - Device minor number. E.g., minor 0 would correspond to * /dev/ttyACM0. * classdev - The location to return the CDC serial class' device @@ -3004,7 +3004,7 @@ errout_with_class: * Description: * Register USB serial port (and USB serial console if so configured). * - * Input Parameter: + * Input Parameters: * minor - Device minor number. E.g., minor 0 would correspond to * /dev/ttyACM0. * handle - An optional opaque reference to the CDC/ACM class object that diff --git a/drivers/usbdev/composite.c b/drivers/usbdev/composite.c index 17204d7f81825e61604b98d1c0c14a09aa39561d..6800cd95dbdaa34ff0787a63fff5e6625108b220 100644 --- a/drivers/usbdev/composite.c +++ b/drivers/usbdev/composite.c @@ -786,7 +786,7 @@ static void composite_resume(FAR struct usbdevclass_driver_s *driver, * board-specific implementations in order to obtain the class objects for * each of the members of the composite. * - * Input Parameter: + * Input Parameters: * None * * Returned Value: diff --git a/drivers/usbdev/rndis.c b/drivers/usbdev/rndis.c index 3e1baf2e08a0a5295c425612318f4607190fd714..bc70bc10366c6e77c20d58faf5ac6c27bcfd889e 100644 --- a/drivers/usbdev/rndis.c +++ b/drivers/usbdev/rndis.c @@ -775,7 +775,7 @@ static void rndis_giverxreq(FAR struct rndis_dev_s *priv) * priv: pointer to RNDIS device driver structure * req: the request whose buffer we should fill * - * Returned value: + * Returned Value: * The total length of the request data * * Assumptions: diff --git a/drivers/usbdev/usbmsc.c b/drivers/usbdev/usbmsc.c index 7fdfcbfc8828400f0c1fb28e28c903f5312492d7..14b735301fd33b248b5952d3bfd352983ff11d71 100644 --- a/drivers/usbdev/usbmsc.c +++ b/drivers/usbdev/usbmsc.c @@ -1231,7 +1231,7 @@ void usbmsc_rdcomplete(FAR struct usbdev_ep_s *ep, * In all cases, the success reponse is a zero-length packet; the failure * response is an EP0 stall. * - * Input parameters: + * Input Parameters: * priv - Private state structure for this USB storage instance * stall - true is the action failed and a stall is required * diff --git a/drivers/usbdev/usbmsc.h b/drivers/usbdev/usbmsc.h index 79d26778e83a703f5156ce3f6d3bdd2edad38cd8..d0d93d3489dcce10f23d7f26db41ad39a14b866b 100644 --- a/drivers/usbdev/usbmsc.h +++ b/drivers/usbdev/usbmsc.h @@ -679,7 +679,7 @@ void usbmsc_rdcomplete(FAR struct usbdev_ep_s *ep, * In all cases, the success reponse is a zero-length packet; the failure * response is an EP0 stall. * - * Input parameters: + * Input Parameters: * priv - Private state structure for this USB storage instance * stall - true is the action failed and a stall is required * diff --git a/drivers/usbdev/usbmsc_scsi.c b/drivers/usbdev/usbmsc_scsi.c index 8b20a008c4364a0f6f78fde38458fa4958f891c9..369d926be1c36edacf2b84ed9f8ba469ccd09970 100644 --- a/drivers/usbdev/usbmsc_scsi.c +++ b/drivers/usbdev/usbmsc_scsi.c @@ -1636,7 +1636,7 @@ static int inline usbmsc_setupcmd(FAR struct usbmsc_dev_s *priv, * Called from the worker thread in the USBMSC_STATE_IDLE state. Checks * for the receipt of a bulk CBW. * - * Returned value: + * Returned Value: * If no new, valid CBW is available, this function returns a negated errno. * Otherwise, when a new CBW is successfully parsed, this function sets * priv->thstate to USBMSC_STATE_CMDPARSE and returns OK. @@ -1781,7 +1781,7 @@ static int usbmsc_idlestate(FAR struct usbmsc_dev_s *priv) * This state is entered when usbmsc_idlestate obtains a valid CBW * containing SCSI commands. This function processes those SCSI commands. * - * Returned value: + * Returned Value: * If no write request is available or certain other errors occur, this * function returns a negated errno and stays in the USBMSC_STATE_CMDPARSE * state. Otherwise, when the new CBW is successfully process, this @@ -2097,7 +2097,7 @@ static int usbmsc_cmdparsestate(FAR struct usbmsc_dev_s *priv) * of the USBMSC_STATE_CMDPARSE state that handles extended SCSI read * command handling. * - * Returned value: + * Returned Value: * If no USBDEV write request is available or certain other errors occur, this * function returns a negated errno and stays in the USBMSC_STATE_CMDREAD * state. Otherwise, when the new SCSI read command is fully processed, @@ -2244,7 +2244,7 @@ static int usbmsc_cmdreadstate(FAR struct usbmsc_dev_s *priv) * of the USBMSC_STATE_CMDPARSE state that handles extended SCSI write * command handling. * - * Returned value: + * Returned Value: * If no USBDEV write request is available or certain other errors occur, this * function returns a negated errno and stays in the USBMSC_STATE_CMDWRITE * state. Otherwise, when the new SCSI write command is fully processed, @@ -2384,7 +2384,7 @@ errout: * The USBMSC_STATE_CMDFINISH state is entered when processing of a * command has finished but before status has been returned. * - * Returned value: + * Returned Value: * If no USBDEV write request is available or certain other errors occur, this * function returns a negated errno and stays in the USBMSC_STATE_CMDFINISH * state. Otherwise, when the command is fully processed, this function @@ -2527,7 +2527,7 @@ static int usbmsc_cmdfinishstate(FAR struct usbmsc_dev_s *priv) * That state is after a CBW has been fully processed. This function sends * the concluding CSW. * - * Returned value: + * Returned Value: * If no write request is available or certain other errors occur, this * function returns a negated errno and stays in the USBMSC_STATE_CMDSTATUS * state. Otherwise, when the SCSI statis is successfully returned, this diff --git a/drivers/usbhost/hid_parser.c b/drivers/usbhost/hid_parser.c index 59198faa93749bddb80b54f6360b17630794e7b8..88a167beac6f8bae7e3eb046169205441d228968 100644 --- a/drivers/usbhost/hid_parser.c +++ b/drivers/usbhost/hid_parser.c @@ -398,7 +398,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen, * report. If the given item does not exist in the report, the function * does not modify the report item's data. * - * Input Parameters + * Input Parameters: * report Buffer containing an IN or FEATURE report from an attached * device. * item Pointer to the report item of interest in a struct hid_rptinfo_s @@ -500,7 +500,7 @@ void hid_putitem(FAR uint8_t *report, struct hid_rptitem_s *item) * Description: * Retrieves the size of a given HID report in bytes from it's Report ID. * - * InputParameters: + * Input Parameters: * rptinfo Pointer to a struct hid_rptinfo_s instance containing the parser output. * id Report ID of the report whose size is to be retrieved. * rpttype Type of the report whose size is to be determined, a valued from the diff --git a/drivers/usbhost/usbhost_cdcacm.c b/drivers/usbhost/usbhost_cdcacm.c index 250e561e23ed1a2a3ad62fce016152dd51a1a123..7353af369ec163cee0152850e38c2c01213a9c85 100644 --- a/drivers/usbhost/usbhost_cdcacm.c +++ b/drivers/usbhost/usbhost_cdcacm.c @@ -2623,7 +2623,7 @@ static bool usbhost_rxavailable(FAR struct uart_dev_s *uartdev) * Return true if UART activated RX flow control to block more incoming * data * - * Input parameters: + * Input Parameters: * uartdev - UART device instance * nbuffered - the number of characters currently buffered * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is diff --git a/drivers/usbhost/usbhost_enumerate.c b/drivers/usbhost/usbhost_enumerate.c index a6cbddc9ed6169bc07e04c9161c9fe4751e607ee..cb45a191da07a87fc45db5560c7eebe274a8812f 100644 --- a/drivers/usbhost/usbhost_enumerate.c +++ b/drivers/usbhost/usbhost_enumerate.c @@ -280,7 +280,7 @@ static inline int usbhost_classbind(FAR struct usbhost_hubport_s *hport, * and bound to the hub port, the allocated class instance is returned * into this caller-provided memory location. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * diff --git a/drivers/usbhost/usbhost_findclass.c b/drivers/usbhost/usbhost_findclass.c index 7ae1cad4dc8d952c38232b4f61bfc220aa3fca5d..f92534fd1f31e8c22f858b6f8d23cf7b807d5aec 100644 --- a/drivers/usbhost/usbhost_findclass.c +++ b/drivers/usbhost/usbhost_findclass.c @@ -64,7 +64,7 @@ * classid - ID info for the class under consideration. * devid - ID info reported by the device. * - * Returned Values: + * Returned Value: * TRUE - the class will support this device. * ****************************************************************************/ @@ -127,7 +127,7 @@ static bool usbhost_idmatch(const struct usbhost_id_s *classid, * Input Parameters: * id - Identifies the USB device class that has connect to the USB host. * - * Returned Values: + * Returned Value: * On success this function will return a non-NULL instance of struct * usbhost_registry_s. NULL will be returned on failure. This function * can only fail if (1) id is NULL, or (2) no USB host class is registered diff --git a/drivers/usbhost/usbhost_hidkbd.c b/drivers/usbhost/usbhost_hidkbd.c index 39cbdadfb3446f4442d1846ab8b9b03c8c2fabf2..3a0e07afafcc71c83a8308825d59c0a370fa5570 100644 --- a/drivers/usbhost/usbhost_hidkbd.c +++ b/drivers/usbhost/usbhost_hidkbd.c @@ -653,7 +653,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *priv) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s. NULL is returned on failure; this function will * will fail only if there are insufficient resources to create another @@ -680,7 +680,7 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Input Parameters: * usbclass - A reference to the class instance to be freed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -753,7 +753,7 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *dev * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -824,7 +824,7 @@ static void usbhost_destroy(FAR void *arg) * priv - Driver internal state * keycode - The value to add to the user buffer * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -880,7 +880,7 @@ static void usbhost_putbuffer(FAR struct usbhost_state_s *priv, * stream - The struct lib_outstream_s reference * ch - The character to add to the user buffer * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -908,7 +908,7 @@ static void usbhost_putstream(FAR struct lib_outstream_s *stream, int ch) * scancode - Scan code to be mapped. * modifier - Ctrl,Alt,Shift,GUI modifier bits * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -950,7 +950,7 @@ static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier) * scancode - Scan code to be mapped. * modifier - Ctrl, Alt, Shift, GUI modifier bits * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -999,7 +999,7 @@ static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv, * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1326,7 +1326,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1578,7 +1578,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv, * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1629,12 +1629,12 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) CONFIG_HIDKBD_STACKSIZE, (main_t)usbhost_kbdpoll, (FAR char * const *)NULL); - if (priv->pollpid == ERROR) + if (priv->pollpid < 0) { /* Failed to started the poll thread... probably due to memory resources */ usbhost_givesem(&g_exclsem); - ret = -ENOMEM; + ret = (int)priv->pollpid; goto errout; } @@ -1669,7 +1669,7 @@ errout: * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -1689,7 +1689,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1710,7 +1710,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1732,7 +1732,7 @@ static inline uint32_t usbhost_getle32(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1756,7 +1756,7 @@ static void usbhost_putle32(uint8_t *dest, uint32_t val) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1782,7 +1782,7 @@ static inline int usbhost_tdalloc(FAR struct usbhost_state_s *priv) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1827,7 +1827,7 @@ static inline int usbhost_tdfree(FAR struct usbhost_state_s *priv) * id - In the case where the device supports multiple base classes, * subclasses, or protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate * with the USB host class. NULL is returned on failure; this function @@ -1912,7 +1912,7 @@ static FAR struct usbhost_class_s * * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1981,7 +1981,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass, * usbclass - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -2424,7 +2424,7 @@ errout: * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * diff --git a/drivers/usbhost/usbhost_hidmouse.c b/drivers/usbhost/usbhost_hidmouse.c index 043adb3183a2eec1c7fc77e8afb61e8e0cfdf6e8..4648c3bdb3c5895629b1b7ccb08caa7e708940fe 100644 --- a/drivers/usbhost/usbhost_hidmouse.c +++ b/drivers/usbhost/usbhost_hidmouse.c @@ -513,7 +513,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *priv) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s. NULL is returned on failure; this function will * will fail only if there are insufficient resources to create another @@ -540,7 +540,7 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Input Parameters: * usbclass - A reference to the class instance to be freed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -614,7 +614,7 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -676,7 +676,7 @@ static void usbhost_destroy(FAR void *arg) * Description: * Wake any threads waiting for mouse data * - * Input Paramters: + * Input Parameters: * priv - A reference to the mouse state structure. * * Returned Value: @@ -1038,7 +1038,7 @@ static bool usbhost_threshold(FAR struct usbhost_state_s *priv) * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1448,7 +1448,7 @@ errout: * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1648,7 +1648,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv, * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1699,12 +1699,12 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) CONFIG_HIDMOUSE_STACKSIZE, (main_t)usbhost_mouse_poll, (FAR char * const *)NULL); - if (priv->pollpid == ERROR) + if (priv->pollpid < 0) { /* Failed to started the poll thread... probably due to memory resources */ usbhost_givesem(&g_exclsem); - ret = -ENOMEM; + ret = priv->pollpid; goto errout; } @@ -1739,7 +1739,7 @@ errout: * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -1759,7 +1759,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1780,7 +1780,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1802,7 +1802,7 @@ static inline uint32_t usbhost_getle32(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1826,7 +1826,7 @@ static void usbhost_putle32(uint8_t *dest, uint32_t val) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1852,7 +1852,7 @@ static inline int usbhost_tdalloc(FAR struct usbhost_state_s *priv) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1896,7 +1896,7 @@ static inline int usbhost_tdfree(FAR struct usbhost_state_s *priv) * id - In the case where the device supports multiple base classes, * subclasses, or protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate * with the USB host class. NULL is returned on failure; this function @@ -1982,7 +1982,7 @@ static FAR struct usbhost_class_s * * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -2050,7 +2050,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass, * usbclass - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -2553,7 +2553,7 @@ errout: * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * diff --git a/drivers/usbhost/usbhost_hub.c b/drivers/usbhost/usbhost_hub.c index 58d7c64a2dd8a69b500c1213e83d4e5e6abc10ee..b3fecd661786faae8c1d25ea3ef0a68b4edeb790 100644 --- a/drivers/usbhost/usbhost_hub.c +++ b/drivers/usbhost/usbhost_hub.c @@ -222,7 +222,7 @@ static struct usbhost_registry_s g_hub = * Input Parameters: * hport - A reference to the hub port instance to be freed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -264,7 +264,7 @@ static void usbhost_hport_deactivate(FAR struct usbhost_hubport_s *hport) * Input Parameters: * hport - The hub port to be activated. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned * on any failure. * @@ -308,7 +308,7 @@ static int usbhost_hport_activate(FAR struct usbhost_hubport_s *hport) * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -496,7 +496,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_class_s *hubclass, * Input Parameters: * hubclass - The USB host class instance. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -598,7 +598,7 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) * hport - The port on the parent hub where the this hub is connected. * on - True: enable power; false: Disable power * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -661,7 +661,7 @@ static int usbhost_hubpwr(FAR struct usbhost_hubpriv_s *priv, * Input Parameters: * xfer - The USB host class instance. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -1010,7 +1010,7 @@ static void usbhost_hub_event(FAR void *arg) * class - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -1112,7 +1112,7 @@ static void usbhost_disconnect_event(FAR void *arg) * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -1132,7 +1132,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1154,7 +1154,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * nbytes - The number of bytes actually transferred (or a negated errno * value; * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -1244,7 +1244,7 @@ static void usbhost_callback(FAR void *arg, ssize_t nbytes) * id - In the case where the device supports multiple base classes, * subclasses, or protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate * with the USB host class. NULL is returned on failure; this function @@ -1351,7 +1351,7 @@ errout_with_hub: * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1439,7 +1439,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *hubclass, * class - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -1497,7 +1497,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * diff --git a/drivers/usbhost/usbhost_registerclass.c b/drivers/usbhost/usbhost_registerclass.c index a795b88d02a0235b293cec95aed0532adb868737..8cd52dd02dbc81c38cb3b85a221531afd1650656 100644 --- a/drivers/usbhost/usbhost_registerclass.c +++ b/drivers/usbhost/usbhost_registerclass.c @@ -86,7 +86,7 @@ * usbclass - An write-able instance of struct usbhost_registry_s that * will be maintained in a registry. * - * Returned Values: + * Returned Value: * On success, this function will return zero (OK). Otherwise, a negated * errno value is returned. * diff --git a/drivers/usbhost/usbhost_skeleton.c b/drivers/usbhost/usbhost_skeleton.c index 651f99fb52785bc1293115a22558335d28239680..c79d2498aeb113c5e711b596cd6bc2f0e3356d29 100644 --- a/drivers/usbhost/usbhost_skeleton.c +++ b/drivers/usbhost/usbhost_skeleton.c @@ -242,7 +242,7 @@ static void usbhost_takesem(sem_t *sem) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s. NULL is returned on failure; this function will * will fail only if there are insufficient resources to create another @@ -269,7 +269,7 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Input Parameters: * usbclass - A reference to the class instance to be freed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -345,7 +345,7 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -409,7 +409,7 @@ static void usbhost_destroy(FAR void *arg) * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -623,7 +623,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv, * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -700,7 +700,7 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -720,7 +720,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -741,7 +741,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -763,7 +763,7 @@ static inline uint32_t usbhost_getle32(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -785,7 +785,7 @@ static void usbhost_putle32(uint8_t *dest, uint32_t val) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On sucess, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -811,7 +811,7 @@ static inline int usbhost_talloc(FAR struct usbhost_state_s *priv) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On sucess, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -855,7 +855,7 @@ static inline int usbhost_tfree(FAR struct usbhost_state_s *priv) * id - In the case where the device supports multiple base classes, * subclasses, or protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate * with the USB host class. NULL is returned on failure; this function @@ -930,7 +930,7 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_hubport_s * * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -989,7 +989,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass, * usbclass - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -1061,7 +1061,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * diff --git a/drivers/usbhost/usbhost_storage.c b/drivers/usbhost/usbhost_storage.c index f78a58ce545e80bc18bba36896b2ade7f26c946f..89ff54cac7b06e69ac67968e6306954ba8b20638 100644 --- a/drivers/usbhost/usbhost_storage.c +++ b/drivers/usbhost/usbhost_storage.c @@ -357,7 +357,7 @@ static void usbhost_takesem(sem_t *sem) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s. NULL is returned on failure; this function will * will fail only if there are insufficient resources to create another @@ -411,7 +411,7 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Input Parameters: * usbclass - A reference to the class instance to be freed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -502,7 +502,7 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *dev * Input Parameters: * cbw/csw - A reference to the CBW/CSW to dump. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -548,7 +548,7 @@ static void usbhost_dumpcsw(FAR struct usbmsc_csw_s *csw) * Input Parameters: * cbw - A reference to allocated and initialized CBW to be built. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -674,7 +674,7 @@ usbhost_writecbw(size_t startsector, uint16_t blocksize, * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -912,7 +912,7 @@ static inline int usbhost_inquiry(FAR struct usbhost_state_s *priv) * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -986,7 +986,7 @@ static void usbhost_destroy(FAR void *arg) * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1209,7 +1209,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv, * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1400,7 +1400,7 @@ static inline int usbhost_initvolume(FAR struct usbhost_state_s *priv) * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -1419,7 +1419,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * Input Parameters: * val - A pointer to the first byte of the big endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -1439,7 +1439,7 @@ static inline uint16_t usbhost_getbe16(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1460,7 +1460,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1481,7 +1481,7 @@ static void usbhost_putbe16(uint8_t *dest, uint16_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1503,7 +1503,7 @@ static inline uint32_t usbhost_getle32(const uint8_t *val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1525,7 +1525,7 @@ static inline uint32_t usbhost_getbe32(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1548,7 +1548,7 @@ static void usbhost_putle32(uint8_t *dest, uint32_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1570,7 +1570,7 @@ static void usbhost_putbe32(uint8_t *dest, uint32_t val) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On sucess, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1596,7 +1596,7 @@ static inline int usbhost_talloc(FAR struct usbhost_state_s *priv) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On sucess, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1630,7 +1630,7 @@ static inline int usbhost_tfree(FAR struct usbhost_state_s *priv) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1669,7 +1669,7 @@ static FAR struct usbmsc_cbw_s *usbhost_cbwalloc(FAR struct usbhost_state_s *pri * id - In the case where the device supports multiple base classes, * subclasses, or protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate * with the USB host class. NULL is returned on failure; this function @@ -1748,7 +1748,7 @@ usbhost_create(FAR struct usbhost_hubport_s *hport, * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1807,7 +1807,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass, * usbclass - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -2286,7 +2286,7 @@ static int usbhost_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * diff --git a/drivers/usbhost/usbhost_xboxcontroller.c b/drivers/usbhost/usbhost_xboxcontroller.c index d64ab3353f11eb99eeb336d8ecda2d5be2fd31a0..91b0b5093c8ce50fd773e11d63cec4e4333f6d37 100644 --- a/drivers/usbhost/usbhost_xboxcontroller.c +++ b/drivers/usbhost/usbhost_xboxcontroller.c @@ -365,7 +365,7 @@ static void usbhost_takesem(sem_t *sem) * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s. NULL is returned on failure; this function will * will fail only if there are insufficient resources to create another @@ -392,7 +392,7 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Input Parameters: * usbclass - A reference to the class instance to be freed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -468,7 +468,7 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -534,7 +534,7 @@ static void usbhost_destroy(FAR void *arg) * Description: * Wake any threads waiting for controller data * - * Input Paramters: + * Input Parameters: * priv - A reference to the controller state structure. * * Returned Value: @@ -586,7 +586,7 @@ static void usbhost_notify(FAR struct usbhost_state_s *priv) * Input Parameters: * arg - A reference to the class instance to be destroyed. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1060,7 +1060,7 @@ errout: * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1291,7 +1291,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv, * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1341,12 +1341,12 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) CONFIG_XBOXCONTROLLER_STACKSIZE, (main_t)usbhost_xboxcontroller_poll, (FAR char * const *)NULL); - if (priv->pollpid == ERROR) + if (priv->pollpid < 0) { /* Failed to started the poll thread... probably due to memory resources */ usbhost_givesem(&g_exclsem); - ret = -ENOMEM; + ret = priv->pollpid; goto errout; } @@ -1384,7 +1384,7 @@ errout: * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * ****************************************************************************/ @@ -1404,7 +1404,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1425,7 +1425,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * dest - A pointer to the first byte to save the big endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1447,7 +1447,7 @@ static inline uint32_t usbhost_getle32(const uint8_t *val) * dest - A pointer to the first byte to save the little endian value. * val - The 32-bit value to be saved. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -1471,7 +1471,7 @@ static void usbhost_putle32(uint8_t *dest, uint32_t val) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On sucess, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1497,7 +1497,7 @@ static inline int usbhost_talloc(FAR struct usbhost_state_s *priv) * Input Parameters: * priv - A reference to the class instance. * - * Returned Values: + * Returned Value: * On sucess, zero (OK) is returned. On failure, an negated errno value * is returned to indicate the nature of the failure. * @@ -1541,7 +1541,7 @@ static inline int usbhost_tfree(FAR struct usbhost_state_s *priv) * id - In the case where the device supports multiple base classes, * subclasses, or protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate * with the USB host class. NULL is returned on failure; this function @@ -1624,7 +1624,7 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_hubport_s * * descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -1683,7 +1683,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass, * usbclass - The USB host class entry previously obtained from a call to * create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value * is returned indicating the nature of the failure * @@ -2208,7 +2208,7 @@ errout: * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * diff --git a/drivers/usbmonitor/usbmonitor.c b/drivers/usbmonitor/usbmonitor.c index 6d350f23dbd24eeaee98da759a4697fae3a83ad0..548c39b749933e11ae315741e7a307fa342573bc 100644 --- a/drivers/usbmonitor/usbmonitor.c +++ b/drivers/usbmonitor/usbmonitor.c @@ -197,7 +197,7 @@ static int usbmonitor_daemon(int argc, char **argv) * Input Parameters: * None * - * Returned values: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * @@ -231,25 +231,24 @@ int usbmonitor_start(void) (FAR char * const *)NULL); if (ret < 0) { - int errcode = errno; uerr("ERROR: Failed to start the USB monitor: %d\n", - errcode); - UNUSED(errcode); + ret); } else { g_usbmonitor.pid = ret; uinfo("Started: %d\n", g_usbmonitor.pid); + ret = OK; } sched_unlock(); - return 0; + return ret; } sched_unlock(); uinfo("%s: %d\n", g_usbmonitor.stop ? "Stopping" : "Running", g_usbmonitor.pid); - return 0; + return OK; } /**************************************************************************** @@ -260,7 +259,7 @@ int usbmonitor_start(void) * Input Parameters: * None * - * Returned values: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * diff --git a/drivers/wireless/cc1101.c b/drivers/wireless/cc1101.c index 9c008f798d83f7d4031688c53f66df87fb78f82c..e31a6e2a1db65d6030f93334d6ba088fa668700d 100644 --- a/drivers/wireless/cc1101.c +++ b/drivers/wireless/cc1101.c @@ -326,7 +326,7 @@ void cc1101_access_end(FAR struct cc1101_dev_s *dev) /* CC1101 Access with Range Check * - * Input Paramters: + * Input Parameters: * dev CC1101 Private Structure * addr CC1101 Address * buf Pointer to buffer, either for read or write access diff --git a/drivers/wireless/cc3000/cc3000.c b/drivers/wireless/cc3000/cc3000.c index 447d19f337cb9034d97b8d9227f3d96ea663dcdb..b04a8afa141bc94e799527fb2661434e3bfa8b84 100644 --- a/drivers/wireless/cc3000/cc3000.c +++ b/drivers/wireless/cc3000/cc3000.c @@ -1189,7 +1189,7 @@ errout_without_sem: } /**************************************************************************** - * Name:cc3000_write + * Name: cc3000_write * * Bit of non standard buffer management ahead * The buffer is memory allocated in the user space with space for the spi @@ -1306,7 +1306,7 @@ errout_without_sem: } /**************************************************************************** - * Name:cc3000_ioctl + * Name: cc3000_ioctl ****************************************************************************/ static int cc3000_ioctl(FAR struct file *filep, int cmd, unsigned long arg) diff --git a/drivers/wireless/cc3000/cc3000_common.c b/drivers/wireless/cc3000/cc3000_common.c index acbb1c4ea613279e7e84cab6885eb453321bfa3d..bf8a8da8cd9d5ff462d5f2c0535b2dc0d974d9e2 100644 --- a/drivers/wireless/cc3000/cc3000_common.c +++ b/drivers/wireless/cc3000/cc3000_common.c @@ -40,7 +40,7 @@ #include /**************************************************************************** - * Name:__error__ + * Name: __error__ * * Description: * Stub function for ASSERT macro diff --git a/drivers/wireless/cc3000/socket.c b/drivers/wireless/cc3000/socket.c index 10699a70899075c41ea86b055a21146184a9a19c..b1da05d0c9fc7723eece37caf9bf0e51516bada8 100644 --- a/drivers/wireless/cc3000/socket.c +++ b/drivers/wireless/cc3000/socket.c @@ -130,7 +130,7 @@ int cc3000_socket(int domain, int type, int protocol) if (type < SOCK_STREAM || type >= ARRAY_SIZE(bsd2ti_types)) { - errno = EPROTOTYPE; + set_errno(EPROTOTYPE); return -1; } @@ -145,7 +145,7 @@ int cc3000_socket(int domain, int type, int protocol) break; default: - errno = EAFNOSUPPORT; + set_errno(EAFNOSUPPORT); return -1; } @@ -163,7 +163,7 @@ int cc3000_socket(int domain, int type, int protocol) break; default: - errno = EPROTONOSUPPORT; + set_errno(EPROTONOSUPPORT); return -1; } diff --git a/drivers/wireless/cc3000/socket_imp.c b/drivers/wireless/cc3000/socket_imp.c index a9a830e6ef3914c46d54787b914f56f8d6737f4b..832e696a028dc5eae118b9f31b81218fc781846b 100644 --- a/drivers/wireless/cc3000/socket_imp.c +++ b/drivers/wireless/cc3000/socket_imp.c @@ -512,15 +512,16 @@ int cc3000_gethostbyname_impl(char *hostname, uint16_t usNameLen, unsigned long *out_ip_addr) { tBsdGethostbynameParams ret; - uint8_t *ptr, *args; - - set_errno(EFAIL); + uint8_t *ptr; + uint8_t *args; if (usNameLen > CC3000_HOSTNAME_MAX_LENGTH) { - return get_errno(); + return -EINVAL; } + ret.retVal = OK; + ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); @@ -539,11 +540,9 @@ int cc3000_gethostbyname_impl(char *hostname, uint16_t usNameLen, SimpleLinkWaitEvent(HCI_EVNT_BSD_GETHOSTBYNAME, &ret); - set_errno(ret.retVal); - (*((FAR long *)out_ip_addr)) = ret.outputAddress; - return ret.retVal; + return (int)ret.retVal; } #endif diff --git a/drivers/wireless/cc3000/wlan.c b/drivers/wireless/cc3000/wlan.c index c77488bcf43fba8c067bfca4442db90d4ebf0d74..2e2334393594f09042cd2dc9565696ca71ecf4a4 100644 --- a/drivers/wireless/cc3000/wlan.c +++ b/drivers/wireless/cc3000/wlan.c @@ -1216,7 +1216,7 @@ long wlan_smart_config_set_prefix(FAR char *cNewPrefix) * Input Parameters: * key AES128 key of size 16 bytes * - * Returned Value + * Returned Value: * On success 0, error otherwise. * ****************************************************************************/ @@ -1242,7 +1242,7 @@ signed long aes_read_key(uint8_t *key) * Input Parameters: * key AES128 key of size 16 bytes * - * Returned Value + * Returned Value: * On success 0, error otherwise. * ****************************************************************************/ diff --git a/drivers/wireless/ieee80211/bcmf_driver.c b/drivers/wireless/ieee80211/bcmf_driver.c index 1a3ae7f76e7f16bdb1f388aecb3b8876a7950712..6c17b2b7a91666ac87e5be58ded46191976ed036 100644 --- a/drivers/wireless/ieee80211/bcmf_driver.c +++ b/drivers/wireless/ieee80211/bcmf_driver.c @@ -886,8 +886,8 @@ int bcmf_wl_start_scan(FAR struct bcmf_dev_s *priv, struct iwreq *iwr) /* Start scan_timeout timer */ - wd_start(priv->scan_timeout, BCMF_SCAN_TIMEOUT_TICK, - bcmf_wl_scan_timeout, (wdparm_t)priv); + (void)wd_start(priv->scan_timeout, BCMF_SCAN_TIMEOUT_TICK, + bcmf_wl_scan_timeout, (wdparm_t)priv); return OK; diff --git a/drivers/wireless/ieee80211/bcmf_sdio.c b/drivers/wireless/ieee80211/bcmf_sdio.c index 25f94ab303ee3c4df7701ff88e8f288b69e9011c..d13276c2636d14f656934fbf8dfbf4b45820b3be 100644 --- a/drivers/wireless/ieee80211/bcmf_sdio.c +++ b/drivers/wireless/ieee80211/bcmf_sdio.c @@ -665,8 +665,8 @@ int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv, /* Start the waitdog timer */ - wd_start(sbus->waitdog, BCMF_WAITDOG_TIMEOUT_TICK, bcmf_sdio_waitdog_timeout, - (wdparm_t)priv); + (void)wd_start(sbus->waitdog, BCMF_WAITDOG_TIMEOUT_TICK, + bcmf_sdio_waitdog_timeout, (wdparm_t)priv); /* Spawn bcmf daemon thread */ @@ -760,8 +760,8 @@ int bcmf_sdio_thread(int argc, char **argv) /* Restart the waitdog timer */ - wd_start(sbus->waitdog, BCMF_WAITDOG_TIMEOUT_TICK, - bcmf_sdio_waitdog_timeout, (wdparm_t)priv); + (void)wd_start(sbus->waitdog, BCMF_WAITDOG_TIMEOUT_TICK, + bcmf_sdio_waitdog_timeout, (wdparm_t)priv); /* Wake up device */ diff --git a/drivers/wireless/ieee802154/xbee/xbee.c b/drivers/wireless/ieee802154/xbee/xbee.c index c0a7fd0ca029227895ecd92242f2b67063066e85..3cd82479df768f6b3dd818ac29cfd865628500ed 100644 --- a/drivers/wireless/ieee802154/xbee/xbee.c +++ b/drivers/wireless/ieee802154/xbee/xbee.c @@ -386,7 +386,7 @@ static void xbee_attnworker(FAR void *arg) * datalen - The size of the data section of the frame. This is the value * included as the second and third byte of the frame. * - * Returns: + * Returned Value: * true - Frame type is known and length is logical * false - Frame type is unknown or length is invalid for frame type * @@ -453,7 +453,7 @@ static bool xbee_validate_apiframe(uint8_t frametype, uint16_t datalen) * frame - pointer to the frame data * framelen - size of the overall frame. NOT the data length field * - * Returns: + * Returned Value: * true - Checksum is valid * false - Checksum is invalid * diff --git a/drivers/wireless/ieee802154/xbee/xbee_netdev.c b/drivers/wireless/ieee802154/xbee/xbee_netdev.c index d408d21ec34f7831882623e891b78107859b6edd..77e75e1187df45934725d4665ea01f02cd1a7677 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_netdev.c +++ b/drivers/wireless/ieee802154/xbee/xbee_netdev.c @@ -665,7 +665,7 @@ static void xbeenet_txpoll_expiry(int argc, wdparm_t arg, ...) * Description: * Get the extended address of the PAN coordinator. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * eaddr - The location in which to return the extended address. * @@ -702,7 +702,7 @@ static int xbeenet_coord_eaddr(FAR struct radio_driver_s *radio, * Description: * Get the short address of the PAN coordinator. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * saddr - The location in which to return the short address. * @@ -1165,10 +1165,10 @@ static int xbeenet_ioctl(FAR struct net_driver_s *dev, int cmd, /**************************************************************************** * Name: xbeemac_get_mhrlen * - * Description + * Description: * Calculate the MAC header length given the frame meta-data. * - * Input parameters: + * Input Parameters: * netdev - The network device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -1200,7 +1200,7 @@ static int xbeenet_get_mhrlen(FAR struct radio_driver_s *netdev, * Description: * Requests the transfer of a list of frames to the XBee MAC. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -1272,7 +1272,7 @@ static int xbeenet_req_data(FAR struct radio_driver_s *netdev, * run time. This information is provided to the 6LoWPAN network via the * following structure. * - * Input parameters: + * Input Parameters: * netdev - The network device to be queried * properties - Location where radio properities will be returned. * @@ -1349,7 +1349,7 @@ static int xbeenet_properties(FAR struct radio_driver_s *netdev, * Input Parameters: * mac - Pointer to the mac layer struct to be registered. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * @@ -1392,7 +1392,7 @@ int xbee_netdev_register(XBEEHANDLE xbee) #endif dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->xd_mac = xbee; /* Save the MAC interface instance */ priv->xd_txpoll = wd_create(); /* Create periodic poll timer */ diff --git a/drivers/wireless/spirit/drivers/spirit_netdev.c b/drivers/wireless/spirit/drivers/spirit_netdev.c index 9e9b0655c08334066a7ca01fef771bb84fbc51f6..4a9ef1e54eb66b473c11c2d2835baf714c1d48d6 100644 --- a/drivers/wireless/spirit/drivers/spirit_netdev.c +++ b/drivers/wireless/spirit/drivers/spirit_netdev.c @@ -2262,7 +2262,7 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd, * Description: * Calculate the MAC header length given the frame meta-data. * - * Input parameters: + * Input Parameters: * netdev - The network device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -2294,7 +2294,7 @@ static int spirit_get_mhrlen(FAR struct radio_driver_s *netdev, * indirectly as a consequence of a TX poll that generates a series of * 6LoWPAN radio packets. * - * Input parameters: + * Input Parameters: * netdev - The network device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -2407,7 +2407,7 @@ static int spirit_req_data(FAR struct radio_driver_s *netdev, * run time. This information is provided to the 6LoWPAN network via the * following structure. * - * Input parameters: + * Input Parameters: * netdev - The network device to be queried * properties - Location where radio properities will be returned. * @@ -2812,7 +2812,7 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi, priv->lower = lower; - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/wireless/spirit/include/spirit_general.h b/drivers/wireless/spirit/include/spirit_general.h index 204b3dfcee24472554b3f98cb8feb96a53459760..942a66b982da00a21068b4753c7ce4cf47567e0d 100644 --- a/drivers/wireless/spirit/include/spirit_general.h +++ b/drivers/wireless/spirit/include/spirit_general.h @@ -123,15 +123,4 @@ enum spirit_version_e * Public Function Prototypes ******************************************************************************/ -/****************************************************************************** - * Name: - * - * Description: - * - * Input parameters: - * - * Returned Value: - * - ******************************************************************************/ - #endif /* __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_GENERAL_H */ diff --git a/drivers/wireless/spirit/include/spirit_spi.h b/drivers/wireless/spirit/include/spirit_spi.h index 7cc891d603101ff0c3f4cc3079de0f64880b9df2..6fbdff33d8049253af4c4a38b563286c697f1c27 100644 --- a/drivers/wireless/spirit/include/spirit_spi.h +++ b/drivers/wireless/spirit/include/spirit_spi.h @@ -86,7 +86,7 @@ struct spi_dev_s; /* Forward reference */ * Description: * Read single or multiple SPIRIT1 register * - * Input parameters: + * Input Parameters: * regaddr: Base register's address to be read * buffer: Pointer to the buffer of registers' values to be read * buflen: Number of register values to be read @@ -106,7 +106,7 @@ int spirit_reg_read(FAR struct spirit_library_s *spirit, uint8_t regaddr, * Description: * Read single or multiple SPIRIT1 register. * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * regaddr - Base register's address to write * buffer - Pointer to the buffer of register values to write @@ -129,7 +129,7 @@ int spirit_reg_write(FAR struct spirit_library_s *spirit, uint8_t regaddr, * atomic only in the sense that other accesses to the SPI bus are * prohibited throughout the operation. * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * regaddr - Base register's address to write * clrbits - Bits to clear in the register @@ -150,7 +150,7 @@ int spirit_reg_modify(FAR struct spirit_library_s *spirit, uint8_t regaddr, * Description: * Send a command * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * cmd - Command code to be sent * @@ -168,7 +168,7 @@ int spirit_command(FAR struct spirit_library_s *spirit, uint8_t cmd); * Description: * Read data from RX FIFO * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * buffer - Pointer to the buffer of data values to write * buflen - Number of bytes to be written @@ -188,7 +188,7 @@ int spirit_fifo_read(FAR struct spirit_library_s *spirit, FAR uint8_t *buffer, * Description: * Write data into TX FIFO. * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * buffer - Pointer to the buffer of data values to write * buflen - Number of data values to be written. diff --git a/drivers/wireless/spirit/lib/spirit_linearfifo.c b/drivers/wireless/spirit/lib/spirit_linearfifo.c index 3e22358412d43cd9c7ed4b36ec4e8362b1f579cb..452d8ed373352ce571b1007666d0fdc52d4bfd9b 100644 --- a/drivers/wireless/spirit/lib/spirit_linearfifo.c +++ b/drivers/wireless/spirit/lib/spirit_linearfifo.c @@ -102,7 +102,7 @@ uint8_t spirit_fifo_get_txcount(FAR struct spirit_library_s *spirit) } /****************************************************************************** - * Name: + * Name: spirit_fifo_set_rxalmostfull * * Description: * Sets the almost full threshold for the Rx FIFO. When the number of diff --git a/drivers/wireless/spirit/lib/spirit_spi.c b/drivers/wireless/spirit/lib/spirit_spi.c index 752dc78650cfceb82fb90d2219379b49bd079494..3433dfcafe6e1f318a2b9126886f904860d45152 100644 --- a/drivers/wireless/spirit/lib/spirit_spi.c +++ b/drivers/wireless/spirit/lib/spirit_spi.c @@ -254,7 +254,7 @@ static void spirit_unlock(FAR struct spi_dev_s *spi) * Description: * Read single or multiple SPIRIT1 register * - * Input parameters: + * Input Parameters: * * regaddr: Base register's address to be read * buffer: Pointer to the buffer of registers' values to be read @@ -309,7 +309,7 @@ int spirit_reg_read(FAR struct spirit_library_s *spirit, uint8_t regaddr, * Description: * Read single or multiple SPIRIT1 register. * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * regaddr - Base register's address to write * buffer - Pointer to the buffer of register values to write @@ -363,7 +363,7 @@ int spirit_reg_write(FAR struct spirit_library_s *spirit, uint8_t regaddr, * Description: * Perform atomic read/modify/write on a single SPIRIT1 register. * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * regaddr - Base register's address to write * clrbits - Bits to clear in the register @@ -442,7 +442,7 @@ int spirit_reg_modify(FAR struct spirit_library_s *spirit, uint8_t regaddr, * Description: * Send a command * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * cmd - Command code to be sent * @@ -489,7 +489,7 @@ int spirit_command(FAR struct spirit_library_s *spirit, uint8_t cmd) * Description: * Read data from RX FIFO * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * buffer - Pointer to the buffer of data values to write * buflen - Number of bytes to be written @@ -543,7 +543,7 @@ int spirit_fifo_read(FAR struct spirit_library_s *spirit, FAR uint8_t *buffer, * Description: * Write data into TX FIFO. * - * Input parameters: + * Input Parameters: * spirit - Reference to an instance of the driver state stucture. * buffer - Pointer to the buffer of data values to write * buflen - Number of data values to be written. diff --git a/fs/aio/aio_read.c b/fs/aio/aio_read.c index 462c5ddd26eb676ee22415b62a7e71884ecb19d9..6cb446fe3f37644a0d9bb754a69cc7281d15dac2 100644 --- a/fs/aio/aio_read.c +++ b/fs/aio/aio_read.c @@ -128,19 +128,16 @@ static void aio_read_worker(FAR void *arg) } #endif - /* Set the result of the read */ + /* Set the result of the read operation. */ +#ifdef CONFIG_DEBUG_FS_ERROR if (nread < 0) { - int errcode = get_errno(); - ferr("ERROR: pread failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - aiocbp->aio_result = -errcode; - } - else - { - aiocbp->aio_result = nread; + ferr("ERROR: read failed: %d\n", (int)nread); } +#endif + + aiocbp->aio_result = nread; /* Signal the client */ diff --git a/fs/aio/aioc_contain.c b/fs/aio/aioc_contain.c index ac492abbc37408f16ac7e0d0e58a04a2dabae87d..ee8f18a683183e64a006ec8884edbc6d3d326845 100644 --- a/fs/aio/aioc_contain.c +++ b/fs/aio/aioc_contain.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/aio/aioc_contain.c * - * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -139,7 +140,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp) aioc->aioc_pid = getpid(); #ifdef CONFIG_PRIORITY_INHERITANCE - DEBUGVERIFY(sched_getparam (aioc->aioc_pid, ¶m)); + DEBUGVERIFY(nxsched_getparam (aioc->aioc_pid, ¶m)); aioc->aioc_prio = param.sched_priority; #endif diff --git a/fs/dirent/fs_closedir.c b/fs/dirent/fs_closedir.c index 6b74bbdf19761bad461fcde7a4d0c7bf5d9a28d6..5ab991c3093a112b131645261cc988d13b545eaf 100644 --- a/fs/dirent/fs_closedir.c +++ b/fs/dirent/fs_closedir.c @@ -64,10 +64,10 @@ * 'dirp'. The directory stream descriptor 'dirp' is not available after * this call. * - * Inputs: + * Input Parameters: * dirp -- An instance of type DIR created by a previous call to opendir(); * - * Return: + * Returned Value: * The closedir() function returns 0 on success. On error, -1 is * returned, and errno is set appropriately. * diff --git a/fs/dirent/fs_opendir.c b/fs/dirent/fs_opendir.c index 43b62b9c87910196437b71cdce4d556e4f019ad2..e8bedefff7afb00c3f4dbbef6d687218adfe9904 100644 --- a/fs/dirent/fs_opendir.c +++ b/fs/dirent/fs_opendir.c @@ -61,12 +61,12 @@ * Description: * Handle the case where the inode to be opened is within a mountpoint. * - * Inputs: + * Input Parameters: * inode -- the inode of the mountpoint to open * relpath -- the relative path within the mountpoint to open * dir -- the dirent structure to be initialized * - * Return: + * Returned Value: * On success, OK is returned; Otherwise, a positive errno is returned. * ****************************************************************************/ @@ -127,11 +127,11 @@ static inline int open_mountpoint(FAR struct inode *inode, * Handle the case where the inode to be opened is within the top-level * pseudo-file system. * - * Inputs: + * Input Parameters: * inode -- the inode of the mountpoint to open * dir -- the dirent structure to be initialized * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -164,10 +164,10 @@ static void open_pseudodir(FAR struct inode *inode, FAR struct fs_dirent_s *dir) * and, therefore, it must be a directory node. But is has no children * to be enumerated either. * - * Inputs: + * Input Parameters: * dir -- the dirent structure to be initialized * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -204,10 +204,10 @@ static inline void open_emptydir(FAR struct fs_dirent_s *dir) * directory name, and returns a pointer to the directory stream. The * stream is positioned at the first entry in the directory. * - * Inputs: + * Input Parameters: * path -- the directory to open * - * Return: + * Returned Value: * The opendir() function returns a pointer to the directory stream. On * error, NULL is returned, and errno is set appropriately. * diff --git a/fs/dirent/fs_readdir.c b/fs/dirent/fs_readdir.c index 93b2f654fdb5137de93d9dd3b406d80386854f96..f7cc4a69e6384e8e8ba16e05674cababff6d6e27 100644 --- a/fs/dirent/fs_readdir.c +++ b/fs/dirent/fs_readdir.c @@ -153,10 +153,10 @@ static inline int readpseudodir(struct fs_dirent_s *idir) * to by dir. It returns NULL on reaching the end-of-file or if an error * occurred. * - * Inputs: + * Input Parameters: * dirp -- An instance of type DIR created by a previous call to opendir(); * - * Return: + * Returned Value: * The readdir() function returns a pointer to a dirent structure, or NULL * if an error occurs or end-of-file is reached. On error, errno is set * appropriately. diff --git a/fs/dirent/fs_rewinddir.c b/fs/dirent/fs_rewinddir.c index 7ad252d8aa5af5d5884e963b8c330cc2e22c7fae..6450a5859f3a6456921c33ef3664d874bd2b8fbb 100644 --- a/fs/dirent/fs_rewinddir.c +++ b/fs/dirent/fs_rewinddir.c @@ -93,11 +93,11 @@ static inline void rewindpseudodir(struct fs_dirent_s *idir) * The rewinddir() function resets the position of the * directory stream dir to the beginning of the directory. * - * Inputs: + * Input Parameters: * dirp -- An instance of type DIR created by a previous * call to opendir(); * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/fs/dirent/fs_seekdir.c b/fs/dirent/fs_seekdir.c index 761dba33cd7578a514123d371297c9e6c598f546..896658b690b2129f32b67ab63030a63708d603f2 100644 --- a/fs/dirent/fs_seekdir.c +++ b/fs/dirent/fs_seekdir.c @@ -188,12 +188,12 @@ static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset) * which the next readdir() call will start. seekdir() should be used with * an offset returned by telldir(). * - * Inputs: + * Input Parameters: * dirp -- An instance of type DIR created by a previous * call to opendir(); * offset -- offset to seek to * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/fs/driver/driver.h b/fs/driver/driver.h index bbe605602e17835212f5c55f3d70f42554d8e4d0..dd15fb33bb09fb2386ee165f99224dff9da264aa 100644 --- a/fs/driver/driver.h +++ b/fs/driver/driver.h @@ -69,13 +69,13 @@ extern "C" * Description: * Return the inode of the block driver specified by 'pathname' * - * Inputs: + * Input Parameters: * pathname - the full path to the block driver to be located * mountflags - if MS_RDONLY is not set, then driver must support write * operations (see include/sys/mount.h) * ppinode - address of the location to return the inode reference * - * Return: + * Returned Value: * Returns zero on success or a negated errno on failure: * * EINVAL - pathname or pinode is NULL @@ -98,7 +98,7 @@ int find_blockdriver(FAR const char *pathname, int mountflags, * Create a temporary char driver using drivers/bch to mediate character * oriented accessed to the block driver. * - * Input parameters: + * Input Parameters: * blkdev - The path to the block driver * oflags - Character driver open flags * diff --git a/fs/driver/fs_blockproxy.c b/fs/driver/fs_blockproxy.c index 1f15370bcdf5107d15b4755f0674d7e10aa91370..74d9b75c89a58d54f24d67880e99055fb68383ba 100644 --- a/fs/driver/fs_blockproxy.c +++ b/fs/driver/fs_blockproxy.c @@ -77,7 +77,7 @@ static sem_t g_devno_sem = SEM_INITIALIZER(1); * psuedo-file system. We cannot use mktemp for this because it will * attempt to open() the file. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -146,7 +146,7 @@ static FAR char *unique_chardev(void) * Create a temporary char driver using drivers/bch to mediate character * oriented accessed to the block driver. * - * Input parameters: + * Input Parameters: * blkdev - The path to the block driver * oflags - Character driver open flags * diff --git a/fs/driver/fs_closeblockdriver.c b/fs/driver/fs_closeblockdriver.c index 7c9c60244d91bb04d416e87d6149136e22491e0f..9ce13df6fda05df65b6b82bf4620d8895d5b4a93 100644 --- a/fs/driver/fs_closeblockdriver.c +++ b/fs/driver/fs_closeblockdriver.c @@ -55,10 +55,10 @@ * Description: * Call the close method and release the inode * - * Inputs: + * Input Parameters: * inode - reference to the inode of a block driver opened by open_blockdriver * - * Return: + * Returned Value: * Returns zero on success or a negated errno on failure: * * EINVAL - inode is NULL diff --git a/fs/driver/fs_findblockdriver.c b/fs/driver/fs_findblockdriver.c index 0615a474b233af2d6106f21c649d743ce4575bed..f85bff032f46faf940dc9ed03905b77c2836807f 100644 --- a/fs/driver/fs_findblockdriver.c +++ b/fs/driver/fs_findblockdriver.c @@ -61,13 +61,13 @@ * Description: * Return the inode of the block driver specified by 'pathname' * - * Inputs: + * Input Parameters: * pathname - the full path to the block driver to be located * mountflags - if MS_RDONLY is not set, then driver must support write * operations (see include/sys/mount.h) * ppinode - address of the location to return the inode reference * - * Return: + * Returned Value: * Returns zero on success or a negated errno on failure: * * EINVAL - pathname or pinode is NULL diff --git a/fs/driver/fs_openblockdriver.c b/fs/driver/fs_openblockdriver.c index 9a42020bf787bbcfd0ecf03140e7dd6c27f9efa1..e88d05d75241f9762cffcc6f77e9feb1f3ee77b2 100644 --- a/fs/driver/fs_openblockdriver.c +++ b/fs/driver/fs_openblockdriver.c @@ -56,13 +56,13 @@ * Description: * Return the inode of the block driver specified by 'pathname' * - * Inputs: + * Input Parameters: * pathname - the full path to the block driver to be opened * mountflags - if MS_RDONLY is not set, then driver must support write * operations (see include/sys/mount.h) * ppinode - address of the location to return the inode reference * - * Return: + * Returned Value: * Returns zero on success or a negated errno on failure: * * EINVAL - pathname or pinode is NULL diff --git a/fs/driver/fs_registerblockdriver.c b/fs/driver/fs_registerblockdriver.c index 690961907131d025c86371c459494860ca3a62ca..f1da64c9f1a5f120e0eaf7aa6682bbbcf0deb1e5 100644 --- a/fs/driver/fs_registerblockdriver.c +++ b/fs/driver/fs_registerblockdriver.c @@ -58,7 +58,7 @@ * Description: * Register a block driver inode the pseudo file system. * - * Input parameters: + * Input Parameters: * path - The path to the inode to create * bops - The block driver operations structure * mode - inmode priviledges (not used) diff --git a/fs/driver/fs_registerdriver.c b/fs/driver/fs_registerdriver.c index 501bf93f662a518a796acacaa1b17da62a3987ae..85f32e48a94582816edcf89b692718905d62c830 100644 --- a/fs/driver/fs_registerdriver.c +++ b/fs/driver/fs_registerdriver.c @@ -56,7 +56,7 @@ * Description: * Register a character driver inode the pseudo file system. * - * Input parameters: + * Input Parameters: * path - The path to the inode to create * fops - The file operations structure * mode - inmode priviledges (not used) diff --git a/fs/fat/fs_fat32dirent.c b/fs/fat/fs_fat32dirent.c index 7ea497b62a19c492a986d535c294b1cda8c7ff7c..bd1655aa79decdd979592bb8836944cfadf72577 100644 --- a/fs/fat/fs_fat32dirent.c +++ b/fs/fat/fs_fat32dirent.c @@ -182,7 +182,7 @@ static uint8_t fat_lfnchecksum(const uint8_t *sfname) /**************************************************************************** * Name: fat_parsesfname * - * Desciption: Convert a user filename into a properly formatted FAT + * Description: Convert a user filename into a properly formatted FAT * (short 8.3) filename as it would appear in a directory entry. Here are * the rules for the 8+3 short file name in the directory: * @@ -213,7 +213,7 @@ static uint8_t fat_lfnchecksum(const uint8_t *sfname) * code pages". The logic below does not, at present, support any other * character sets. * - * Returned value: + * Returned Value: * OK - The path refers to a valid 8.3 FAT file name and has been properly * converted and stored in dirinfo. * <0 - Otherwise an negated error is returned meaning that the string is @@ -458,7 +458,7 @@ errout: /**************************************************************************** * Name: fat_parselfname * - * Desciption: Convert a user filename into a properly formatted FAT + * Description: Convert a user filename into a properly formatted FAT * long filename as it would appear in a directory entry. Here are * the rules for the long file name in the directory: * @@ -468,7 +468,7 @@ errout: * 2. '.' (dot) can occur more than once in a filename. Extension is * the substring after the last dot. * - * Returned value: + * Returned Value: * OK - The path refers to a valid long file name and has been properly * stored in dirinfo. * <0 - Otherwise an negated error is returned meaning that the string is @@ -549,7 +549,7 @@ errout: /**************************************************************************** * Name: fat_createalias * - * Desciption: Given a valid long file name, create a short filename alias. + * Description: Given a valid long file name, create a short filename alias. * Here are the rules for creation of the alias: * * 1. All uppercase @@ -562,7 +562,7 @@ errout: * * This function is called only from fat_putlfname() * - * Returned value: + * Returned Value: * OK - The alias was created correctly. * <0 - Otherwise an negated error is returned. * @@ -761,13 +761,13 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo) /**************************************************************************** * Name: fat_findalias * - * Desciption: Make sure that the short alias for the long file name is + * Description: Make sure that the short alias for the long file name is * unique, ie., that there is no other * * NOTE: This function does not restore the directory entry that was in the * sector cache * - * Returned value: + * Returned Value: * OK - The alias is unique. * <0 - Otherwise an negated error is returned. * @@ -800,14 +800,14 @@ static inline int fat_findalias(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_uniquealias * - * Desciption: Make sure that the short alias for the long file name is + * Description: Make sure that the short alias for the long file name is * unique, modifying the alias as necessary to assure uniqueness. * * NOTE: This function does not restore the directory entry that was in the * sector cache * * information upon return. - * Returned value: + * Returned Value: * OK - The alias is unique. * <0 - Otherwise an negated error is returned. * @@ -913,7 +913,7 @@ static inline int fat_uniquealias(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_path2dirname * - * Desciption: Convert a user filename into a properly formatted FAT + * Description: Convert a user filename into a properly formatted FAT * (short 8.3) filename as it would appear in a directory entry. * ****************************************************************************/ @@ -951,7 +951,7 @@ static int fat_path2dirname(const char **path, struct fat_dirinfo_s *dirinfo, /**************************************************************************** * Name: fat_findsfnentry * - * Desciption: Find a short file name directory entry. Returns OK if the + * Description: Find a short file name directory entry. Returns OK if the * directory exists; -ENOENT if it does not. * ****************************************************************************/ @@ -1038,7 +1038,7 @@ static int fat_findsfnentry(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_cmplfnchunk * - * Desciption: There are 13 characters per LFN entry, broken up into three + * Description: There are 13 characters per LFN entry, broken up into three * chunks for characts 1-5, 6-11, and 12-13. This function will perform * the comparison of a single chunk. * @@ -1102,7 +1102,7 @@ static bool fat_cmplfnchunk(uint8_t *chunk, const uint8_t *substr, int nchunk) /**************************************************************************** * Name: fat_cmplfname * - * Desciption: Given an LFN directory entry, compare a substring of the name + * Description: Given an LFN directory entry, compare a substring of the name * to a portion in the directory entry. * ****************************************************************************/ @@ -1146,7 +1146,7 @@ static bool fat_cmplfname(const uint8_t *direntry, const uint8_t *substr) /**************************************************************************** * Name: fat_findlfnentry * - * Desciption: Find a sequence of long file name directory entries. + * Description: Find a sequence of long file name directory entries. * * NOTE: As a side effect, this function returns with the sector containing * the short file name directory entry in the cache. @@ -1368,7 +1368,7 @@ next_entry: /**************************************************************************** * Name: fat_allocatesfnentry * - * Desciption: Find a free directory entry for a short file name entry. + * Description: Find a free directory entry for a short file name entry. * ****************************************************************************/ @@ -1450,7 +1450,7 @@ static inline int fat_allocatesfnentry(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_allocatelfnentry * - * Desciption: Find a sequence of free directory entries for a several long + * Description: Find a sequence of free directory entries for a several long * and one short file name entry. * * On entry, dirinfo.dir refers to the first interesting entry the directory. @@ -1592,7 +1592,7 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_getsfname * - * Desciption: Get the 8.3 filename from a directory entry. On entry, the + * Description: Get the 8.3 filename from a directory entry. On entry, the * short file name entry is already in the cache. * ****************************************************************************/ @@ -1711,7 +1711,7 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer, /**************************************************************************** * Name: fat_getlfnchunk * - * Desciption: There are 13 characters per LFN entry, broken up into three + * Description: There are 13 characters per LFN entry, broken up into three * chunks for characts 1-5, 6-11, and 12-13. This function will get the * file name characters from one chunk. * @@ -1742,7 +1742,7 @@ static void fat_getlfnchunk(uint8_t *chunk, uint8_t *dest, int nchunk) /**************************************************************************** * Name: fat_getlfname * - * Desciption: Get the long filename from a sequence of directory entries. + * Description: Get the long filename from a sequence of directory entries. * On entry, the "last" long file name entry is in the cache. Returns with * the short file name entry in the cache. * @@ -1903,7 +1903,7 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di /**************************************************************************** * Name: fat_putsfname * - * Desciption: Write the short directory entry name. + * Description: Write the short directory entry name. * * Assumption: The directory sector is in the cache. * @@ -1928,7 +1928,7 @@ static int fat_putsfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo /**************************************************************************** * Name: fat_initlfname * - * Desciption: There are 13 characters per LFN entry, broken up into three + * Description: There are 13 characters per LFN entry, broken up into three * chunks for characts 1-5, 6-11, and 12-13. This function will put the * 0xffff characters into one chunk. * @@ -1954,7 +1954,7 @@ static void fat_initlfname(uint8_t *chunk, int nchunk) /**************************************************************************** * Name: fat_putlfnchunk * - * Desciption: There are 13 characters per LFN entry, broken up into three + * Description: There are 13 characters per LFN entry, broken up into three * chunks for characts 1-5, 6-11, and 12-13. This function will put the * file name characters into one chunk. * @@ -1986,7 +1986,7 @@ static void fat_putlfnchunk(uint8_t *chunk, const uint8_t *src, int nchunk) /**************************************************************************** * Name: fat_putlfname * - * Desciption: Write the long filename into a sequence of directory entries. + * Description: Write the long filename into a sequence of directory entries. * On entry, the "last" long file name entry is in the cache. Returns with * the short file name entry in the cache. * @@ -2192,7 +2192,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_putsfdirentry * - * Desciption: Write a short file name directory entry + * Description: Write a short file name directory entry * * Assumption: The directory sector is in the cache. The caller will write * sector information. @@ -2236,7 +2236,7 @@ static int fat_putsfdirentry(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_finddirentry * - * Desciption: Given a path to something that may or may not be in the file + * Description: Given a path to something that may or may not be in the file * system, return the description of the directory entry of the requested * item. * @@ -2407,7 +2407,7 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo, /**************************************************************************** * Name: fat_allocatedirentry * - * Desciption: + * Description: * Find (or allocate) all needed directory entries to contain the file name * ****************************************************************************/ @@ -2544,7 +2544,7 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs, /**************************************************************************** * Name: fat_freedirentry * - * Desciption: Free the directory entry. + * Description: Free the directory entry. * * NOTE: As a side effect, this function returns with the sector containing * the deleted short file name directory entry in the cache. @@ -2647,7 +2647,7 @@ int fat_freedirentry(struct fat_mountpt_s *fs, struct fat_dirseq_s *seq) /**************************************************************************** * Name: fat_dirname2path * - * Desciption: Convert a filename in a raw directory entry into a user + * Description: Convert a filename in a raw directory entry into a user * filename. This is essentially the inverse operation of that performed * by fat_path2dirname. See that function for more details. * @@ -2690,7 +2690,7 @@ int fat_dirname2path(struct fat_mountpt_s *fs, struct fs_dirent_s *dir) /**************************************************************************** * Name: fat_dirnamewrite * - * Desciption: Write the (possibly long) directory entry name. This function + * Description: Write the (possibly long) directory entry name. This function * is called only from fat_rename to write the new file name. * * Assumption: The directory sector containing the short file name entry @@ -2731,7 +2731,7 @@ int fat_dirnamewrite(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) /**************************************************************************** * Name: fat_dirwrite * - * Desciption: Write a directory entry, possibly with a long file name. + * Description: Write a directory entry, possibly with a long file name. * Called from: * * fat_mkdir() to write the new FAT directory entry. @@ -2777,7 +2777,7 @@ int fat_dirwrite(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo, /**************************************************************************** * Name: fat_dircreate * - * Desciption: Create a directory entry for a new file + * Description: Create a directory entry for a new file * ****************************************************************************/ @@ -2809,7 +2809,7 @@ int fat_dircreate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) /**************************************************************************** * Name: fat_remove * - * Desciption: Remove a directory or file from the file system. This + * Description: Remove a directory or file from the file system. This * implements both rmdir() and unlink(). * ****************************************************************************/ diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c index cdbfc2d4cb580718d24520b8a8545f8e66d5c528..47a12574faa72940fe4dabf47d0b5be1ccf19aa9 100644 --- a/fs/fat/fs_fat32util.c +++ b/fs/fat/fs_fat32util.c @@ -813,7 +813,8 @@ off_t fat_cluster2sector(FAR struct fat_mountpt_s *fs, uint32_t cluster) * Description: * Get the next cluster start from the FAT. * - * Return: <0: error, 0:cluster unassigned, >=0: start sector of cluster + * Returned Value: + * <0: error, 0:cluster unassigned, >=0: start sector of cluster * ****************************************************************************/ @@ -1161,7 +1162,7 @@ int fat_removechain(struct fat_mountpt_s *fs, uint32_t cluster) * Add a new cluster to the chain following cluster (if cluster is non- * NULL). if cluster is zero, then a new chain is created. * - * Return: + * Returned Value: * <0:error, 0: no free cluster, >=2: new cluster number * ****************************************************************************/ diff --git a/fs/inode/fs_inodereserve.c b/fs/inode/fs_inodereserve.c index 1c08b0556769e1fa7e259b7aeac5039a300fc0be..f1b0bc685fd31104fee3938d81a885f13a91f745 100644 --- a/fs/inode/fs_inodereserve.c +++ b/fs/inode/fs_inodereserve.c @@ -144,7 +144,7 @@ static void inode_insert(FAR struct inode *node, * Reserve an (initialized) inode the pseudo file system. The initial * reference count on the new inode is zero. * - * Input parameters: + * Input Parameters: * path - The path to the inode to create * inode - The location to return the inode pointer * diff --git a/fs/inode/inode.h b/fs/inode/inode.h index 71b1af8e92792bf6d8070079e349dfb7e0c006ea..ae1ef0ce48eb17b86dae90406c52595c47c21a44 100644 --- a/fs/inode/inode.h +++ b/fs/inode/inode.h @@ -293,7 +293,7 @@ const char *inode_nextname(FAR const char *name); * * NOTE: Caller must hold the inode semaphore * - * Input parameters: + * Input Parameters: * path - The path to the inode to create * inode - The location to return the inode pointer * diff --git a/fs/mount/fs_automount.c b/fs/mount/fs_automount.c index e73ce50e2449cc893ad72281e37903a6da95f45e..41de262749f864d8b75d4c851dd68bf1033ef878 100644 --- a/fs/mount/fs_automount.c +++ b/fs/mount/fs_automount.c @@ -303,11 +303,8 @@ static int automount_unmount(FAR struct automounter_state_s *priv) (uint32_t)((uintptr_t)priv)); if (ret < 0) { - errcode = get_errno(); - DEBUGASSERT(errcode > 0); - - ferr("ERROR: wd_start failed: %d\n", errcode); - return -ret; + ferr("ERROR: wd_start failed: %d\n", ret); + return ret; } } diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index 62a982b40e8fdf15858117413be445511564cf03..404b700fce733519a10c62532cbf07a014946b65 100644 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -214,7 +214,7 @@ mount_findfs(FAR const struct fsmap_t *fstab, FAR const char *filesystemtype) * mount() attaches the filesystem specified by the 'source' block device * name into the root file system at the path specified by 'target.' * - * Return: + * Returned Value: * Zero is returned on success; -1 is returned on an error and errno is * set appropriately: * diff --git a/fs/mount/fs_umount2.c b/fs/mount/fs_umount2.c index e342ae2e16dfd06745113375caf577eb48ad9bf5..598cb7b1967f72cf8e8277533cf15f38d01ea958 100644 --- a/fs/mount/fs_umount2.c +++ b/fs/mount/fs_umount2.c @@ -59,7 +59,7 @@ * umount() detaches the filesystem mounted at the path specified by * 'target.' * - * Return: + * Returned Value: * Zero is returned on success; -1 is returned on an error and errno is * set appropriately: * diff --git a/fs/mqueue/mq_close.c b/fs/mqueue/mq_close.c index 4578c1cc085b9b3153566b3185d7b70bc53febd5..adbe02535021f393b3e0f16b5dbe878179d35a87 100644 --- a/fs/mqueue/mq_close.c +++ b/fs/mqueue/mq_close.c @@ -67,7 +67,7 @@ * mqdes - Message queue descriptor. * group - Group that has the open descriptor. * - * Return Value: + * Returned Value: * Zero (OK) if the message queue is closed successfully. Otherwise, a * negated errno value is returned. * @@ -125,7 +125,7 @@ int nxmq_close_group(mqd_t mqdes, FAR struct task_group_s *group) * Parameters: * mqdes - Message queue descriptor. * - * Return Value: + * Returned Value: * 0 (OK) if the message queue is closed successfully, * otherwise, -1 (ERROR). * @@ -176,7 +176,7 @@ int mq_close(mqd_t mqdes) * Parameters: * inode - The message queue inode * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index 5c372a50d5bc5ab2b0fb3c5c29b3a75e2a67b71c..2f9a338fdaf7b307abd9ed594a1d32ff439e3ab0 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -79,7 +79,7 @@ * created to determine the maximum number of * messages that may be placed in the message queue. * - * Return Value: + * Returned Value: * A message queue descriptor or (mqd_t)-1 (ERROR) * * Assumptions: diff --git a/fs/mqueue/mq_unlink.c b/fs/mqueue/mq_unlink.c index 9705a0ef8bad8998890e0772e6a4fc22bae6fc4a..7610eee43c03ebec412a44e3da9cb10bb784454a 100644 --- a/fs/mqueue/mq_unlink.c +++ b/fs/mqueue/mq_unlink.c @@ -66,7 +66,7 @@ * Parameters: * mq_name - Name of the message queue * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/fs/mqueue/mqueue.h b/fs/mqueue/mqueue.h index 4edc08ece18b0d2f11e264d8fb94b940746be45b..b8cdb36d206e4c36f6bec2943212dedae8b3f6aa 100644 --- a/fs/mqueue/mqueue.h +++ b/fs/mqueue/mqueue.h @@ -80,7 +80,7 @@ extern "C" * Parameters: * inode - The message queue inode * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/fs/nfs/nfs_util.c b/fs/nfs/nfs_util.c index 8a6967cbbea439ed58765bf98f65cda689cbf53d..c012ef39b51169baafd64e68aa6ffa1519ea75a9 100644 --- a/fs/nfs/nfs_util.c +++ b/fs/nfs/nfs_util.c @@ -157,7 +157,7 @@ void nfs_semgive(struct nfsmount *nmp) /**************************************************************************** * Name: nfs_checkmount * - * Desciption: Check if the mountpoint is still valid. + * Description: Check if the mountpoint is still valid. * * The caller should hold the mountpoint semaphore * @@ -190,11 +190,11 @@ int nfs_checkmount(struct nfsmount *nmp) /**************************************************************************** * Name: nfs_request * - * Desciption: + * Description: * Perform the NFS request. On successful receipt, it verifies the NFS level of the * returned values. * - * Return Value: + * Returned Value: * Zero on success; a positive errno value on failure. * ****************************************************************************/ @@ -255,7 +255,7 @@ tryagain: /**************************************************************************** * Name: nfs_lookup * - * Desciption: + * Description: * Given a directory file handle, and the path to file in the directory, * return the file handle of the path and attributes of both the file and * the directory containing the file. @@ -376,11 +376,11 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename, /**************************************************************************** * Name: nfs_findnode * - * Desciption: + * Description: * Given a path to something that may or may not be in the file system, * return the handle of the directory entry of the requested object. * - * Return Value: + * Returned Value: * Zero on success; a positive errno value on failure. * ****************************************************************************/ @@ -483,12 +483,12 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath, /**************************************************************************** * Name: nfs_finddir * - * Desciption: + * Description: * Given a path to something that may or may not be in the file system, * return the handle of the entry of the directory containing the requested * object. * - * Return Value: + * Returned Value: * Zero on success; a positive errno value on failure. * ****************************************************************************/ @@ -574,10 +574,10 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath, /**************************************************************************** * Name: nfs_attrupdate * - * Desciption: + * Description: * Update file attributes on write or after the file is modified. * - * Return Value: + * Returned Value: * None. * ****************************************************************************/ diff --git a/fs/nxffs/nxffs.h b/fs/nxffs/nxffs.h index bc979a3050a1f726e3c90cdc98e9f8a8177ff08e..c6ae19bed1a174eb7d9f5f201179aab9e931682a 100644 --- a/fs/nxffs/nxffs.h +++ b/fs/nxffs/nxffs.h @@ -386,7 +386,7 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume); * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint16_t representing the whole 16-bit integer value * * Defined in nxffs_util.c @@ -405,7 +405,7 @@ uint16_t nxffs_rdle16(FAR const uint8_t *val); * dest - A pointer to the first byte to save the little endian value. * val - The 16-bit value to be saved. * - * Returned Values: + * Returned Value: * None * * Defined in nxffs_util.c @@ -423,7 +423,7 @@ void nxffs_wrle16(uint8_t *dest, uint16_t val); * Input Parameters: * val - A pointer to the first byte of the little endian value. * - * Returned Values: + * Returned Value: * A uint32_t representing the whole 32-bit integer value * * Defined in nxffs_util.c @@ -461,7 +461,7 @@ void nxffs_wrle32(uint8_t *dest, uint32_t val); * buffer - Address of the start of the memory to check. * buflen - The number of bytes to check. * - * Returned Values: + * Returned Value: * The number of erased bytes found at the beginning of the memory region. * * Defined in nxffs_util.c @@ -581,7 +581,7 @@ int nxffs_getc(FAR struct nxffs_volume_s *volume, uint16_t reserve); * caller may call kmm_free upon return of this function if necessary to * free the entry container. * - * Input parameters: + * Input Parameters: * entry - The entry to be freed. * * Returned Value: @@ -679,7 +679,7 @@ off_t nxffs_inodeend(FAR struct nxffs_volume_s *volume, * volume - Describes the NXFFS volume * block - The (logical) block number to load and verify. * - * Returned Values: + * Returned Value: * OK (zero( is returned on success. Otherwise, a negated errno value is * returned indicating the nature of the failure: * @@ -836,7 +836,7 @@ FAR struct nxffs_wrfile_s *nxffs_findwriter(FAR struct nxffs_volume_s *volume); * Note that in either case, the inode name has already been written to * FLASH. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * entry - Describes the inode header to write * @@ -858,7 +858,7 @@ int nxffs_wrinode(FAR struct nxffs_volume_s *volume, * The packing logic has moved an inode. Check if any open files are using * this inode and, if so, move the data in the open file structure as well. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * entry - Describes the new inode entry * @@ -877,7 +877,7 @@ int nxffs_updateinode(FAR struct nxffs_volume_s *volume, * Description: * Zero-extend a file. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * entry - Describes the new inode entry * length - The new, extended length of the file @@ -1074,7 +1074,7 @@ int nxffs_rminode(FAR struct nxffs_volume_s *volume, FAR const char *name); * Input Parameters: * volume - The volume to be packed. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * diff --git a/fs/nxffs/nxffs_block.c b/fs/nxffs/nxffs_block.c index c1cad2afe4a3aeed7ff89f1589925d533e972fe7..06d5174949363d5f400c5419f695036d97640c08 100644 --- a/fs/nxffs/nxffs_block.c +++ b/fs/nxffs/nxffs_block.c @@ -66,7 +66,7 @@ * volume - Describes the NXFFS volume * block - The (logical) block number to load and verify. * - * Returned Values: + * Returned Value: * OK (zero( is returned on success. Otherwise, a negated errno value is * returned indicating the nature of the failure: * diff --git a/fs/nxffs/nxffs_inode.c b/fs/nxffs/nxffs_inode.c index 2240c18313f2618283bf0d734a719e472dc4a337..e3c52421a34a65cf221a1e04905bd3ed5423a262 100644 --- a/fs/nxffs/nxffs_inode.c +++ b/fs/nxffs/nxffs_inode.c @@ -213,7 +213,7 @@ errout: * caller may call kmm_free upon return of this function if necessary to * free the entry container. * - * Input parameters: + * Input Parameters: * entry - The entry to be freed. * * Returned Value: diff --git a/fs/nxffs/nxffs_open.c b/fs/nxffs/nxffs_open.c index f5a65e10d2e8150e0cd6f1bf5f4853aabd109103..8276a399a63e12e607fa3b8938c70255cb9ea013 100644 --- a/fs/nxffs/nxffs_open.c +++ b/fs/nxffs/nxffs_open.c @@ -855,7 +855,7 @@ static inline void nxffs_freeofile(FAR struct nxffs_volume_s *volume, * file was open for writing, and finally, * 3. Write the new file inode. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * wrfile - Describes the state of the open file * @@ -1200,7 +1200,7 @@ errout: * Note that in either case, the inode name has already been written to * FLASH. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * entry - Describes the inode header to write * @@ -1283,7 +1283,7 @@ errout: * The packing logic has moved an inode. Check if any open files are using * this inode and, if so, move the data in the open file structure as well. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * entry - Describes the new inode entry * diff --git a/fs/nxffs/nxffs_pack.c b/fs/nxffs/nxffs_pack.c index 134ee430a63da248c604b823b55ecd9e39796a3a..0c6819a465f1d7d2b62d6d733dce6401763894f6 100644 --- a/fs/nxffs/nxffs_pack.c +++ b/fs/nxffs/nxffs_pack.c @@ -164,7 +164,7 @@ static off_t nxffs_packtell(FAR struct nxffs_volume_s *volume, * Input Parameters: * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -191,7 +191,7 @@ static inline bool nxffs_packvalid(FAR struct nxffs_pack_s *pack) * volume - The volume to be packed. * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * The offset to the data area on the first valid block. Zero is return * if there are no valid blocks or if there are no valid inode headers * after the first valid block. @@ -261,7 +261,7 @@ static inline off_t nxffs_mediacheck(FAR struct nxffs_volume_s *volume, * -- then no packing can be performed. In this case, then the free * flash offset is returned through this location. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. If -ENOSPC is returned then the * free FLASH offset is also returned. @@ -398,7 +398,7 @@ static inline int nxffs_startpos(FAR struct nxffs_volume_s *volume, * offset - FLASH offset to the data block header (will be zero for zero- * files. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * @@ -441,7 +441,7 @@ static int nxffs_srcsetup(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * @@ -618,7 +618,7 @@ errout: * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure (not used). * @@ -727,7 +727,7 @@ static int nxffs_wrinodehdr(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * @@ -782,7 +782,7 @@ static void nxffs_wrdathdr(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * None. * ****************************************************************************/ @@ -830,7 +830,7 @@ static void nxffs_packtransfer(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * @@ -872,7 +872,7 @@ static int nxffs_endsrcblock(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * @@ -1057,7 +1057,7 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * If there is an active writer of the volume, its open file instance is * returned. NULL is returned otherwise. * @@ -1125,7 +1125,7 @@ nxffs_setupwriter(FAR struct nxffs_volume_s *volume, * volume - The volume to be packed * pack - The volume packing state structure. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * @@ -1257,7 +1257,7 @@ static inline int nxffs_packwriter(FAR struct nxffs_volume_s *volume, * Input Parameters: * volume - The volume to be packed. * - * Returned Values: + * Returned Value: * Zero on success; Otherwise, a negated errno value is returned to * indicate the nature of the failure. * diff --git a/fs/nxffs/nxffs_util.c b/fs/nxffs/nxffs_util.c index ac51140fa35b8020bf31dd443cc07bd1ae10ef29..7893798ade1a0fcdaefb09657062d3335f598d09 100644 --- a/fs/nxffs/nxffs_util.c +++ b/fs/nxffs/nxffs_util.c @@ -143,7 +143,7 @@ void nxffs_wrle32(uint8_t *dest, uint32_t val) * buffer - Address of the start of the memory to check. * buflen - The number of bytes to check. * - * Returned Values: + * Returned Value: * The number of erased bytes found at the beginning of the memory region. * ****************************************************************************/ diff --git a/fs/nxffs/nxffs_write.c b/fs/nxffs/nxffs_write.c index 1fd761e4401dc0fc05797fe21d56e8830f0dd756..c788947d83be827aea18d32ec44f5c44ca5263f0 100644 --- a/fs/nxffs/nxffs_write.c +++ b/fs/nxffs/nxffs_write.c @@ -633,7 +633,7 @@ errout: * Description: * Zero-extend a file. * - * Input parameters + * Input Parameters: * volume - Describes the NXFFS volume * entry - Describes the new inode entry * length - The new, extended length of the file diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index e269d873e3abbfa26db7f2eb69f42e6e97d35b22..5b5801aa91ab99c7f7cf8c449c553dada37ff8df 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -77,6 +77,7 @@ ****************************************************************************/ extern const struct procfs_operations proc_operations; +extern const struct procfs_operations irq_operations; extern const struct procfs_operations cpuload_operations; extern const struct procfs_operations meminfo_operations; extern const struct procfs_operations module_operations; @@ -124,8 +125,12 @@ static const struct procfs_entry_s g_procfs_entries[] = { "cpuload", &cpuload_operations, PROCFS_FILE_TYPE }, #endif +#ifdef CONFIG_SCHED_IRQMONITOR + { "irqs", &irq_operations, PROCFS_FILE_TYPE }, +#endif + #ifndef CONFIG_FS_PROCFS_EXCLUDE_MEMINFO - { "meminfo", &meminfo_operations, PROCFS_FILE_TYPE }, + { "meminfo", &meminfo_operations, PROCFS_FILE_TYPE }, #endif #if defined(CONFIG_MODULE) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) @@ -133,15 +138,15 @@ static const struct procfs_entry_s g_procfs_entries[] = #endif #ifndef CONFIG_FS_PROCFS_EXCLUDE_BLOCKS - { "fs/blocks", &mount_procfsoperations, PROCFS_FILE_TYPE }, + { "fs/blocks", &mount_procfsoperations, PROCFS_FILE_TYPE }, #endif #ifndef CONFIG_FS_PROCFS_EXCLUDE_MOUNT - { "fs/mount", &mount_procfsoperations, PROCFS_FILE_TYPE }, + { "fs/mount", &mount_procfsoperations, PROCFS_FILE_TYPE }, #endif #ifndef CONFIG_FS_PROCFS_EXCLUDE_USAGE - { "fs/usage", &mount_procfsoperations, PROCFS_FILE_TYPE }, + { "fs/usage", &mount_procfsoperations, PROCFS_FILE_TYPE }, #endif #if defined(CONFIG_FS_SMARTFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS) diff --git a/fs/procfs/fs_procfsutil.c b/fs/procfs/fs_procfsutil.c index 7a71ff18540ff2f29c81f672959b91c2ad9f1c4a..9dd4f5367409357bee64b2374c6ee12242a12653 100644 --- a/fs/procfs/fs_procfsutil.c +++ b/fs/procfs/fs_procfsutil.c @@ -124,7 +124,7 @@ size_t procfs_memcpy(FAR const char *src, size_t srclen, /* Handle the remaining offset */ srclen -= lnoffset; - dest += lnoffset; + src += lnoffset; *offset = 0; /* Copy the line into the user destination buffer */ diff --git a/fs/romfs/fs_romfsutil.c b/fs/romfs/fs_romfsutil.c index 145f349bc641bda9bfe5590d6b38289cec06cc05..b796a3b0180eda028e0e949ca9825e34f83204f0 100644 --- a/fs/romfs/fs_romfsutil.c +++ b/fs/romfs/fs_romfsutil.c @@ -64,7 +64,7 @@ /**************************************************************************** * Name: romfs_swap32 * - * Desciption: + * Description: * Convert the 32-bit big endian value to little endian * ****************************************************************************/ @@ -80,7 +80,7 @@ static inline uint32_t romfs_swap32(uint32_t value) /**************************************************************************** * Name: romfs_devread32 * - * Desciption: + * Description: * Read the big-endian 32-bit value from the mount device buffer * * Assumption: @@ -105,7 +105,7 @@ static uint32_t romfs_devread32(struct romfs_mountpt_s *rm, int ndx) /**************************************************************************** * Name: romfs_checkentry * - * Desciption: + * Description: * Check if the entry at offset is a directory or file path segment * ****************************************************************************/ @@ -181,7 +181,7 @@ static inline int romfs_checkentry(struct romfs_mountpt_s *rm, /**************************************************************************** * Name: romfs_devcacheread * - * Desciption: + * Description: * Read the specified sector for specified offset into the sector cache. * Return the index into the sector corresponding to the offset * @@ -234,7 +234,7 @@ int16_t romfs_devcacheread(struct romfs_mountpt_s *rm, uint32_t offset) /**************************************************************************** * Name: romfs_followhardlinks * - * Desciption: + * Description: * Given the offset to a file header, check if the file is a hardlink. * If so, traverse the hard links until the terminal, non-linked header * so found and return that offset. @@ -280,7 +280,7 @@ static int romfs_followhardlinks(struct romfs_mountpt_s *rm, uint32_t offset, /**************************************************************************** * Name: romfs_searchdir * - * Desciption: + * Description: * This is part of the romfs_finddirentry log. Search the directory * beginning at dirinfo->fr_firstoffset for entryname. * @@ -382,7 +382,7 @@ void romfs_semgive(struct romfs_mountpt_s *rm) /**************************************************************************** * Name: romfs_hwread * - * Desciption: Read the specified sector into the sector buffer + * Description: Read the specified sector into the sector buffer * ****************************************************************************/ @@ -432,7 +432,7 @@ int romfs_hwread(struct romfs_mountpt_s *rm, uint8_t *buffer, uint32_t sector, /**************************************************************************** * Name: romfs_filecacheread * - * Desciption: + * Description: * Read the specified sector into the sector cache * ****************************************************************************/ @@ -488,7 +488,7 @@ int romfs_filecacheread(struct romfs_mountpt_s *rm, struct romfs_file_s *rf, /**************************************************************************** * Name: romfs_hwconfigure * - * Desciption: + * Description: * This function is called as part of the ROMFS mount operation It * configures the ROMFS filestem for use on this block driver. This includes * the accounting for the geometry of the device, setting up any XIP modes @@ -561,7 +561,7 @@ int romfs_hwconfigure(struct romfs_mountpt_s *rm) /**************************************************************************** * Name: romfs_fsconfigure * - * Desciption: + * Description: * This function is called as part of the ROMFS mount operation It * sets up the mount structure to include configuration information contained * in the ROMFS header. This is the place where we actually determine if @@ -609,7 +609,7 @@ int romfs_fsconfigure(struct romfs_mountpt_s *rm) /**************************************************************************** * Name: romfs_fileconfigure * - * Desciption: + * Description: * This function is called as part of the ROMFS file open operation It * sets up the file structure to handle buffer appropriately, depending * upon XIP mode or not. @@ -650,7 +650,7 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf) /**************************************************************************** * Name: romfs_checkmount * - * Desciption: Check if the mountpoint is still valid. + * Description: Check if the mountpoint is still valid. * * The caller should hold the mountpoint semaphore * @@ -694,7 +694,7 @@ int romfs_checkmount(struct romfs_mountpt_s *rm) /**************************************************************************** * Name: romfs_finddirentry * - * Desciption: + * Description: * Given a path to something that may or may not be in the file system, * return the directory entry of the item. * @@ -793,7 +793,7 @@ int romfs_finddirentry(struct romfs_mountpt_s *rm, /**************************************************************************** * Name: romfs_parsedirentry * - * Desciption: + * Description: * Return the directory entry at this offset. If rf is NULL, then the * mount device resources are used. Otherwise, file resources are used. * @@ -847,7 +847,7 @@ int romfs_parsedirentry(struct romfs_mountpt_s *rm, uint32_t offset, /**************************************************************************** * Name: romfs_parsefilename * - * Desciption: + * Description: * Return the filename from directory entry at this offset * ****************************************************************************/ @@ -914,7 +914,7 @@ int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset, /**************************************************************************** * Name: romfs_datastart * - * Desciption: + * Description: * Given the offset to a file header, return the offset to the start of * the file data * diff --git a/fs/semaphore/sem_close.c b/fs/semaphore/sem_close.c index ffe687bec86b01252298311f76c1f7c5f887f67b..bd5ab9920519b7a4a69bc2ed91811e14aee4fefc 100644 --- a/fs/semaphore/sem_close.c +++ b/fs/semaphore/sem_close.c @@ -71,7 +71,7 @@ * Parameters: * sem - semaphore descriptor * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if unsuccessful. * * Assumptions: diff --git a/fs/semaphore/sem_open.c b/fs/semaphore/sem_open.c index 4bc91daeb0a4067f4e10c462d8ff1985e5765a72..c09f962798e53f8dcd05a0fc7dc70f34f173fd75 100644 --- a/fs/semaphore/sem_open.c +++ b/fs/semaphore/sem_open.c @@ -93,7 +93,7 @@ * initial values of the semaphore must be less than or equal to * SEM_VALUE_MAX. * - * Return Value: + * Returned Value: * A pointer to sem_t or SEM_FAILED if unsuccessful. * * Assumptions: diff --git a/fs/semaphore/sem_unlink.c b/fs/semaphore/sem_unlink.c index ca73a800418ad55aa1733d7bcf3ccd7016b3198f..647e3cba5c8ca76434d8153f6faffa5cb2af33a8 100644 --- a/fs/semaphore/sem_unlink.c +++ b/fs/semaphore/sem_unlink.c @@ -70,7 +70,7 @@ * Parameters: * name - Semaphore name * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if unsuccessful. * * Assumptions: diff --git a/fs/smartfs/smartfs_utils.c b/fs/smartfs/smartfs_utils.c index da37b922124b7c3648c7cba15d61f2d4ca8b79af..5071030c41950239ba4c040911a438900ff394c2 100644 --- a/fs/smartfs/smartfs_utils.c +++ b/fs/smartfs/smartfs_utils.c @@ -190,7 +190,7 @@ void smartfs_wrle32(uint8_t *dest, uint32_t val) /**************************************************************************** * Name: smartfs_mount * - * Desciption: This function is called only when the mountpoint is first + * Description: This function is called only when the mountpoint is first * established. It initializes the mountpoint structure and verifies * that a valid SMART filesystem is provided by the block driver. * @@ -334,7 +334,7 @@ errout: /**************************************************************************** * Name: smartfs_unmount * - * Desciption: This function is called only when the mountpoint is being + * Description: This function is called only when the mountpoint is being * unbound. If we are serving multiple directories, then we have to * remove ourselves from the mount linked list, and potentially free * the shared buffers. @@ -1825,6 +1825,7 @@ int smartfs_shrinkfile(FAR struct smartfs_mountpt_s *fs, { dest = (FAR uint8_t *)&sf->buffer; destsize = fs->fs_llformat.availbytes; + } else { offset = sizeof(struct smartfs_chain_header_s) + length; @@ -2072,7 +2073,7 @@ int smartfs_extendfile(FAR struct smartfs_mountpt_s *fs, ret = OK; errout_with_buffer: -#ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER +#ifndef CONFIG_SMARTFS_USE_SECTOR_BUFFER /* Release the allocated buffer */ kmm_free(buffer); diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c index 0c61c2e7a0c79caaff46d912ccaf870ddabe361a..27bd733e6e4ebfd3435cb88df602a66687e3fe2a 100644 --- a/fs/unionfs/fs_unionfs.c +++ b/fs/unionfs/fs_unionfs.c @@ -2617,7 +2617,7 @@ errout_with_search: * file system appear a some path below the unionfs mountpoint, * mountpt - The full path to the mountpoint for the union file system * - * Returned value: + * Returned Value: * Zero (OK) is returned if the union file system was correctly created and * mounted. On any failure, a negated error value will be returned to * indicate the nature of the failure. diff --git a/fs/userfs/fs_userfs.c b/fs/userfs/fs_userfs.c index bf91d58c1ec26d02afb0f07f3aaf22935d566fb8..3cb7a10b21e4a1f136282bd615b01f5c13b109fb 100644 --- a/fs/userfs/fs_userfs.c +++ b/fs/userfs/fs_userfs.c @@ -944,7 +944,7 @@ static int userfs_truncate(FAR struct file *filep, off_t length) /* Construct and send the request to the server */ req = (FAR struct userfs_truncate_request_s *)priv->iobuffer; - req->req = USERFS_REQ_FSTAT; + req->req = USERFS_REQ_TRUNCATE; req->openinfo = filep->f_priv; req->length = length; @@ -986,7 +986,6 @@ static int userfs_truncate(FAR struct file *filep, off_t length) /* Return the result of truncate operation */ - DEBUGASSERT(buf != NULL); return resp->ret; } diff --git a/fs/vfs/fs_fstatfs.c b/fs/vfs/fs_fstatfs.c index 80c0d1d7dd3fbbacc9506597c88d4610dc1591d0..7e4ddb3879c7b509b3da78b753d3c9f68d7a7ad6 100644 --- a/fs/vfs/fs_fstatfs.c +++ b/fs/vfs/fs_fstatfs.c @@ -54,7 +54,8 @@ /**************************************************************************** * Name: fstatfs * - * Return: Zero on success; -1 on failure with errno set: + * Returned Value: + * Zero on success; -1 on failure with errno set: * * EACCES Search permission is denied for one of the directories in the * path prefix of path. diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index a68dc43ce5c0e17116c04ca4a6b0cc1839751325..3127647869e60b166430c5a2e1c1dd77bffd5587 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -68,7 +68,7 @@ * req The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * Returns a non-negative number on success; A negated errno value is * returned on any failure (see comments ioctl() for a list of appropriate * errno values). @@ -114,7 +114,7 @@ int file_ioctl(FAR struct file *filep, int req, unsigned long arg) * req The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * -1 on failure with errno set properly: * diff --git a/fs/vfs/fs_lseek.c b/fs/vfs/fs_lseek.c index 6827d931d10a53a905d5e9b02de98b92653efd83..fcdbb85664b112eeafe0d3617c8b5d9fe663c763 100644 --- a/fs/vfs/fs_lseek.c +++ b/fs/vfs/fs_lseek.c @@ -65,7 +65,7 @@ * offset Defines the offset to position to * whence Defines how to use offset * - * Return: + * Returned Value: * The resulting offset on success. A negated errno value is returned on * any failure (see lseek comments). * @@ -146,7 +146,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence) * offset Defines the offset to position to * whence Defines how to use offset * - * Return: + * Returned Value: * The resulting offset on success. -1 on failure withi errno set properly: * * EBADF fd is not an open file descriptor. diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 825f8d16d850f35c8c8ff87cce51cc34f662a7f9..d6b32974b4fc7c6858018238c5efc9b8f35a2510 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -357,14 +357,14 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup) * occurred for any of the file descriptors, then poll() blocks until * one of the events occurs. * - * Inputs: + * Input Parameters: * fds - List of structures describing file descriptors to be monitored * nfds - The number of entries in the list * timeout - Specifies an upper limit on the time for which poll() will * block in milliseconds. A negative value of timeout means an infinite * timeout. * - * Return: + * Returned Value: * On success, the number of structures that have non-zero revents fields. * A value of 0 indicates that the call timed out and no file descriptors * were ready. On error, -1 is returned, and errno is set appropriately: diff --git a/fs/vfs/fs_pread.c b/fs/vfs/fs_pread.c index 782c7448fbde3bf9289630ae67d0bdb49604293a..9c7eb79461e928b1c527cae3f23910824c3b23e3 100644 --- a/fs/vfs/fs_pread.c +++ b/fs/vfs/fs_pread.c @@ -129,7 +129,7 @@ ssize_t file_pread(FAR struct file *filep, FAR void *buf, size_t nbytes, * nbytes The maximum size of the user-provided buffer * offset The file offset * - * Return: + * Returned Value: * The positive non-zero number of bytes read on success, 0 on if an * end-of-file condition, or -1 on failure with errno set appropriately. * See read() return values diff --git a/fs/vfs/fs_pwrite.c b/fs/vfs/fs_pwrite.c index 1a67d915f87fa274bbfcf198933231d525c0f61b..698b6d9eb86a84baad3e82849ee778201c02585b 100644 --- a/fs/vfs/fs_pwrite.c +++ b/fs/vfs/fs_pwrite.c @@ -126,7 +126,7 @@ ssize_t file_pwrite(FAR struct file *filep, FAR const void *buf, * buf Data to write * nbytes Length of data to write * - * Return: + * Returned Value: * The positive non-zero number of bytes read on success, 0 on if an * end-of-file condition, or -1 on failure with errno set appropriately. * See write() return values diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index b3ba38bf42cefe5117e0408fc3233074e3eeec63..e7fb11cc4f7393c60be259037d2fc7b4043bd8c7 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -84,7 +84,7 @@ * is more wasteful of resources and poll() is the recommended API to be * used. * - * Input parameters: + * Input Parameters: * nfds - the maximum fd number (+1) of any descriptor in any of the * three sets. * readfds - the set of descriptions to monitor for read-ready events @@ -93,7 +93,7 @@ * timeout - Return at this time if none of these events of interest * occur. * - * Return: + * Returned Value: * 0: Timer expired * >0: The number of bits set in the three sets of descriptors * -1: An error occurred (errno will be set appropriately) diff --git a/fs/vfs/fs_sendfile.c b/fs/vfs/fs_sendfile.c index a71dbcdf9bb80a1677acd7c1f4689d5b3830ebae..b1ef4ffb2ad33d86e5520db30fa3ea83cd898715 100644 --- a/fs/vfs/fs_sendfile.c +++ b/fs/vfs/fs_sendfile.c @@ -74,7 +74,7 @@ * different semantics and prototypes. sendfile() should not be used * in portable programs. * - * Input Parmeters: + * Input Parameters: * infd - A file (or socket) descriptor opened for reading * outfd - A descriptor opened for writing. * offset - If 'offset' is not NULL, then it points to a variable diff --git a/fs/vfs/fs_statfs.c b/fs/vfs/fs_statfs.c index 0f33c10aba34aec39e42356cf625ee6806d1cee1..4a8f6af7e1f15280d927cd0faea47947ace8a660 100644 --- a/fs/vfs/fs_statfs.c +++ b/fs/vfs/fs_statfs.c @@ -70,7 +70,8 @@ static int statpseudofs(FAR struct inode *inode, FAR struct statfs *buf) /**************************************************************************** * Name: statfs * - * Return: Zero on success; -1 on failure with errno set: + * Returned Value: + * Zero on success; -1 on failure with errno set: * * EACCES Search permission is denied for one of the directories in the * path prefix of path. diff --git a/graphics/nxbe/nxbe.h b/graphics/nxbe/nxbe.h index 5b0743c0d809d344114f0db83aab467f89c9743d..dc9de89a9dc5e3614ceb7de8b7c74bbcec0d97b7 100644 --- a/graphics/nxbe/nxbe.h +++ b/graphics/nxbe/nxbe.h @@ -198,7 +198,7 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be); * Input Parameters: * wnd - The window to be closed (and deallocated) * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -208,7 +208,7 @@ void nxbe_closewindow(struct nxbe_window_s *wnd); /**************************************************************************** * Name: nxbe_setposition * - * Descripton: + * Description: * This function checks for intersections and redraws the display after * a change in the position of a window. * @@ -220,7 +220,7 @@ void nxbe_setposition(FAR struct nxbe_window_s *wnd, /**************************************************************************** * Name: nxbe_setsize * - * Descripton: + * Description: * This function checks for intersections and redraws the display after * a change in the size of a window. * @@ -261,7 +261,7 @@ void nxbe_lower(FAR struct nxbe_window_s *wnd); * pos - The pixel location to be set * col - The color to use in the set * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -281,7 +281,7 @@ void nxbe_setpixel(FAR struct nxbe_window_s *wnd, * rect - The location to be filled * col - The color to use in the fill * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -302,7 +302,7 @@ void nxbe_fill(FAR struct nxbe_window_s *wnd, * rect - The location to be filled * col - The color to use in the fill * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -328,7 +328,7 @@ void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd, * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -349,7 +349,7 @@ void nxbe_getrectangle(FAR struct nxbe_window_s *wnd, * rect - Describes the rectangular region to move * offset - The offset to move the region * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -375,7 +375,7 @@ void nxbe_move(FAR struct nxbe_window_s *wnd, * may lie outside of the display. * stride - The width of the full source image in pixels. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_bitmap.c b/graphics/nxbe/nxbe_bitmap.c index 61a380ca1046336899448a138b0305e6435c2acc..772b08e46a00949c887c7063470d10f0ca3a8985 100644 --- a/graphics/nxbe/nxbe_bitmap.c +++ b/graphics/nxbe/nxbe_bitmap.c @@ -109,7 +109,7 @@ static void nxs_clipcopy(FAR struct nxbe_clipops_s *cops, * may lie outside of the display. * stride - The width of the full source image in pixels. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_clipper.c b/graphics/nxbe/nxbe_clipper.c index e73ba6c8530c9ba6140f191915b4665b92e00908..bf013f2e152a3decace3c7444ac93e63e4b0348d 100644 --- a/graphics/nxbe/nxbe_clipper.c +++ b/graphics/nxbe/nxbe_clipper.c @@ -156,7 +156,7 @@ static inline bool nxbe_poprectangle(struct nxbe_clipstack_s *stack, /**************************************************************************** * Name: nxbe_clipper * - * Descripton: + * Description: * Perform flexible clipping operations. Callbacks are executed for * each oscured and visible portions of the window. * @@ -265,7 +265,7 @@ void nxbe_clipper(FAR struct nxbe_window_s *wnd, /**************************************************************************** * Name: nxbe_clipnull * - * Descripton: + * Description: * The do-nothing clipping callback function * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_closewindow.c b/graphics/nxbe/nxbe_closewindow.c index 44520da22c182b4fc43985057b5ee6ca4fa316d5..cec2c5ae9e2bc096b375afb0cc0a004f815ea89f 100644 --- a/graphics/nxbe/nxbe_closewindow.c +++ b/graphics/nxbe/nxbe_closewindow.c @@ -61,7 +61,7 @@ * wnd - The window to be closed (and deallocated using the user-space * allocator) * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_fill.c b/graphics/nxbe/nxbe_fill.c index e2b45fbc96234ff23af85600f869da8748ed2a62..48567ccdcf2a5efaacbc6f44f06537fd9f803a07 100644 --- a/graphics/nxbe/nxbe_fill.c +++ b/graphics/nxbe/nxbe_fill.c @@ -99,7 +99,7 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops, * rect - The location to be filled * col - The color to use in the fill * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_filltrapezoid.c b/graphics/nxbe/nxbe_filltrapezoid.c index 1936a6c4d6297d943f35b50dfb9a895f4a07927d..51fde5728b033036c05e3713b7603ce7d764ae10 100644 --- a/graphics/nxbe/nxbe_filltrapezoid.c +++ b/graphics/nxbe/nxbe_filltrapezoid.c @@ -123,7 +123,7 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops, * rect - The location to be filled (in relative window coordinates) * col - The color to use in the fill * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_getrectangle.c b/graphics/nxbe/nxbe_getrectangle.c index 2e707a816cd16cffc3d50e0d68265952065eb209..72073537e663e57ff477f8aa81c16c5440298a37 100644 --- a/graphics/nxbe/nxbe_getrectangle.c +++ b/graphics/nxbe/nxbe_getrectangle.c @@ -76,7 +76,7 @@ struct nxbe_fill_s * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_move.c b/graphics/nxbe/nxbe_move.c index e2eee9f01bbf3ffcb2d779a724cfddf01a1fb1cd..747b4e5a764ff0b86d881598fefd8f85963f0a2d 100644 --- a/graphics/nxbe/nxbe_move.c +++ b/graphics/nxbe/nxbe_move.c @@ -197,7 +197,7 @@ static void nxbe_clipmovedest(FAR struct nxbe_clipops_s *cops, * rect - Describes the rectangular region to move * offset - The offset to move the region * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_redraw.c b/graphics/nxbe/nxbe_redraw.c index 397a0190603d54611639d8ff9ca34ffe7d91c739..bafd497a252d1aaf5e9afa9d9544853f506948f2 100644 --- a/graphics/nxbe/nxbe_redraw.c +++ b/graphics/nxbe/nxbe_redraw.c @@ -83,7 +83,7 @@ static void nxbe_clipredraw(FAR struct nxbe_clipops_s *cops, /**************************************************************************** * Name: nxbe_redraw * - * Descripton: + * Description: * Re-draw the visible portions of the rectangular region for the * specified window * diff --git a/graphics/nxbe/nxbe_redrawbelow.c b/graphics/nxbe/nxbe_redrawbelow.c index 97152670489b64065d5bdc35cdff739dd894f8c4..f51afc1f57ec7462501c1b074d58554044d9da74 100644 --- a/graphics/nxbe/nxbe_redrawbelow.c +++ b/graphics/nxbe/nxbe_redrawbelow.c @@ -51,7 +51,7 @@ /**************************************************************************** * Name: nxbe_redrawbelow * - * Descripton: + * Description: * Re-draw the visible portions of the rectangular region for all windows * below (and including) the specified window. This function is called * whenever a window is closed, moved, lowered or re-sized in order to diff --git a/graphics/nxbe/nxbe_setpixel.c b/graphics/nxbe/nxbe_setpixel.c index 574a4ee3deb2ef9ba6b89775cc262c273c0f2048..409b11c4423ad421b210c8ce209389b6312d1a87 100644 --- a/graphics/nxbe/nxbe_setpixel.c +++ b/graphics/nxbe/nxbe_setpixel.c @@ -99,7 +99,7 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops, * rect - The location to be filled * col - The color to use in the fill * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxbe/nxbe_setposition.c b/graphics/nxbe/nxbe_setposition.c index a40a01ebe7936b1cd19981be745c9a28be36188a..e5ee663ba4ddb1f48fee850429b32e8d31c13368 100644 --- a/graphics/nxbe/nxbe_setposition.c +++ b/graphics/nxbe/nxbe_setposition.c @@ -51,7 +51,7 @@ /**************************************************************************** * Name: nxbe_setposition * - * Descripton: + * Description: * This function checks for intersections and redraws the display after * a change in the position of a window. * diff --git a/graphics/nxbe/nxbe_setsize.c b/graphics/nxbe/nxbe_setsize.c index 3b522d38a4019ad54d5c8435b803f6717feb9f9b..c7f10642584d394bb22eecb1bfdb54482897c74d 100644 --- a/graphics/nxbe/nxbe_setsize.c +++ b/graphics/nxbe/nxbe_setsize.c @@ -51,7 +51,7 @@ /**************************************************************************** * Name: nxbe_setsize * - * Descripton: + * Description: * This function checks for intersections and redraws the display after * a change in the size of a window. * diff --git a/graphics/nxbe/nxbe_visible.c b/graphics/nxbe/nxbe_visible.c index bf22ffa0beb6d3d81922df487b974225345330c3..e39eef851222b48a545cd0bc9c356cfd781a1f2e 100644 --- a/graphics/nxbe/nxbe_visible.c +++ b/graphics/nxbe/nxbe_visible.c @@ -81,7 +81,7 @@ static void nxbe_clipvisible(FAR struct nxbe_clipops_s *cops, /**************************************************************************** * Name: nxbe_visible * - * Descripton: + * Description: * Return true if the point, pt, in window wnd is visible. pt is in * absolute screen coordinates * diff --git a/graphics/nxglib/fb/nxglib_copyrectangle.c b/graphics/nxglib/fb/nxglib_copyrectangle.c index 4b7270f1d06462b939951e75989cdaef0a3b99a0..a4e18cefda6cd01c91e00d530d500bc03707b233 100644 --- a/graphics/nxglib/fb/nxglib_copyrectangle.c +++ b/graphics/nxglib/fb/nxglib_copyrectangle.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: nxgl_copyrectangle_*bpp * - * Descripton: + * Description: * Copy a rectangular bitmap image into the specific position in the * framebuffer memory. * diff --git a/graphics/nxglib/fb/nxglib_fillrectangle.c b/graphics/nxglib/fb/nxglib_fillrectangle.c index 4fec88b60b41d3755a5c22de074ec667dda49f09..16fde377a1000b1a2db540dad85063d6e24a03fe 100644 --- a/graphics/nxglib/fb/nxglib_fillrectangle.c +++ b/graphics/nxglib/fb/nxglib_fillrectangle.c @@ -61,7 +61,7 @@ /**************************************************************************** * Name: nxgl_fillrectangle_*bpp * - * Descripton: + * Description: * Fill a rectangle region in the framebuffer memory with a fixed color * ****************************************************************************/ diff --git a/graphics/nxglib/fb/nxglib_filltrapezoid.c b/graphics/nxglib/fb/nxglib_filltrapezoid.c index dcf29faad4fb8c8ee3fceb2574d486200df18495..a66dbd6e21b4b77181b2ddb5a7dcc5ce2ed8e66d 100644 --- a/graphics/nxglib/fb/nxglib_filltrapezoid.c +++ b/graphics/nxglib/fb/nxglib_filltrapezoid.c @@ -63,7 +63,7 @@ /**************************************************************************** * Name: nxglib_filltrapezoid_*bpp * - * Descripton: + * Description: * Fill a trapezoidal region in the framebuffer memory with a fixed color. * Clip the trapezoid to lie within a boundng box. This is useful for * drawing complex shapes that can be broken into a set of trapezoids. diff --git a/graphics/nxglib/fb/nxglib_getrectangle.c b/graphics/nxglib/fb/nxglib_getrectangle.c index 280affae1a26b0f9a393f224f846e52cb2853b54..419c36048b38e93fcbd23833c7c6f76d19168acc 100644 --- a/graphics/nxglib/fb/nxglib_getrectangle.c +++ b/graphics/nxglib/fb/nxglib_getrectangle.c @@ -105,7 +105,7 @@ static inline void nxgl_lowresmemcpy(FAR uint8_t *dline, FAR const uint8_t *slin /**************************************************************************** * Name: nxgl_getrectangle_*bpp * - * Descripton: + * Description: * Fetch a rectangular region from framebuffer memory. The source is * expressed as a rectangle. * diff --git a/graphics/nxglib/fb/nxglib_moverectangle.c b/graphics/nxglib/fb/nxglib_moverectangle.c index a24fc9f6f3291c52a706d46b9a39bd49bf021f29..178f6070ccdd0a4ce7182e4353fe917736aa9aa7 100644 --- a/graphics/nxglib/fb/nxglib_moverectangle.c +++ b/graphics/nxglib/fb/nxglib_moverectangle.c @@ -105,7 +105,7 @@ static inline void nxgl_lowresmemcpy(FAR uint8_t *dline, FAR const uint8_t *slin /**************************************************************************** * Name: nxgl_moverectangle_*bpp * - * Descripton: + * Description: * Move a rectangular region from location to another in the * framebuffer memory. The source is expressed as a rectangle; the * destination position is expressed as a point corresponding to the diff --git a/graphics/nxglib/fb/nxglib_setpixel.c b/graphics/nxglib/fb/nxglib_setpixel.c index 0cde90ff1ab9d41e1bdf8919f5ef9f3c5684d24c..fd240469fb7790095a2a567ae6118b2dd402b49d 100644 --- a/graphics/nxglib/fb/nxglib_setpixel.c +++ b/graphics/nxglib/fb/nxglib_setpixel.c @@ -61,7 +61,7 @@ /**************************************************************************** * Name: nxgl_setpixel_*bpp * - * Descripton: + * Description: * Draw a single pixel in frambuffer memory at the given position and with * the given color. This is equivalent to nxgl_fillrectangle_*bpp() with * a 1x1 rectangle but is more efficient. diff --git a/graphics/nxglib/lcd/nxglib_copyrectangle.c b/graphics/nxglib/lcd/nxglib_copyrectangle.c index a1fc20e8706b44134bcac5c5b25c776d70bfda18..69b973d7f7e3f1981388c0aced1729db275ce9cf 100644 --- a/graphics/nxglib/lcd/nxglib_copyrectangle.c +++ b/graphics/nxglib/lcd/nxglib_copyrectangle.c @@ -55,7 +55,7 @@ /**************************************************************************** * Name: nxgl_copyrectangle_*bpp * - * Descripton: + * Description: * Copy a rectangular bitmap image into the specific position in the * framebuffer memory. * diff --git a/graphics/nxglib/lcd/nxglib_fillrectangle.c b/graphics/nxglib/lcd/nxglib_fillrectangle.c index e3c263bff2609386a348178e434914cefdda76fc..bcef2c15028fd6d4e476e51cd95c0340288e385e 100644 --- a/graphics/nxglib/lcd/nxglib_fillrectangle.c +++ b/graphics/nxglib/lcd/nxglib_fillrectangle.c @@ -63,7 +63,7 @@ /**************************************************************************** * Name: nxgl_fillrectangle_*bpp * - * Descripton: + * Description: * Fill a rectangle region in the LCD memory with a fixed color * ****************************************************************************/ diff --git a/graphics/nxglib/lcd/nxglib_filltrapezoid.c b/graphics/nxglib/lcd/nxglib_filltrapezoid.c index 5960384ab104a21f2f65523889d55412e04a77b7..5da7418b2bac89a0170a27f4c40a1d32aeb7cf61 100644 --- a/graphics/nxglib/lcd/nxglib_filltrapezoid.c +++ b/graphics/nxglib/lcd/nxglib_filltrapezoid.c @@ -63,7 +63,7 @@ /**************************************************************************** * Name: nxglib_filltrapezoid_*bpp * - * Descripton: + * Description: * Fill a trapezoidal region in the LCD memory with a fixed color. * Clip the trapezoid to lie within a boundng box. This is useful for * drawing complex shapes that can be broken into a set of trapezoids. diff --git a/graphics/nxglib/lcd/nxglib_getrectangle.c b/graphics/nxglib/lcd/nxglib_getrectangle.c index adf6a90047c993e028f1982f7c12716293e1196a..129a7dc5ed1007b2aff75f2cb61e866ad2d1e5c4 100644 --- a/graphics/nxglib/lcd/nxglib_getrectangle.c +++ b/graphics/nxglib/lcd/nxglib_getrectangle.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: nxgl_moverectangle_*bpp * - * Descripton: + * Description: * Fetch a rectangular region from LCD GRAM memory. The source is * expressed as a rectangle. * diff --git a/graphics/nxglib/lcd/nxglib_moverectangle.c b/graphics/nxglib/lcd/nxglib_moverectangle.c index 85b388963aea78e3d95cdb5ab088e5ce5549f7d2..1956ff17d3bd8fcb7453f254f91908c24a1843a1 100644 --- a/graphics/nxglib/lcd/nxglib_moverectangle.c +++ b/graphics/nxglib/lcd/nxglib_moverectangle.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: nxgl_moverectangle_*bpp * - * Descripton: + * Description: * Move a rectangular region from location to another in the * LCD memory. The source is expressed as a rectangle; the * destination position is expressed as a point corresponding to the diff --git a/graphics/nxglib/lcd/nxglib_setpixel.c b/graphics/nxglib/lcd/nxglib_setpixel.c index cb57d048ab4badf97948483608390c642457c95a..402d4f64dae2dabc739b4bc34db37d5d81d7b4c7 100644 --- a/graphics/nxglib/lcd/nxglib_setpixel.c +++ b/graphics/nxglib/lcd/nxglib_setpixel.c @@ -62,7 +62,7 @@ /**************************************************************************** * Name: nxgl_setpixel_*bpp * - * Descripton: + * Description: * Draw a single pixel in LCD memory at the given position and with the * given color. This is equivalent to nxgl_fillrectangle_*bpp() with a 1x1 * rectangle but is more efficient. diff --git a/graphics/nxmu/nx_start.c b/graphics/nxmu/nx_start.c index cfa39cc5236148cf93d991d4148b5b42e282c74f..757b418d7e9993a75c4ad63a82b2dcea6fb089a3 100644 --- a/graphics/nxmu/nx_start.c +++ b/graphics/nxmu/nx_start.c @@ -190,11 +190,9 @@ int nx_start(void) CONFIG_NXSTART_SERVERSTACK, nx_server, NULL); if (server < 0) { - int errcode = errno; - DEBUGASSERT(errcode > 0); - - gerr("ERROR: Failed to create nx_server kernel thread: %d\n", errcode); - return -errcode; + gerr("ERROR: Failed to create nx_server kernel thread: %d\n", + (int)server); + return (int)server; } g_nxserver_started = true; diff --git a/graphics/nxmu/nxfe.h b/graphics/nxmu/nxfe.h index 62ae235fedefbc53fdf2e8aa833db4e6f6545419..c1e02b769daaf82c9a336590ae9a0eadf96c8dce 100644 --- a/graphics/nxmu/nxfe.h +++ b/graphics/nxmu/nxfe.h @@ -106,7 +106,7 @@ extern "C" * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -125,7 +125,7 @@ int nxmu_sendclient(FAR struct nxfe_conn_s *conn, * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -143,7 +143,7 @@ int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, * be - The back-end status structure * wnd - The pre-allocated window structure to be initialized [IN/OUT] * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -164,7 +164,7 @@ void nxmu_openwindow(FAR struct nxbe_state_s *be, * cb - Callbacks used to process window events * arg - User provided argument (see nx_openwindow, nx_constructwindow) * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -184,7 +184,7 @@ void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn, * Input Parameters: * fe - The front-end state structure * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_openwindow.c b/graphics/nxmu/nxmu_openwindow.c index 01ed612a5b4de640785ac955d8f4d512acb5b49e..0d05ac3700dccbe27de25bb764f0ef871b82c760 100644 --- a/graphics/nxmu/nxmu_openwindow.c +++ b/graphics/nxmu/nxmu_openwindow.c @@ -76,7 +76,7 @@ * be - The back-end status structure * wnd - The pre-allocated window structure to be initialized [IN/OUT] * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_redrawreq.c b/graphics/nxmu/nxmu_redrawreq.c index 325fb1e72b27decf768ab2c0216d371fa2d2caf8..2214174b3e48c1d2074ee4cb88c3c70a6518b3d4 100644 --- a/graphics/nxmu/nxmu_redrawreq.c +++ b/graphics/nxmu/nxmu_redrawreq.c @@ -73,7 +73,7 @@ /**************************************************************************** * Name: nxfe_redrawreq * - * Descripton: + * Description: * Request the client that has this window to redraw the rectangular region. * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_releasebkgd.c b/graphics/nxmu/nxmu_releasebkgd.c index 7f8d2935076f368b2a862b8495c5a0ad4b320e2a..35c65930729c6b680916ede5f5a605a0a874514e 100644 --- a/graphics/nxmu/nxmu_releasebkgd.c +++ b/graphics/nxmu/nxmu_releasebkgd.c @@ -79,7 +79,7 @@ * Input Parameters: * fe - The front-end state structure * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_reportposition.c b/graphics/nxmu/nxmu_reportposition.c index 757873ac1eee3e81d34aff8f199b0664f7da6cb3..e6166c49a388c0d57ee85a0914d5e436337fef31 100644 --- a/graphics/nxmu/nxmu_reportposition.c +++ b/graphics/nxmu/nxmu_reportposition.c @@ -73,7 +73,7 @@ /**************************************************************************** * Name: nxfe_reportposition * - * Descripton: + * Description: * Report the new size/position of the window. * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_requestbkgd.c b/graphics/nxmu/nxmu_requestbkgd.c index 23f7748fc30321218d8e92ffdfc950cf2017e84d..fa12750feefae5bd23f70a4887b1ba2be93e3540 100644 --- a/graphics/nxmu/nxmu_requestbkgd.c +++ b/graphics/nxmu/nxmu_requestbkgd.c @@ -39,32 +39,13 @@ #include +#include #include #include #include #include "nxfe.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -82,7 +63,7 @@ * cb - Callbacks used to process window events * arg - User provided argument (see nx_openwindow, nx_constructwindow) * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -92,12 +73,7 @@ void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn, FAR const struct nx_callback_s *cb, FAR void *arg) { -#ifdef CONFIG_DEBUG_FEATURES - if (!conn || !be || !cb) - { - errno = EINVAL; - } -#endif + DEBUGASSERT(conn != NULL || be != NULL || cb != NULL); /* Set the client's callback vtable and and replace the server * connection with the clients connection. diff --git a/graphics/nxmu/nxmu_sendclient.c b/graphics/nxmu/nxmu_sendclient.c index a26a6d3e96442a6d3ed7f365422be67e7f2a7ffc..21588fbbd254eb122c02be5fd0a477edcedf893a 100644 --- a/graphics/nxmu/nxmu_sendclient.c +++ b/graphics/nxmu/nxmu_sendclient.c @@ -62,7 +62,7 @@ * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_sendclientwindow.c b/graphics/nxmu/nxmu_sendclientwindow.c index e8ce5276a17f5ee9fa08c0f5577cb69cc5b49d48..32d42a3d48e679265688fd1c89944d4885cac55a 100644 --- a/graphics/nxmu/nxmu_sendclientwindow.c +++ b/graphics/nxmu/nxmu_sendclientwindow.c @@ -80,7 +80,7 @@ * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/graphics/nxmu/nxmu_server.c b/graphics/nxmu/nxmu_server.c index 79cb140a3e5732319c6215b634a6e3204d20f5c3..5593c57dd6587b7daecd26c6e58828cc63ef5562 100644 --- a/graphics/nxmu/nxmu_server.c +++ b/graphics/nxmu/nxmu_server.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -53,22 +54,6 @@ #include "nxfe.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -190,7 +175,7 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev, if (ret < 0) { gerr("ERROR: nxbe_configure failed: %d\n", -ret); - errno = -ret; + set_errno(-ret); return ERROR; } @@ -199,7 +184,7 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev, if (ret < 0) { gerr("ERROR: nxbe_colormap failed: %d\n", -ret); - errno = -ret; + set_errno(-ret); return ERROR; } #endif /* CONFIG_FB_CMAP */ @@ -285,7 +270,7 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev, * mqname - The name for the server incoming message queue * dev - Vtable "object" of the framebuffer/LCD "driver" to use * - * Return: + * Returned Value: * This function usually does not return. If it does return, it will * return ERROR and errno will be set appropriately. * @@ -301,15 +286,7 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) /* Initialization *********************************************************/ - /* Sanity checking */ - -#ifdef CONFIG_DEBUG_FEATURES - if (!mqname || !dev) - { - errno = EINVAL; - return ERROR; - } -#endif + DEBUGASSERT(mqname != NULL || dev != NULL); /* Initialize and configure the server */ diff --git a/graphics/nxterm/nx_register.c b/graphics/nxterm/nx_register.c index 3da6fd8a658fa8a1a5f20e630557d5dcbc4c4fa7..8c1e0a8018f8b3a506903bcd93f6badee76c36ff 100644 --- a/graphics/nxterm/nx_register.c +++ b/graphics/nxterm/nx_register.c @@ -90,7 +90,7 @@ static const struct nxterm_operations_s g_nxops = * rect - The location to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -114,7 +114,7 @@ static int nxterm_fill(FAR struct nxterm_state_s *priv, * offset - The offset to move the region. The rectangular region will be * moved so that the origin is translated by this amount. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -146,7 +146,7 @@ static int nxterm_move(FAR struct nxterm_state_s *priv, * may lie outside of the display. * stride - The width of the full source image in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -177,7 +177,7 @@ static int nxterm_bitmap(FAR struct nxterm_state_s *priv, * wndo - Describes the window and font to be used * minor - The device minor number * - * Return: + * Returned Value: * A non-NULL handle is returned on success. * ****************************************************************************/ diff --git a/graphics/nxterm/nxtk_register.c b/graphics/nxterm/nxtk_register.c index ae4e861246441091a71e77abafefc031544fed63..d89f31cd3f5d0921bd67d75285b47f78006b06ee 100644 --- a/graphics/nxterm/nxtk_register.c +++ b/graphics/nxterm/nxtk_register.c @@ -90,7 +90,7 @@ static const struct nxterm_operations_s g_nxtkops = * rect - The location to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -114,7 +114,7 @@ static int nxtkcon_fill(FAR struct nxterm_state_s *priv, * offset - The offset to move the region. The rectangular region will be * moved so that the origin is translated by this amount. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -146,7 +146,7 @@ static int nxtkcon_move(FAR struct nxterm_state_s *priv, * may lie outside of the display. * stride - The width of the full source image in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -177,7 +177,7 @@ static int nxtkcon_bitmap(FAR struct nxterm_state_s *priv, * wndo - Describes the window and font to be used * minor - The device minor number * - * Return: + * Returned Value: * A non-NULL handle is returned on success. * ****************************************************************************/ diff --git a/graphics/nxterm/nxtool_register.c b/graphics/nxterm/nxtool_register.c index 2a9de5d5596f9ef10dfc26215221cceb9b6fc3db..04849692f345829e17fe08d230c56e00ad9b6695 100644 --- a/graphics/nxterm/nxtool_register.c +++ b/graphics/nxterm/nxtool_register.c @@ -90,7 +90,7 @@ static const struct nxterm_operations_s g_nxtoolops = * rect - The location to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -114,7 +114,7 @@ static int nxtool_fill(FAR struct nxterm_state_s *priv, * offset - The offset to move the region. The rectangular region will be * moved so that the origin is translated by this amount. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -146,7 +146,7 @@ static int nxtool_move(FAR struct nxterm_state_s *priv, * may lie outside of the display. * stride - The width of the full source image in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -179,7 +179,7 @@ static int nxtool_bitmap(FAR struct nxterm_state_s *priv, * wndo - Describes the window and font to be used * minor - The device minor number * - * Return: + * Returned Value: * A non-NULL handle is returned on success. * ****************************************************************************/ diff --git a/graphics/vnc/server/vnc_fbdev.c b/graphics/vnc/server/vnc_fbdev.c index e5995996547a4748f9392382c225a18a08ffe86f..47badee8f0570dcb5ede0f7b6cd54d24564f7b78 100644 --- a/graphics/vnc/server/vnc_fbdev.c +++ b/graphics/vnc/server/vnc_fbdev.c @@ -412,7 +412,7 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, * Description: * Start the VNC server. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -470,7 +470,7 @@ static int vnc_start_server(int display) * Description: * Wait for the server to be started. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -525,7 +525,7 @@ static inline int vnc_wait_start(int display) * Wait for the server to be connected to the VNC client. We can do * nothing until that connection is established. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -612,7 +612,7 @@ static inline int vnc_wait_connect(int display) * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -746,7 +746,7 @@ int vnc_fbinitialize(int display, vnc_kbdout_t kbdout, * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/graphics/vnc/server/vnc_negotiate.c b/graphics/vnc/server/vnc_negotiate.c index 31ee14322ff2f6cdab02a82b7af893336792f460..d9ee9c42e678d94b71e8b2fa32b65afe0fd2f811 100644 --- a/graphics/vnc/server/vnc_negotiate.c +++ b/graphics/vnc/server/vnc_negotiate.c @@ -115,7 +115,6 @@ int vnc_negotiate(FAR struct vnc_session_s *session) ssize_t nsent; ssize_t nrecvd; size_t len; - int errcode; #ifdef CONFIG_NET_SOCKOPTS struct timeval tv; @@ -158,10 +157,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) nrecvd = psock_recv(&session->connect, session->inbuf, len, 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive protocol confirmation failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive protocol confirmation failed: %d\n", (int)nrecvd); + return (int)nrecvd; } else if (nrecvd == 0) { @@ -226,10 +223,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) sizeof(struct rfb_selected_sectype_s), 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive SecurityType failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive SecurityType failed: %d\n", (int)nrecvd); + return (int)nrecvd; } else if (nrecvd == 0) { @@ -309,10 +304,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) sizeof(struct rfb_clientinit_s), 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive ClientInit failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive ClientInit failed: %d\n", (int)nrecvd); + return (int)nrecvd; } else if (nrecvd == 0) { @@ -383,10 +376,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) sizeof(struct rfb_setpixelformat_s), 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive SetPixelFormat failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive SetPixelFormat failed: %d\n", (int)nrecvd); + return (int)nrecvd; } else if (nrecvd == 0) { @@ -430,10 +421,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session) CONFIG_VNCSERVER_INBUFFER_SIZE, 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive SetEncodings failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive SetEncodings failed: %d\n", (int)nrecvd); + return (int)nrecvd; } else if (nrecvd == 0) { diff --git a/graphics/vnc/server/vnc_receiver.c b/graphics/vnc/server/vnc_receiver.c index 36d04428abc48a8a8d9cdad86b81daf5a817b1d2..34d07570673e97d159701cfec3f4fa43e72f99e6 100644 --- a/graphics/vnc/server/vnc_receiver.c +++ b/graphics/vnc/server/vnc_receiver.c @@ -92,7 +92,6 @@ int vnc_read_remainder(FAR struct vnc_session_s *session, size_t msglen, { ssize_t nrecvd; size_t ntotal; - int errcode; /* Loop until the rest of the message is recieved. */ @@ -104,10 +103,8 @@ int vnc_read_remainder(FAR struct vnc_session_s *session, size_t msglen, msglen - ntotal, 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive message failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive message failed: %d\n", (int)nrecvd); + return (int)nrecvd; } } @@ -138,7 +135,6 @@ int vnc_receiver(FAR struct vnc_session_s *session) struct timeval tv; #endif ssize_t nrecvd; - int errcode; int ret; DEBUGASSERT(session); @@ -155,10 +151,8 @@ int vnc_receiver(FAR struct vnc_session_s *session) &tv, sizeof(struct timeval)); if (ret < 0) { - errcode = get_errno(); - gerr("ERROR: Failed to disable receive timeout: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Failed to disable receive timeout: %d\n", ret); + return ret; } #endif @@ -174,10 +168,8 @@ int vnc_receiver(FAR struct vnc_session_s *session) nrecvd = psock_recv(&session->connect, session->inbuf, 1, 0); if (nrecvd < 0) { - errcode = get_errno(); - gerr("ERROR: Receive byte failed: %d\n", errcode); - DEBUGASSERT(errcode > 0); - return -errcode; + gerr("ERROR: Receive byte failed: %d\n", (int)nrecvd); + return (int)nrecvd; } /* A return value of zero means that the connection was gracefully @@ -186,7 +178,7 @@ int vnc_receiver(FAR struct vnc_session_s *session) else if (nrecvd == 0) { - gwarn("WARNING: Connection closed\n", errcode); + gwarn("WARNING: Connection closed\n"); return OK; } diff --git a/include/hex2bin.h b/include/hex2bin.h index 3217c54560eeda31e858f6286188dbc7ed885cb2..b1dc9ff8a4c540746a679e60ae0ecc984252c0fa 100644 --- a/include/hex2bin.h +++ b/include/hex2bin.h @@ -133,7 +133,7 @@ extern "C" * swap - Controls byte ordering. See enum hex2bin_swap_e for * description of the values. * - * Returned Value + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * failure. * @@ -146,7 +146,7 @@ int hex2bin(FAR struct lib_instream_s *instream, uint32_t endpaddr, enum hex2bin_swap_e swap); /**************************************************************************** - * Name hex2mem + * Name: hex2mem * * Description: * Read the Intel HEX ASCII data provided on the file descriptor 'fd' and @@ -163,7 +163,7 @@ int hex2bin(FAR struct lib_instream_s *instream, * swap - Controls byte ordering. See enum hex2bin_swap_e for * description of the values. * - * Returned Value + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * failure. * @@ -173,7 +173,7 @@ int hex2mem(int fd, uint32_t baseaddr, uint32_t endpaddr, enum hex2bin_swap_e swap); /**************************************************************************** - * Name fhex2mem + * Name: fhex2mem * * Description: * Read the Intel HEX ASCII data provided on the standard stream @@ -190,7 +190,7 @@ int hex2mem(int fd, uint32_t baseaddr, uint32_t endpaddr, * swap - Controls byte ordering. See enum hex2bin_swap_e for * description of the values. * - * Returned Value + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * failure. * @@ -208,7 +208,7 @@ int fhex2mem(FAR FILE *instream, uint32_t baseaddr, uint32_t endpaddr, * Input Parameters: * Standard task inputs * - * Returned Value + * Returned Value: * EXIT_SUCESS on success; EXIT_FAILURE on failure * ****************************************************************************/ @@ -226,7 +226,7 @@ int hex2bin_main(int argc, char **argv); * Input Parameters: * Standard task inputs * - * Returned Value + * Returned Value: * EXIT_SUCESS on success; EXIT_FAILURE on failure * ****************************************************************************/ diff --git a/include/nuttx/analog/adc.h b/include/nuttx/analog/adc.h index 524773e72906ca194b1316cb57f5d1eb9fd68082..7ce2577fe4ace396b2effdcd1e3816bac1eccc34 100644 --- a/include/nuttx/analog/adc.h +++ b/include/nuttx/analog/adc.h @@ -227,7 +227,7 @@ extern "C" * driver with the "upper half" ADC device and registers that device so that can * be used by application code. * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name all PWM drivers * as "/dev/adc", "/dev/adc1", etc. where the driver path differs only diff --git a/include/nuttx/analog/dac.h b/include/nuttx/analog/dac.h index 93f1282ef573762536e91d943045ebba04f41b9c..5f9fce131c25ee3953181f3d53b6fa61fae0fd76 100644 --- a/include/nuttx/analog/dac.h +++ b/include/nuttx/analog/dac.h @@ -190,7 +190,7 @@ int dac_register(FAR const char *path, FAR struct dac_dev_s *dev); * Input Parameters: * dev - An instance of the device-specific DAC interface * - * Return: + * Returned Value: * OK on success; a negated errno on failure. * ************************************************************************************/ diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 6bbdf758b45e5676ab885fd3820c426e036bfe53..b1266c0a2e008349fb954c3a00712f3c0fee86cd 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -247,7 +247,7 @@ void up_initial_state(FAR struct tcb_s *tcb); * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack_size: The requested stack size. At least this much * must be allocated. @@ -289,7 +289,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype); * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The * initial value of the stack pointer. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - stack: The new stack to be used. * - stack_size: The allocated stack size. @@ -324,7 +324,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size); * been removed from the stack. This will still be the initial value * of the stack pointer when the task is started. * - * Inputs: + * Input Parameters: * - tcb: The TCB of new task * - frame_size: The size of the stack frame to allocate. * @@ -344,7 +344,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size); * A task has been stopped. Free all stack related resources retained in * the defunct TCB. * - * Input Parmeters + * Input Parameters: * - dtcb: The TCB containing information about the stack to be released * - ttype: The thread type. This may be one of following (defined in * include/nuttx/sched.h): @@ -382,7 +382,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype); * logic. Interrupts will always be disabled when this * function is called. * - * Inputs: + * Input Parameters: * tcb: Refers to the tcb to be unblocked. This tcb is * in one of the waiting tasks lists. It must be moved to * the ready-to-run list and, if it is the highest priority @@ -404,7 +404,7 @@ void up_unblock_task(FAR struct tcb_s *tcb); * logic. Interrupts will always be disabled when this * function is called. * - * Inputs: + * Input Parameters: * tcb: Refers to a task in the ready-to-run list (normally * the task at the head of the list). It most be * stopped, its context saved and moved into one of the @@ -455,7 +455,7 @@ void up_release_pending(void); * logic. Interrupts will always be disabled when this * function is called. * - * Inputs: + * Input Parameters: * tcb: The TCB of the task that has been reprioritized * priority: The new task priority * @@ -601,12 +601,12 @@ void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) * function is the user-space, signal handler trampoline function. It is * called from up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * sighand - The address user-space signal handling function * signo, info, and ucontext - Standard arguments to be passed to the * signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via an architecture specific system call made by up_signal_handler() * (see below). However, this will look like a normal return by the @@ -628,12 +628,12 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, * must be provided by architecture-specific logic. It is called from * up_signal_dispatch() in user-mode. * - * Inputs: + * Input Parameters: * sighand - The address user-space signal handling function * signo, info, and ucontext - Standard arguments to be passed to the * signal handling function. * - * Return: + * Returned Value: * None. This function does not return in the normal sense. It returns * via an architecture specific system call. * @@ -1686,6 +1686,54 @@ int up_timer_start(FAR const struct timespec *ts); /* See prototype in include/nuttx/spinlock.h */ +/**************************************************************************** + * Name: up_fetchadd8, up_fetchadd16, and up_fetchadd32 + * + * Description: + * Perform an atomic fetch add operation on the provided 8-, 16-, or 32- + * bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of value to be incremented. + * value - The addend + * + * Returned Value: + * The incremented value (volatile!) + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_HAVE_FETCHADD +int32_t up_fetchadd32(FAR volatile int32_t *addr, int32_t value); +int16_t up_fetchadd16(FAR volatile int16_t *addr, int16_t value); +int8_t up_fetchadd8(FAR volatile int8_t *addr, int8_t value); +#endif + +/**************************************************************************** + * Name: up_fetchsub8 + * + * Description: + * Perform an atomic fetch subtract operation on the provided 8-, 16-, or + * 32-bit value. + * + * This function must be provided via the architecture-specific logic. + * + * Input Parameters: + * addr - The address of value to be decremented. + * value - The subtrahend + * + * Returned Value: + * The decremented value (volatile!) + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_HAVE_FETCHADD +int32_t up_fetchsub32(FAR volatile int32_t *addr, int32_t value); +int16_t up_fetchsub16(FAR volatile int16_t *addr, int16_t value); +int8_t up_fetchsub8(FAR volatile int8_t *addr, int8_t value); +#endif + /**************************************************************************** * Name: up_cpu_index * @@ -1741,7 +1789,7 @@ int up_cpu_index(void); * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of * the stack pointer. * - * Inputs: + * Input Parameters: * - cpu: CPU index that indicates which CPU the IDLE task is * being created for. * - tcb: The TCB of new CPU IDLE task @@ -2015,10 +2063,10 @@ void sched_alarm_expiration(FAR const struct timespec *ts); * Description: * Collect data that can be used for CPU load measurements. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions/Limitations: @@ -2054,7 +2102,7 @@ void irq_dispatch(int irq, FAR void *context); * Input Parameters: * None * - * Returned value: + * Returned Value: * The estimated amount of stack space used. * ****************************************************************************/ diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h index 1bdb9fe7ef4964cb5f98e1561620f2d08fbe4e5e..1395873622bd1848716db91abc7c5c6f2f81829b 100644 --- a/include/nuttx/audio/audio.h +++ b/include/nuttx/audio/audio.h @@ -670,7 +670,7 @@ extern "C" * When this function is called, the "lower half" driver should be in the * reset state (as if the shutdown() method had already been called). * - * Input parameters: + * Input Parameters: * name - The name of the audio device. This name will be used to generate * a full path to the driver in the format "/dev/audio/[name]" in the NuttX * filesystem (i.e. the path "/dev/audio" will be prepended to the supplied @@ -695,7 +695,7 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev); * Allocated an AP Buffer and prepares it for use. This allocates a dynamically * allocated buffer that has no special DMA capabilities. * - * Input parameters: + * Input Parameters: * bufdesc: Pointer to a buffer descriptor * * Returned Value: diff --git a/include/nuttx/audio/tone.h b/include/nuttx/audio/tone.h index e9a9c0059ac7d43db69074815306609911862d54..f5087ae74361334e645cf310314d56e875e42ce9 100644 --- a/include/nuttx/audio/tone.h +++ b/include/nuttx/audio/tone.h @@ -71,7 +71,7 @@ extern "C" * be used by application code. * * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name all PWM drivers * as "/dev/tone0", "/dev/tone1", etc. where the driver path diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h index 4ca74f5a01a8c54db4458298f4a638e574c54dac..ab238a2d6cba13eb5782633b0e727b63b3f71a67 100644 --- a/include/nuttx/binfmt/binfmt.h +++ b/include/nuttx/binfmt/binfmt.h @@ -271,7 +271,7 @@ int exec_module(FAR const struct binary_s *bin); * or friends. It will also automatically free the structure with * kmm_free() after unloading the module. * - * Input Parameter: + * Input Parameters: * pid - The task ID of the child task * bin - This structure must have been allocated with kmm_malloc() and must * persist until the task unloads diff --git a/include/nuttx/binfmt/builtin.h b/include/nuttx/binfmt/builtin.h index 6f4a87be2439b5b3bd9b2fff1d03523dec270aed..bb4594bb9a3c92dbac916c558763eebf684c145f 100644 --- a/include/nuttx/binfmt/builtin.h +++ b/include/nuttx/binfmt/builtin.h @@ -117,7 +117,7 @@ void builtin_uninitialize(void); * Description: * Checks for availabiliy of application registerred during compile time. * - * Input Parameter: + * Input Parameters: * filename - Name of the linked-in binary to be started. * * Returned Value: @@ -136,7 +136,7 @@ int builtin_isavail(FAR const char *appname); * Returns pointer to a name of built-in application pointed by the * index. * - * Input Parameter: + * Input Parameters: * index, from 0 and on ... * * Returned Value: @@ -158,7 +158,7 @@ FAR const char *builtin_getname(int index); * If support for builtin functions is enabled in the NuttX configuration, * then this function must be provided by the application code. * - * Input Parameter: + * Input Parameters: * index, from 0 and on... * * Returned Value: diff --git a/include/nuttx/board.h b/include/nuttx/board.h index af120a8808e29e27619a90cf5bcd8b4bd70d3ec4..5c646a48a96f8f2933dd432c21f83f7e21dd95fd 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/board.h * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -285,58 +285,6 @@ int board_composite_initialize(int port); FAR void *board_composite_connect(int port, int configid); #endif -/**************************************************************************** - * Name: board_tsc_setup - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. - * - * This is an internal OS interface but may be invoked indirectly from - * application-level touchscreen testing logic (perhaps by - * apps/examples/touchscreen). If CONFIG_LIB_BOARDCTL=y and - * CONFIG_BOARDCTL_TSCTEST=y, then this functions will be invoked via the - * (non-standard) boardctl() interface using the BOARDIOC_TSCTEST_SETUP - * command. - * - * Input Parameters: - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int board_tsc_setup(int minor); - -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * This is an internal OS interface but may be invoked indirectly from - * application-level touchscreen testing logic (perhaps by - * apps/examples/touchscreen). If CONFIG_LIB_BOARDCTL=y and - * CONFIG_BOARDCTL_TSCTEST=y, then this functions will be invoked via the - * (non-standard) boardctl() interface using the BOARDIOC_TSCTEST_TEARDOWN - * command. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void); - /**************************************************************************** * Name: board_graphics_setup * diff --git a/include/nuttx/cancelpt.h b/include/nuttx/cancelpt.h index 87b560fd92233ef3b6c0abd91d513b301244c5e3..10cd20bfafb8c33c6479a08829b025a71b92b9df 100644 --- a/include/nuttx/cancelpt.h +++ b/include/nuttx/cancelpt.h @@ -103,7 +103,7 @@ extern "C" * Input Parameters: * None * - * Returned Value + * Returned Value: * true is returned if a cancellation is pending but cannot be performed * now due to the nesting level. * @@ -133,7 +133,7 @@ bool enter_cancellation_point(void); * Input Parameters: * None * - * Returned Value + * Returned Value: * None * ****************************************************************************/ @@ -157,7 +157,7 @@ void leave_cancellation_point(void); * Input Parameters: * None * - * Returned Value + * Returned Value: * true is returned if a cancellation is pending but cannot be performed * now due to the nesting level. * diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index d05d49a50eb3e52f00009a6cf0c0923a0e930a79..0892615e3cd5e5a0266418f828b26c676a8c4c0d 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -272,7 +272,7 @@ EXTERN volatile systime_t g_system_timer; * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -302,7 +302,7 @@ void clock_synchronize(void); * Parameters: * diff: amount of time system-time is adjusted forward with RTC * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -329,7 +329,7 @@ void clock_resynchronize(FAR struct timespec *rtc_diff); * Parameters: * None * - * Return Value: + * Returned Value: * The current value of the system timer counter * * Assumptions: @@ -350,7 +350,7 @@ systime_t clock_systimer(void); * Parameters: * ts - Location to return the time * - * Return Value: + * Returned Value: * Current version always returns OK * * Assumptions: @@ -369,7 +369,7 @@ int clock_systimespec(FAR struct timespec *ts); * pid - The task ID of the thread of interest. pid == 0 is the IDLE thread. * cpuload - The location to return the CPU load * - * Return Value: + * Returned Value: * OK (0) on success; a negated errno value on failure. The only reason * that this function can fail is if 'pid' no longer refers to a valid * thread. diff --git a/include/nuttx/crypto/aes.h b/include/nuttx/crypto/aes.h index 5c4d3e805078f942797947abfb9a1560912faeca..af97032e50d3c01d372d3b62592a875926431f95 100644 --- a/include/nuttx/crypto/aes.h +++ b/include/nuttx/crypto/aes.h @@ -75,7 +75,7 @@ extern "C" * key AES128 key of size 16 bytes * state 16 bytes of plain text and cipher text * - * Returned Value + * Returned Value: * None * ****************************************************************************/ @@ -94,7 +94,7 @@ void aes_encrypt(FAR uint8_t *state, FAR const uint8_t *key); * key AES128 key of size 16 bytes * state 16 bytes of plain text and cipher text * - * Returned Value + * Returned Value: * None * ****************************************************************************/ diff --git a/include/nuttx/drivers/drivers.h b/include/nuttx/drivers/drivers.h index 612434d15b7a1948c96a5c2aabd873dd084c6047..b2f1bbf79ec7a957316229004b79f796a02d30d0 100644 --- a/include/nuttx/drivers/drivers.h +++ b/include/nuttx/drivers/drivers.h @@ -227,12 +227,12 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, * the NuttX FIFOs are based in in-memory, circular buffers, the ability * to control the size of those buffers is critical for system tuning. * - * Inputs: + * Input Parameters: * fd[2] - The user provided array in which to catch the pipe file * descriptors * bufsize - The size of the in-memory, circular buffer in bytes. * - * Return: + * Returned Value: * 0 is returned on success; otherwise, -1 is returned with errno set * appropriately. * @@ -264,13 +264,13 @@ int pipe2(int fd[2], size_t bufsize); * the NuttX FIFOs are based in in-memory, circular buffers, the ability * to control the size of those buffers is critical for system tuning. * - * Inputs: + * Input Parameters: * pathname - The full path to the FIFO instance to attach to or to create * (if not already created). * mode - Ignored for now * bufsize - The size of the in-memory, circular buffer in bytes. * - * Return: + * Returned Value: * 0 is returned on success; otherwise, -1 is returned with errno set * appropriately. * diff --git a/include/nuttx/drivers/pwm.h b/include/nuttx/drivers/pwm.h index eddea5804e28d78fb25706e14ec30a46d12ba639..2d0a5d2c7db7e408a3cf3ffb4419a9d7079437b3 100644 --- a/include/nuttx/drivers/pwm.h +++ b/include/nuttx/drivers/pwm.h @@ -260,7 +260,7 @@ extern "C" * When this function is called, the "lower half" driver should be in the * reset state (as if the shutdown() method had already been called). * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name all PWM drivers * as "/dev/pwm0", "/dev/pwm1", etc. where the driver path differs only @@ -301,7 +301,7 @@ int pwm_register(FAR const char *path, FAR struct pwm_lowerhalf_s *dev); * interface using the handle that was previously passed to the * start() method * - * Input parameters: + * Input Parameters: * handle - This is the handle that was provided to the lower-half * start() method. * diff --git a/include/nuttx/drivers/ramdisk.h b/include/nuttx/drivers/ramdisk.h index 27cfb4e992a43855a09682012bf47c6c0b91ba77..86bb5f4effa1b807a3c717c48a43aef6011d05c8 100644 --- a/include/nuttx/drivers/ramdisk.h +++ b/include/nuttx/drivers/ramdisk.h @@ -79,14 +79,14 @@ extern "C" * Description: * Non-standard function to register a ramdisk or a romdisk * - * Input Parmeters: + * Input Parameters: * minor: Selects suffix of device named /dev/ramN, N={1,2,3...} * nsectors: Number of sectors on device * sectize: The size of one sector * rdflags: See RDFLAG_* definitions * buffer: RAM disk backup memory * - * Returned Valued: + * Returned Value: * Zero on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/include/nuttx/eeprom/i2c_xx24xx.h b/include/nuttx/eeprom/i2c_xx24xx.h new file mode 100644 index 0000000000000000000000000000000000000000..6dfd16ba294b2a95646160dc92244a7bf9ad89aa --- /dev/null +++ b/include/nuttx/eeprom/i2c_xx24xx.h @@ -0,0 +1,113 @@ + /**************************************************************************** + * include/nuttx/eeprom/i2c_xx24xx.h + * + * Copyright (C) 2018 Sebastien Lorquet. All rights reserved. + * Author: Sebastien Lorquet + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_EEPROM_I2C_XX24XX_H +#define __INCLUDE_NUTTX_EEPROM_I2C_XX24XX_H 1 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* DO NOT CHANGE ORDER, IT MACHES CODE IN drivers/eeprom/i2c_xx24xx.c */ + +enum eeprom_24xx_e +{ + /* Microchip geometries */ + + EEPROM_24xx00, + EEPROM_24xx01, + EEPROM_24xx02, + EEPROM_24xx04, + EEPROM_24xx08, + EEPROM_24xx16, + EEPROM_24xx32, + EEPROM_24xx64, + EEPROM_24xx128, + EEPROM_24xx256, + EEPROM_24xx512, + EEPROM_24xx1025, + EEPROM_24xx1026, + + /* Atmel geometries - none... */ + + /* STM geometries */ + + EEPROM_M24C01, + EEPROM_M24C02, + EEPROM_M24M02, + + /* Aliases (devices similar to previously defined ones) */ + + EEPROM_AT24C01 = EEPROM_24xx01, + EEPROM_AT24C02 = EEPROM_24xx02, + EEPROM_AT24C04 = EEPROM_24xx04, + EEPROM_AT24C08 = EEPROM_24xx08, + EEPROM_AT24C16 = EEPROM_24xx16, + EEPROM_AT24C32 = EEPROM_24xx32, + EEPROM_AT24C64 = EEPROM_24xx64, + EEPROM_AT24C128 = EEPROM_24xx128, + EEPROM_AT24C256 = EEPROM_24xx256, + EEPROM_AT24C512 = EEPROM_24xx512, + EEPROM_AT24C1024 = EEPROM_24xx1026, + + EEPROM_M24C04 = EEPROM_24xx04, + EEPROM_M24C08 = EEPROM_24xx08, + EEPROM_M24C16 = EEPROM_24xx16, + EEPROM_M24C32 = EEPROM_24xx32, + EEPROM_M24C64 = EEPROM_24xx64, + EEPROM_M24128 = EEPROM_24xx128, + EEPROM_M24256 = EEPROM_24xx256, + EEPROM_M24512 = EEPROM_24xx512, + EEPROM_M24M01 = EEPROM_24xx1026, +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: ee24xx_initialize + * + * Description: Bind a EEPROM driver to an I2C bus. The user MUST provide + * a description of the device geometry, since it is not possible to read + * this information from the device (contrary to the SPI flash devices). + * + ****************************************************************************/ + +struct i2c_master_s; +int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr, + FAR char *devname, int devtype, int readonly); + +#endif /* __INCLUDE__NUTTX_EEPROM_I2C_XX24XX_H */ diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index bb3b989ab4ae270228d8c7af06cb333b4d58fb25..424b8b44773cf3cd95c0536e349aa7b446b685b4 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -496,7 +496,7 @@ void fs_initialize(void); * Description: * Register a character driver inode the pseudo file system. * - * Input parameters: + * Input Parameters: * path - The path to the inode to create * fops - The file operations structure * mode - inmode privileges (not used) @@ -523,7 +523,7 @@ int register_driver(FAR const char *path, * Description: * Register a block driver inode the pseudo file system. * - * Input parameters: + * Input Parameters: * path - The path to the inode to create * bops - The block driver operations structure * mode - inmode privileges (not used) @@ -1051,7 +1051,7 @@ int file_truncate(FAR struct file *filep, off_t length); * req The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * Returns a non-negative number on success; A negated errno value is * returned on any failure (see comments ioctl() for a list of appropriate * errno values). diff --git a/include/nuttx/fs/unionfs.h b/include/nuttx/fs/unionfs.h index 35815de8c3eeb0efc68ecfd71f4b0965af6fa060..485197e129a56f188184e24bb94dcad78a20d31f 100644 --- a/include/nuttx/fs/unionfs.h +++ b/include/nuttx/fs/unionfs.h @@ -83,7 +83,7 @@ extern "C" * file system appear a some path below the unionfs mountpoint, * mountpt - The full path to the mountpoint for the union file system * - * Returned value: + * Returned Value: * Zero (OK) is returned if the union file system was correctly created and * mounted. On any failure, a negated error value will be returned to * indicate the nature of the failure. diff --git a/include/nuttx/fs/userfs.h b/include/nuttx/fs/userfs.h index 29ad9d3d915d0f7ac47f26f1c5bf46d4ca82cbdc..a1b96938ee1bb5d675293c049323c1c2983de235 100644 --- a/include/nuttx/fs/userfs.h +++ b/include/nuttx/fs/userfs.h @@ -549,7 +549,7 @@ extern "C" * NOTE: This is an OS internal function that should not be called from * appliation logic. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -584,7 +584,7 @@ int userfs_register(void); * NOTE: This is a user function that is implemented as part of the * NuttX C library and is intended to be called by appliation logic. * - * Input parameters: + * Input Parameters: * mountpt - Mountpoint path * userops - The caller operations that implement the file system * interface. diff --git a/include/nuttx/input/ajoystick.h b/include/nuttx/input/ajoystick.h index 7cc7d384b0da90987e0164d05cd3bb3c4a85e6d1..9e7d6a0cd0f175988d22365c92c18d909e86d40a 100644 --- a/include/nuttx/input/ajoystick.h +++ b/include/nuttx/input/ajoystick.h @@ -283,7 +283,7 @@ extern "C" * lower - An instance of the platform-specific analog joystick lower * half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/include/nuttx/input/buttons.h b/include/nuttx/input/buttons.h index dbaaec45e176026c8f472cf6e7846ddcf3c3464c..601979b462e11b6469e0cbc4b324b2df37b02d0a 100644 --- a/include/nuttx/input/buttons.h +++ b/include/nuttx/input/buttons.h @@ -191,7 +191,7 @@ extern "C" * minor device number. * lower - An instance of the platform-specific button lower half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/include/nuttx/input/djoystick.h b/include/nuttx/input/djoystick.h index 3f0f1e0aa96f7bb37036a9e22e6896bc9ea9b759..21def3909b82f4c521a1ea9291244153255ced07 100644 --- a/include/nuttx/input/djoystick.h +++ b/include/nuttx/input/djoystick.h @@ -260,7 +260,7 @@ extern "C" * lower - An instance of the platform-specific discrete joystick lower * half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/include/nuttx/input/nunchuck.h b/include/nuttx/input/nunchuck.h index 844b66abc2cf1eabc5362ca892d5372083261e94..cc0a3b8fcad8fb2fc9d23a9b70f9891316b92fc7 100644 --- a/include/nuttx/input/nunchuck.h +++ b/include/nuttx/input/nunchuck.h @@ -169,7 +169,7 @@ extern "C" * minor device number. * i2c - An instance of the platform-specific I2C connected to Nunchuck. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/include/nuttx/irq.h b/include/nuttx/irq.h index 8f4ed3824f4631a2d8ee198cb49fdb46d674e92a..56f24ff897dc1908840c187226046394f0bf8f83 100644 --- a/include/nuttx/irq.h +++ b/include/nuttx/irq.h @@ -114,8 +114,8 @@ typedef uint32_t irq_mapped_t; /* This struct defines the form of an interrupt service routine */ -typedef int (*xcpt_t)(int irq, FAR void *context, FAR void *arg); -#endif +typedef CODE int (*xcpt_t)(int irq, FAR void *context, FAR void *arg); +#endif /* __ASSEMBLY__ */ /* Now include architecture-specific types */ @@ -247,7 +247,8 @@ void leave_critical_section(irqstate_t flags); * ****************************************************************************/ -#if defined (CONFIG_SMP) && defined (CONFIG_SPINLOCK_IRQ) +#if defined(CONFIG_SMP) && defined(CONFIG_SPINLOCK_IRQ) && \ + defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) irqstate_t spin_lock_irqsave(void); #else # define spin_lock_irqsave(f) enter_critical_section(f) @@ -275,7 +276,8 @@ irqstate_t spin_lock_irqsave(void); * ****************************************************************************/ -#if defined (CONFIG_SMP) && defined (CONFIG_SPINLOCK_IRQ) +#if defined(CONFIG_SMP) && defined(CONFIG_SPINLOCK_IRQ) && \ + defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) void spin_unlock_irqrestore(irqstate_t flags); #else # define spin_unlock_irqrestore(f) leave_critical_section(f) diff --git a/include/nuttx/kthread.h b/include/nuttx/kthread.h index f345a0e914c3c2027a9c01ec886eaf08d14cc902..c9f2ffaf70e00ad83658899708cf53e25d03927b 100644 --- a/include/nuttx/kthread.h +++ b/include/nuttx/kthread.h @@ -64,6 +64,49 @@ extern "C" * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: nxtask_create + * + * Description: + * This function creates and activates a new user task with a specified + * priority and returns its system-assigned ID. + * + * The entry address entry is the address of the "main" function of the + * task. This function will be called once the C environment has been + * set up. The specified function will be called with four arguments. + * Should the specified routine return, a call to exit() will + * automatically be made. + * + * Note that four (and only four) arguments must be passed for the spawned + * functions. + * + * nxtask_create() is identical to the function task_create(), differing + * only in its return value: This function does not modify the errno + * variable. This is a non-standard, internal OS function and is not + * intended for use by application logic. Applications should use + * task_create(). + * + * Input Parameters: + * name - Name of the new task + * priority - Priority of the new task + * stack_size - size (in bytes) of the stack needed + * entry - Entry point of a new task + * arg - A pointer to an array of input parameters. Up to + * CONFIG_MAX_TASK_ARG parameters may be provided. If fewer + * than CONFIG_MAX_TASK_ARG parameters are passed, the list + * should be terminated with a NULL argv[] value. If no + * parameters are required, argv may be NULL. + * + * Returned Value: + * Returns the positive, non-zero process ID of the new task or a negated + * errno value to indicate the nature of any failure. If memory is + * insufficient or the task cannot be created -ENOMEM will be returned. + * + ****************************************************************************/ + +int nxtask_create(FAR const char *name, int priority, + int stack_size, main_t entry, FAR char * const argv[]); + /******************************************************************************** * Name: kthread_create * @@ -73,10 +116,20 @@ extern "C" * newly started thread to run in kernel model. * * Input Parameters: - * (same as task_create()) + * name - Name of the new task + * priority - Priority of the new task + * stack_size - size (in bytes) of the stack needed + * entry - Entry point of a new task + * arg - A pointer to an array of input parameters. Up to + * CONFIG_MAX_TASK_ARG parameters may be provided. If fewer + * than CONFIG_MAX_TASK_ARG parameters are passed, the list + * should be terminated with a NULL argv[] value. If no + * parameters are required, argv may be NULL. * - * Return Value: - * (same as task_create()) + * Returned Value: + * Returns the positive, non-zero process ID of the new task or a negated + * errno value to indicate the nature of any failure. If memory is + * insufficient or the task cannot be created -ENOMEM will be returned. * ********************************************************************************/ diff --git a/include/nuttx/lcd/ssd1306.h b/include/nuttx/lcd/ssd1306.h index fa1117828dc845ac529c7e3cfe05b5f8da471647..9a8433c68a66b03bb2188825d95520677458a388 100644 --- a/include/nuttx/lcd/ssd1306.h +++ b/include/nuttx/lcd/ssd1306.h @@ -244,8 +244,10 @@ extern "C" * **************************************************************************************/ -struct lcd_dev_s; /* See include/nuttx/lcd/lcd.h */ -struct spi_dev_s; /* See include/nuttx/spi/spi.h */ +struct lcd_dev_s; /* See include/nuttx/lcd/lcd.h */ +struct spi_dev_s; /* See include/nuttx/spi/spi.h */ +struct i2c_master_s; /* See include/nuttx/i2c/i2c_master.h */ + #ifdef CONFIG_LCD_SSD1306_SPI FAR struct lcd_dev_s *ssd1306_initialize(FAR struct spi_dev_s *dev, FAR const struct ssd1306_priv_s *board_priv, diff --git a/include/nuttx/leds/rgbled.h b/include/nuttx/leds/rgbled.h index 554f0719ffdc1e52e073aabd2d4af02712d0ab0a..4fb192dc330cc5a9c9b1ad3642edc0f53401885e 100644 --- a/include/nuttx/leds/rgbled.h +++ b/include/nuttx/leds/rgbled.h @@ -71,7 +71,7 @@ extern "C" * be used by application code. * * - * Input parameters: + * Input Parameters: * path - The full path to the driver to be registers in the NuttX pseudo- * filesystem. The recommended convention is to name all PWM drivers * as "/dev/rgdbled0", "/dev/rgbled1", etc. where the driver path diff --git a/include/nuttx/leds/userled.h b/include/nuttx/leds/userled.h index 0b9f8b0e25d17c73ba08e9dec8447b77b794c7db..f0a027808a3dfa2cbef5b77e853edbc8b53b6682 100644 --- a/include/nuttx/leds/userled.h +++ b/include/nuttx/leds/userled.h @@ -170,7 +170,7 @@ extern "C" * minor device number. * lower - An instance of the platform-specific LED lower half driver. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/include/nuttx/mqueue.h b/include/nuttx/mqueue.h index b7276a6ff5da70cc7254b4dcc580626d48d137c7..9c6a650c28780247970b70f19aa580f9023e0bef 100644 --- a/include/nuttx/mqueue.h +++ b/include/nuttx/mqueue.h @@ -306,7 +306,7 @@ ssize_t nxmq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen, * closed so that no thread will attempt access it while it is being * deleted. * - * Inputs: + * Input Parameters: * msgq - Named essage queue to be freed * * Returned Value: diff --git a/include/nuttx/mtd/configdata.h b/include/nuttx/mtd/configdata.h index 65965c61959516ffc7434268ed302aa289b72277..1dff77f0f2b3954e7d4cde3d39984df78ac691ff 100644 --- a/include/nuttx/mtd/configdata.h +++ b/include/nuttx/mtd/configdata.h @@ -117,7 +117,7 @@ extern "C" * When this function is called, the MTD device pass in should already * be initialized appropriately to access the physical device or partition. * - * Input parameters: + * Input Parameters: * mtd - Pointer to the MTD device to bind with the /dev/config device * * Returned Value: diff --git a/include/nuttx/mtd/hamming.h b/include/nuttx/mtd/hamming.h index 99358e10dcfbb0365746a36b2e33d2b5218d70cc..706cb125f1853737e902112179bd059944b3781a 100644 --- a/include/nuttx/mtd/hamming.h +++ b/include/nuttx/mtd/hamming.h @@ -108,7 +108,7 @@ extern "C" * size - Data size in bytes * code - Codes buffer * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -127,7 +127,7 @@ void hamming_compute256x(FAR const uint8_t *data, size_t size, uint8_t *code); * size - Size of the data in bytes * code - Original codes * - * Returned Values: + * Returned Value: * Return 0 if the data is correct, HAMMING_ERROR_SINGLEBIT if one or more * block(s) have had a single bit corrected, or either HAMMING_ERROR_ECC * or HAMMING_ERROR_MULTIPLEBITS. diff --git a/include/nuttx/mtd/mtd.h b/include/nuttx/mtd/mtd.h index e834469866aeca00392147a1414fb74f12245f0a..f201e9ebbd0fb54958d554384073befcde171eef 100644 --- a/include/nuttx/mtd/mtd.h +++ b/include/nuttx/mtd/mtd.h @@ -243,7 +243,7 @@ extern "C" * partitions, that mutual exclusion would be provided by the file system * above the FLASH driver. * - * Input parameters: + * Input Parameters: * mtd - The MTD device to be partitioned * firstblock - The offset in bytes to the first block * nblocks - The number of blocks in the partition diff --git a/include/nuttx/mtd/nand.h b/include/nuttx/mtd/nand.h index b19c6cb79ad8fcfded62a7167a35c8beffe418b3..ab3b73771f8da5d54bacd4a35c792d5b49549af2 100644 --- a/include/nuttx/mtd/nand.h +++ b/include/nuttx/mtd/nand.h @@ -99,10 +99,10 @@ extern "C" * Description: * Probe and initialize NAND. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * - * Returned value. + * Returned Value: * A non-NULL MTD driver intstance is returned on success. NULL is * returned on any failaure. * diff --git a/include/nuttx/mtd/nand_ecc.h b/include/nuttx/mtd/nand_ecc.h index 7e94d4c373c9f5bb93b274a55c0e19134de0057f..a86b0f2aab414b55e4f8a8535c8ae102cdd54171 100644 --- a/include/nuttx/mtd/nand_ecc.h +++ b/include/nuttx/mtd/nand_ecc.h @@ -86,14 +86,14 @@ extern "C" * the spare area. If a buffer pointer is NULL, then the corresponding area * is not saved. * - * Input parameters: + * Input Parameters: * nand - Upper-half, NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in success; a negated errno value is returned on failure. * ****************************************************************************/ @@ -111,14 +111,14 @@ int nandecc_readpage(FAR struct nand_dev_s *nand, off_t block, * If no spare buffer is provided, the spare area is still written with the * ECC information calculated on the data buffer. * - * Input parameters: + * Input Parameters: * nand - Upper-half, NAND FLASH interface * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer containing the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in success; a negated errno value is returned on failure. * ****************************************************************************/ diff --git a/include/nuttx/mtd/nand_model.h b/include/nuttx/mtd/nand_model.h index bd1363cfdd1b5deae44d8fee54c1677668e5cbb7..0012e339bf35f9acbdc44dce62b31e362e083338 100644 --- a/include/nuttx/mtd/nand_model.h +++ b/include/nuttx/mtd/nand_model.h @@ -127,7 +127,7 @@ EXTERN const struct nand_model_s g_nandmodels[NAND_NMODELS]; * chipid Identifier returned by the Nand(id1|(id2<<8)|(id3<<16)|(id4<<24)). * model nand_model_s instance to update with the model parameters. * - * Returned Values: + * Returned Value: * OK is returned on success; -ENODEV is returned on failure. * ****************************************************************************/ @@ -151,7 +151,7 @@ int nandmodel_find(FAR const struct nand_model_s *modeltab, size_t size, * page Stores the first accessed page number inside the first block. * offset Stores the byte offset inside the first accessed page. * - * Returned Values: + * Returned Value: * OK on success; -EPIPE on failure. * ****************************************************************************/ @@ -170,7 +170,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Spare placement scheme * ****************************************************************************/ @@ -186,7 +186,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Device ID * ****************************************************************************/ @@ -202,7 +202,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Number of blocks in the device * ****************************************************************************/ @@ -220,7 +220,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Size of the device in bytes * ****************************************************************************/ @@ -237,7 +237,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * size of the device in MB. * ****************************************************************************/ @@ -253,7 +253,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Block size in pages * ****************************************************************************/ @@ -270,7 +270,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Number of pages in the device * ****************************************************************************/ @@ -288,7 +288,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Block size in bytes * ****************************************************************************/ @@ -304,7 +304,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Size of data area in bytes * ****************************************************************************/ @@ -320,7 +320,7 @@ int nandmodel_translate(FAR const struct nand_model_s *model, off_t address, * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * size of spare area in bytes * ****************************************************************************/ @@ -336,7 +336,7 @@ unsigned int nandmodel_getsparesize(FAR const struct nand_model_s *model); * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * data width * ****************************************************************************/ @@ -354,7 +354,7 @@ unsigned int nandmodel_getsparesize(FAR const struct nand_model_s *model); * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Returns true if the given NAND FLASH model uses the "small blocks/pages" * command set; otherwise returns false. * @@ -372,7 +372,7 @@ unsigned int nandmodel_getsparesize(FAR const struct nand_model_s *model); * Input Parameters: * model Pointer to a nand_model_s instance. * - * Returned Values: + * Returned Value: * Returns true if the device supports the copy-back operation. Otherwise * returns false. * diff --git a/include/nuttx/mtd/nand_raw.h b/include/nuttx/mtd/nand_raw.h index f2edd3821e50b1bfcb4be1b50fc2ac550be0dcd9..44cc069000386cefbacf712cc3cf8fc02150cadb 100644 --- a/include/nuttx/mtd/nand_raw.h +++ b/include/nuttx/mtd/nand_raw.h @@ -128,11 +128,11 @@ * Description: * Erases the specified block of the device. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the physical block to erase. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -146,14 +146,14 @@ * Reads the data and/or the spare areas of a page of a NAND FLASH into the * provided buffers. This is a raw read of the flash contents. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -167,14 +167,14 @@ * Writes the data and/or the spare area of a page on a NAND FLASH chip. * This is a raw write of the flash contents. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer containing the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -189,14 +189,14 @@ * provided buffers. Hardware ECC checking will be performed if so * configured. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to read resides. * page - Number of the page to read inside the given block. * data - Buffer where the data area will be stored. * spare - Buffer where the spare area will be stored. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ @@ -214,14 +214,14 @@ * Writes the data and/or the spare area of a page on a NAND FLASH chip. * Hardware ECC checking will be performed if so configured. * - * Input parameters: + * Input Parameters: * raw - Lower-half, raw NAND FLASH interface * block - Number of the block where the page to write resides. * page - Number of the page to write inside the given block. * data - Buffer containing the data to be writting * spare - Buffer containing the spare data to be written. * - * Returned value. + * Returned Value: * OK is returned in succes; a negated errno value is returned on failure. * ****************************************************************************/ diff --git a/include/nuttx/mtd/nand_scheme.h b/include/nuttx/mtd/nand_scheme.h index acc4b56f11dca4cde0dd9674d105ecf439f95ae7..a30caae1657be2a384490c09e0dcc83d5abcd457 100644 --- a/include/nuttx/mtd/nand_scheme.h +++ b/include/nuttx/mtd/nand_scheme.h @@ -109,7 +109,7 @@ EXTERN const struct nand_scheme_s g_nand_sparescheme4096; * spare Spare area buffer. * marker Pointer to the variable to store the bad block marker. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -130,7 +130,7 @@ void nandscheme_readbadblockmarker(FAR const struct nand_scheme_s *scheme, * spare Spare area buffer. * marker Bad block marker to write. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -150,7 +150,7 @@ void nandscheme_writebadblockmarker(FAR const struct nand_scheme_s *scheme, * Input Parameters: * scheme Pointer to a nand_scheme_s instance. * - * Returned Values: + * Returned Value: * Offset in the spare area to the first ECC byte * ****************************************************************************/ @@ -166,7 +166,7 @@ void nandscheme_writebadblockmarker(FAR const struct nand_scheme_s *scheme, * Input Parameters: * scheme Pointer to a nand_scheme_s instance. * - * Returned Values: + * Returned Value: * Size of the ECC information in the spare area. * ****************************************************************************/ @@ -184,7 +184,7 @@ void nandscheme_writebadblockmarker(FAR const struct nand_scheme_s *scheme, * spare Spare area buffer. * ecc ECC buffer. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -203,7 +203,7 @@ void nandscheme_readecc(FAR const struct nand_scheme_s *scheme, * spare Spare area buffer. * ecc ECC buffer. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -223,7 +223,7 @@ void nandscheme_writeecc(FAR const struct nand_scheme_s *scheme, * Input Parameters: * scheme Pointer to a nand_scheme_s instance. * - * Returned Values: + * Returned Value: * Offset in the spare area to the first extra byte * ****************************************************************************/ @@ -239,7 +239,7 @@ void nandscheme_writeecc(FAR const struct nand_scheme_s *scheme, * Input Parameters: * scheme Pointer to a nand_scheme_s instance. * - * Returned Values: + * Returned Value: * Size of the extra information in the spare area. * ****************************************************************************/ @@ -260,7 +260,7 @@ void nandscheme_writeecc(FAR const struct nand_scheme_s *scheme, * size Number of extra bytes to read. * offset Index where to read the first extra byte. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -283,7 +283,7 @@ void nandscheme_readextra(FAR const struct nand_scheme_s *scheme, * size Number of extra bytes to write. * offset Index where to write the first extra byte. * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -305,7 +305,7 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme, * size Number of extra bytes to write. * offset Index where to write the first extra byte. * - * Returned Values: + * Returned Value: * OK on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/include/nuttx/net/ieee802154.h b/include/nuttx/net/ieee802154.h index 20ff4575934103fdd020ee65e1ec5d744fcfbf2c..5f938f329003ee755734f1eb63f4aeb731fbb4f0 100644 --- a/include/nuttx/net/ieee802154.h +++ b/include/nuttx/net/ieee802154.h @@ -71,7 +71,7 @@ * If there are multilple frames in the list, this metadata * must apply to all of the frames in the list. * - * Return: + * Returned Value: * OK The IEEE 802.15.4 has been processed and can be deleted * ERROR Hold the IEEE 802.15.4 and try again later. There is a listening * socket but no recv in place to catch the IEEE 802.15.4 yet. diff --git a/include/nuttx/net/mii.h b/include/nuttx/net/mii.h index facd4c2f9d593591e88e7f0e01b305e4671b32c1..e4e915e70cf61c22a2dca00e7007bf9096e18c25 100644 --- a/include/nuttx/net/mii.h +++ b/include/nuttx/net/mii.h @@ -583,6 +583,7 @@ # define MII_PHYCTRL2_MODE_BUSY (0 << MII_PHYCTRL2_MODE_SHIFT) /* Still in autonegotiation */ # define MII_PHYCTRL2_MODE_10HDX (1 << MII_PHYCTRL2_MODE_SHIFT) /* 10Base-T half-duplex */ # define MII_PHYCTRL2_MODE_100HDX (2 << MII_PHYCTRL2_MODE_SHIFT) /* 100Base-T half-duplex */ +# define MII_PHYCTRL2_MODE_DUPLEX (4 << MII_PHYCTRL2_MODE_SHIFT) /* Full duplex */ # define MII_PHYCTRL2_MODE_10FDX (5 << MII_PHYCTRL2_MODE_SHIFT) /* 10Base-T full-duplex */ # define MII_PHYCTRL2_MODE_100FDX (6 << MII_PHYCTRL2_MODE_SHIFT) /* 100Base-T full-duplex */ #define MII_PHYCTRL2_SEQTEST (1 << 1) /* Bit 1: Enable SQE test */ @@ -602,6 +603,7 @@ # define MII_PHYCTRL1_MODE_BUSY (0 << MII_PHYCTRL1_MODE_SHIFT) /* Still in autonegotiation */ # define MII_PHYCTRL1_MODE_10HDX (1 << MII_PHYCTRL1_MODE_SHIFT) /* 10Base-T half-duplex */ # define MII_PHYCTRL1_MODE_100HDX (2 << MII_PHYCTRL1_MODE_SHIFT) /* 100Base-T half-duplex */ +# define MII_PHYCTRL1_MODE_DUPLEX (4 << MII_PHYCTRL1_MODE_SHIFT) /* Full duplex */ # define MII_PHYCTRL1_MODE_10FDX (5 << MII_PHYCTRL1_MODE_SHIFT) /* 10Base-T full-duplex */ # define MII_PHYCTRL1_MODE_100FDX (6 << MII_PHYCTRL1_MODE_SHIFT) /* 100Base-T full-duplex */ diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index fb4de5c4737a97dc40585c74dadce28ee7334837..0ca30d9aabe90c671d6a82d27217a319736a7a5f 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -208,8 +208,8 @@ struct socket FAR const struct sock_intf_s *s_sockif; -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS - /* Callback instance for TCP send */ +#if defined(CONFIG_NET_TCP_WRITE_BUFFERS) || defined(CONFIG_NET_UDP_WRITE_BUFFERS) + /* Callback instance for TCP send() or UDP sendto() */ FAR struct devif_callback_s *s_sndcb; #endif @@ -306,7 +306,7 @@ void net_initialize(void); * Input Parameters: * None * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -322,7 +322,7 @@ void net_lock(void); * Input Parameters: * None * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -340,7 +340,7 @@ void net_unlock(void); * sem - A reference to the semaphore to be taken. * abstime - The absolute time to wait until a timeout is declared. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * @@ -358,7 +358,7 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime); * Input Parameters: * sem - A reference to the semaphore to be taken. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * @@ -393,7 +393,7 @@ void net_setipid(uint16_t id); int net_checksd(int fd, int oflags); /**************************************************************************** - * Name: + * Name: net_initlist * * Description: * Initialize a list of sockets for a new task @@ -1037,7 +1037,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, * cmd The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * A non-negative value is returned on success; a negated errno value is * returned on any failure to indicate the nature of the failure: * @@ -1070,7 +1070,7 @@ int psock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg); * cmd The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * A non-negative value is returned on success; a negated errno value is * returned on any failure to indicate the nature of the failure: * diff --git a/include/nuttx/net/pkt.h b/include/nuttx/net/pkt.h index 03e4a0d22afb279a2f4bbfbd4414675775d543d4..fc2d9bd5a27432568e6c31f205c95c6c19a68e2d 100644 --- a/include/nuttx/net/pkt.h +++ b/include/nuttx/net/pkt.h @@ -73,7 +73,7 @@ * Parameters: * dev - The device driver structure containing the received packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR There is a matching connection, but could not dispatch the packet * yet. Useful when a packet arrives before a recv call is in diff --git a/include/nuttx/net/radiodev.h b/include/nuttx/net/radiodev.h index 91cebd35b60616e08b18f126e3d328ef35c85602..b2e95e72725384311901a8344f6213a7a36086cd 100644 --- a/include/nuttx/net/radiodev.h +++ b/include/nuttx/net/radiodev.h @@ -189,7 +189,7 @@ struct radio_driver_s * Description: * Calculate the MAC header length given the frame meta-data. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to recreate the * radio MAC header @@ -209,7 +209,7 @@ struct radio_driver_s * Description: * Requests the transfer of a list of frames to the MAC. * - * Input parameters: + * Input Parameters: * netdev - The network device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -233,7 +233,7 @@ struct radio_driver_s * run time. This information is provided to the 6LoWPAN network via the * following structure. * - * Input parameters: + * Input Parameters: * netdev - The network device to be queried * properties - Location where radio properities will be returned. * diff --git a/include/nuttx/net/telnet.h b/include/nuttx/net/telnet.h index c7184c6d6bba53259e66180033af2c11fc502ed9..16668f1d240e579586f69497c269331526298edd 100644 --- a/include/nuttx/net/telnet.h +++ b/include/nuttx/net/telnet.h @@ -85,7 +85,7 @@ struct telnet_session_s * Parameters: * None * - * Return: + * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/include/nuttx/nx/nx.h b/include/nuttx/nx/nx.h index aec345ac603a1f254ff003ec6f4d6945913aa8c4..209de4fe06a0d8ca301084fa9a667d0967264b98 100644 --- a/include/nuttx/nx/nx.h +++ b/include/nuttx/nx/nx.h @@ -260,7 +260,7 @@ extern "C" * mqname - The name for the server incoming message queue * dev - Vtable "object" of the framebuffer "driver" to use * - * Return: + * Returned Value: * This function usually does not return. If it does return, it will * return ERROR and errno will be set appropriately. * @@ -295,7 +295,7 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev); int nx_start(void); /**************************************************************************** - * Name:nx_connectinstance (and nx_connect macro) + * Name: nx_connectinstance (and nx_connect macro) * * Description: * Open a connection from a client to the NX server. One one client @@ -315,7 +315,7 @@ int nx_start(void); * Input Parameters: * svrmqname - The name for the server incoming message queue * - * Return: + * Returned Value: * Success: A non-NULL handle used with subsequent NX accesses * Failure: NULL is returned and errno is set appropriately * @@ -334,7 +334,7 @@ NXHANDLE nx_connectinstance(FAR const char *svrmqname); * Input Parameters: * handle - the handle returned by nx_connect * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -358,7 +358,7 @@ void nx_disconnect(NXHANDLE handle); * Input Parameters: * handle - the handle returned by nx_connect * - * Return: + * Returned Value: * OK: No errors occurred. If CONFIG_NX_BLOCKING is defined, then * one or more server messages were processed. * ERROR: An error occurred and errno has been set appropriately. Of @@ -385,7 +385,7 @@ int nx_eventhandler(NXHANDLE handle); * Input Parameters: * handle - the handle returned by nx_connect * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -407,7 +407,7 @@ int nx_eventnotify(NXHANDLE handle, int signo); * cb - Callbacks used to process window events * arg - User provided value that will be returned with NX callbacks. * - * Return: + * Returned Value: * Success: A non-NULL handle used with subsequent NX accesses * Failure: NULL is returned and errno is set appropriately * @@ -425,7 +425,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, * Input Parameters: * wnd - The window to be destroyed * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -456,7 +456,7 @@ int nx_closewindow(NXWINDOW hwnd); * arg - An argument that will accompany the block messages (This is arg2 * in the blocked callback). * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -497,7 +497,7 @@ int nx_block(NXWINDOW hwnd, FAR void *arg); * cb - Callbacks to use for processing background window events * arg - User provided value that will be returned with NX callbacks. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -515,7 +515,7 @@ int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb, * Input Parameters: * hwnd - The handle returned (indirectly) by nx_requestbkgd * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -533,7 +533,7 @@ int nx_releasebkgd(NXWINDOW hwnd); * Input Parameters: * hwnd - The window handle * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -550,7 +550,7 @@ int nx_getposition(NXWINDOW hwnd); * hwnd - The window handle * pos - The new position of the window * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -567,7 +567,7 @@ int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos); * hwnd - The window handle * size - The new size of the window. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -580,10 +580,10 @@ int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size); * Description: * Bring the specified window to the top of the display. * - * Input parameters: + * Input Parameters: * hwnd - the window to be raised * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -596,10 +596,10 @@ int nx_raise(NXWINDOW hwnd); * Description: * Lower the specified window to the bottom of the display. * - * Input parameters: + * Input Parameters: * hwnd - the window to be lowered * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -618,7 +618,7 @@ int nx_lower(NXWINDOW hwnd); * pos - The pixel location to be set * col - The color to use in the set * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -637,7 +637,7 @@ int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, * rect - The location to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -666,7 +666,7 @@ int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * rect - The location to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -687,7 +687,7 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * trap - The trapezoidal region to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -712,7 +712,7 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, * caps - Draw a circular on the both ends of the line to support better * line joins * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -734,7 +734,7 @@ int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, * width - The width of the line * color - The color to use to fill the line * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -755,7 +755,7 @@ int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, * radius - The radius of the circle in pixels. * color - The color to use to fill the circle * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -774,7 +774,7 @@ int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, * handle - The connection handle * color - The color to use in the background * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -793,7 +793,7 @@ int nx_setbgcolor(NXHANDLE handle, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); * offset - The offset to move the region. The rectangular region will be * moved so that the origin is translated by this amount. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -819,7 +819,7 @@ int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * may lie outside of the display. * stride - The width of the full source image in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -936,7 +936,7 @@ void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect); * cb - Callbacks used to process window events * arg - User provided value that will be returned with NX callbacks. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately. In the * case of ERROR, NX will have deallocated the pre-allocated window. * diff --git a/include/nuttx/nx/nxfonts.h b/include/nuttx/nx/nxfonts.h index 525a5f56a243a3ea25af63db1e31b5abda669196..47e53aa2cf08d3491217a44ddd43f13f755f84a6 100644 --- a/include/nuttx/nx/nxfonts.h +++ b/include/nuttx/nx/nxfonts.h @@ -603,7 +603,7 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height, * bpp - Bits per pixel * maxglyphs - Maximum number of glyphs permitted in the cache * - * Returned value: + * Returned Value: * On success a non-NULL handle is returned that then may sequently be * used with nxf_getglyph() to extract fonts from the font cache. NULL * returned on any failure with the errno value set to indicate the nature @@ -626,7 +626,7 @@ FCACHE nxf_cache_connect(enum nx_fontid_e fontid, * Input Parameters: * fhandle - A font cache handler previously returned by nxf_cache_connect(); * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -643,7 +643,7 @@ void nxf_cache_disconnect(FCACHE fhandle); * Input Parameters: * fhandle - A font cache handle previously returned by nxf_cache_connect(); * - * Returned value: + * Returned Value: * Zero (OK) is returned if the metrics were * * Returned Value: diff --git a/include/nuttx/nx/nxglib.h b/include/nuttx/nx/nxglib.h index e0d3f6b846c3de69753510d303ee51b94e0cee3b..30850049a7f58e5e03337263d3512de8c46407fc 100644 --- a/include/nuttx/nx/nxglib.h +++ b/include/nuttx/nx/nxglib.h @@ -222,7 +222,7 @@ void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, /**************************************************************************** * Name: nxgl_setpixel_*bpp * - * Descripton: + * Description: * Draw a single pixel in graphics memory at the given position and * with the given color. This is equivalent to nxgl_fillrectangle_*bpp() * with a 1x1 rectangle but is more efficient. @@ -247,7 +247,7 @@ void nxgl_setpixel_32bpp(FAR NX_PLANEINFOTYPE *pinfo, /**************************************************************************** * Name: nxgl_fillrectangle_*bpp * - * Descripton: + * Description: * Fill a rectangle region in the graphics memory with a fixed color * ****************************************************************************/ @@ -277,7 +277,7 @@ void nxgl_fillrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, /**************************************************************************** * Name: nxgl_getrectangle_*bpp * - * Descripton: + * Description: * Fetch a rectangular region from graphics memory. The source is * expressed as a rectangle. * @@ -308,7 +308,7 @@ void nxgl_getrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, /**************************************************************************** * Name: nxglib_filltrapezoid_*bpp * - * Descripton: + * Description: * Fill a trapezoidal region in the graphics memory with a fixed color. * Clip the trapezoid to lie within a bounding box. This is useful for * drawing complex shapes that can be broken into a set of trapezoids. @@ -347,7 +347,7 @@ void nxgl_filltrapezoid_32bpp(FAR NX_PLANEINFOTYPE *pinfo, /**************************************************************************** * Name: nxgl_moverectangle_*bpp * - * Descripton: + * Description: * Move a rectangular region from location to another in the * framebuffer/LCD memory. The source is expressed as a rectangle; the * destination position is expressed as a point corresponding to the @@ -380,7 +380,7 @@ void nxgl_moverectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, /**************************************************************************** * Name: nxgl_copyrectangle_*bpp * - * Descripton: + * Description: * Copy a rectangular bitmap image into the specific position in the * graphics memory. * @@ -679,12 +679,12 @@ bool nxgl_colorcmp(const nxgl_mxpixel_t color1[CONFIG_NX_NPLANES], * this case, 3 trapezoids will be returned, but traps[1] will be * degenerate. * - * Input parameters: + * Input Parameters: * vector - A pointer to the vector described the line to be drawn. * traps - A pointer to a array of trapezoids (size 3). * rect - A pointer to a rectangle. * - * Returned value: + * Returned Value: * 0: Line successfully broken up into three trapezoids. Values in * traps[0], traps[1], and traps[2] are valid. * 1: Line successfully represented by one trapezoid. Value in traps[1] @@ -708,13 +708,13 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector, * circumference of the circle. These points may then be used by * nx_drawcircle() or related APIs to draw a circle outline. * - * Input parameters: + * Input Parameters: * center - A pointer to the point that is the center of the circle * radius - The radius of the circle in pixels. * circle - A pointer the first entry in an array of 16 points where the * circle points will be returned. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -730,13 +730,13 @@ void nxgl_circlepts(FAR const struct nxgl_point_s *center, * Given a description of a a circle, return 8 trapezoids that can be * used to fill the circle by nx_fillcircle() and other interfaces. * - * Input parameters: + * Input Parameters: * center - A pointer to the point that is the center of the circle * radius - The radius of the circle in pixels. * circle - A pointer the first entry in an array of 8 trapezoids where * the circle description will be returned. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ diff --git a/include/nuttx/nx/nxmu.h b/include/nuttx/nx/nxmu.h index fe8253bd74a47bec6ccc2ca9c2d88bc719e06b5b..fb6cd68d343726676720b9d4cb0a6ddcd509fad8 100644 --- a/include/nuttx/nx/nxmu.h +++ b/include/nuttx/nx/nxmu.h @@ -495,7 +495,7 @@ extern "C" * cb - Callbacks used to process window events * arg - User provided value that will be returned with NX callbacks. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately. In the * case of ERROR, NX will have deallocated the pre-allocated window. * @@ -515,7 +515,7 @@ int nxfe_constructwindow(NXHANDLE handle, * Input Parameters: * sem - the semaphore to be taken. * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -533,7 +533,7 @@ void nxmu_semtake(sem_t *sem); * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -553,7 +553,7 @@ int nxmu_sendserver(FAR struct nxfe_conn_s *conn, * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/include/nuttx/nx/nxterm.h b/include/nuttx/nx/nxterm.h index 48347c1fad3aa0ef0596eb0d3d6b3e5c31510fca..dc11a9d10685f3b3b14485d8829755b114605a83 100644 --- a/include/nuttx/nx/nxterm.h +++ b/include/nuttx/nx/nxterm.h @@ -229,7 +229,7 @@ extern "C" * nxtool_register() returns. * minor - The device minor number * - * Return: + * Returned Value: * A non-NULL handle is returned on success. * ****************************************************************************/ @@ -252,7 +252,7 @@ NXTERM nx_register(NXWINDOW hwnd, FAR struct nxterm_window_s *wndo, * nxtool_register() returns. * minor - The device minor number * - * Return: + * Returned Value: * A non-NULL handle is returned on success. * ****************************************************************************/ @@ -277,7 +277,7 @@ NXTERM nxtk_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo, * nxtool_register() returns. * minor - The device minor number * - * Return: + * Returned Value: * A non-NULL handle is returned on success. * ****************************************************************************/ diff --git a/include/nuttx/nx/nxtk.h b/include/nuttx/nx/nxtk.h index 6cd00f01b8d465d48de3ba13036380b52e09c7c8..75b31c21640b69f5d3de75bea86f11e2510d9482 100644 --- a/include/nuttx/nx/nxtk.h +++ b/include/nuttx/nx/nxtk.h @@ -125,7 +125,7 @@ extern "C" * cb - Callbacks used to process window events * arg - User provided value that will be returned with NXTK callbacks. * - * Return: + * Returned Value: * Success: A non-NULL handle used with subsequent NXTK window accesses * Failure: NULL is returned and errno is set appropriately * @@ -143,7 +143,7 @@ NXTKWINDOW nxtk_openwindow(NXHANDLE handle, * Input Parameters: * hfwnd - The handle returned by nxtk_openwindow * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -176,7 +176,7 @@ int nxtk_closewindow(NXTKWINDOW hfwnd); * arg - An argument that will accompany the block messages (This is arg2 * in the blocked callback). * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -194,7 +194,7 @@ int nxtk_block(NXTKWINDOW hfwnd, FAR void *arg); * Input Parameters: * hfwnd - The window handle returned by nxtk_openwindow. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -213,7 +213,7 @@ int nxtk_getposition(NXTKWINDOW hfwnd); * hfwnd - The window handle returned by nxtk_openwindow * pos - The new position of the client sub-window * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -232,7 +232,7 @@ int nxtk_setposition(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *pos); * hfwnd - The window handle returned by nxtk_openwindow * size - The new size of the client sub-window. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -246,11 +246,11 @@ int nxtk_setsize(NXTKWINDOW hfwnd, FAR const struct nxgl_size_s *size); * Bring the window containing the specified client sub-window to the top * of the display. * - * Input parameters: + * Input Parameters: * hfwnd - the window to be raised. This must have been previously created * by nxtk_openwindow(). * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -264,11 +264,11 @@ int nxtk_raise(NXTKWINDOW hfwnd); * Lower the window containing the specified client sub-window to the * bottom of the display. * - * Input parameters: + * Input Parameters: * hfwnd - the window to be lowered. This must have been previously created * by nxtk_openwindow(). * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -286,7 +286,7 @@ int nxtk_lower(NXTKWINDOW hfwnd); * rect - The location within the client window to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -310,7 +310,7 @@ int nxtk_fillwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -330,7 +330,7 @@ int nxtk_getwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, * trap - The trapezoidal region to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -355,7 +355,7 @@ int nxtk_filltrapwindow(NXTKWINDOW hfwnd, * caps - Draw a circular cap the ends of the line to support better * line joins * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -377,7 +377,7 @@ int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, * width - The width of the line * color - The color to use to fill the line * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -399,7 +399,7 @@ int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, * radius - The radius of the circle in pixels. * color - The color to use to fill the circle * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -423,7 +423,7 @@ int nxtk_fillcirclewindow(NXWINDOW hfwnd, * offset - The offset to move the region. The rectangular region will be * moved so that the origin is translated by this amount. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -449,7 +449,7 @@ int nxtk_movewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, * origin may lie outside of the sub-window display. * stride - The width of the full source image in pixels. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -471,7 +471,7 @@ int nxtk_bitmapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, * cb - Callbacks used to process toolbar events * arg - User provided value that will be returned with toolbar callbacks. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -488,7 +488,7 @@ int nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, * Input Parameters: * hfwnd - The handle returned by nxtk_openwindow * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -511,7 +511,7 @@ int nxtk_closetoolbar(NXTKWINDOW hfwnd); * hfwnd - The handle returned by nxtk_openwindow * bounds - User provided location in which to return the bounding box. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -529,7 +529,7 @@ int nxtk_toolbarbounds(NXTKWINDOW hfwnd, FAR struct nxgl_rect_s *bounds); * rect - The location within the toolbar window to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -553,7 +553,7 @@ int nxtk_filltoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -573,7 +573,7 @@ int nxtk_gettoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, * trap - The trapezoidal region to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -599,7 +599,7 @@ int nxtk_filltraptoolbar(NXTKWINDOW hfwnd, * caps - Draw a circular cap on the ends of the line to support better * line joins * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -621,7 +621,7 @@ int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, * width - The width of the line * color - The color to use to fill the line * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -643,7 +643,7 @@ int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, * radius - The radius of the circle in pixels. * color - The color to use to fill the circle * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -668,7 +668,7 @@ int nxtk_fillcircletoolbar(NXWINDOW hfwnd, * offset - The offset to move the region. The rectangular region will be * moved so that the origin is translated by this amount. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -693,7 +693,7 @@ int nxtk_movetoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, * origin may lie outside of the sub-window display. * stride - The width of the full source image in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/include/nuttx/power/battery_charger.h b/include/nuttx/power/battery_charger.h index 997e0fa5c3a610ab3f687d4db389c7a9ff87420a..e17618b2935340d0eb9e3ef269391cad897e3eb2 100644 --- a/include/nuttx/power/battery_charger.h +++ b/include/nuttx/power/battery_charger.h @@ -196,12 +196,12 @@ extern "C" * Register a lower half battery driver with the common, upper-half * battery driver. * - * Input parameters: + * Input Parameters: * devpath - The location in the pseudo-filesystem to create the driver. * Recommended standard is "/dev/bat0", "/dev/bat1", etc. * dev - An instance of the battery state structure . * - * Returned value: + * Returned Value: * Zero on success or a negated errno value on failure. * ****************************************************************************/ diff --git a/include/nuttx/power/battery_gauge.h b/include/nuttx/power/battery_gauge.h index 24a8eb5055d99384c8c268c076c82e3c562401a7..d6bd280cf7c7f7a70d7a9f67a8899c3dcb5e817c 100644 --- a/include/nuttx/power/battery_gauge.h +++ b/include/nuttx/power/battery_gauge.h @@ -158,12 +158,12 @@ extern "C" * Register a lower half battery driver with the common, upper-half * battery driver. * - * Input parameters: + * Input Parameters: * devpath - The location in the pseudo-filesystem to create the driver. * Recommended standard is "/dev/bat0", "/dev/bat1", etc. * dev - An instance of the battery state structure . * - * Returned value: + * Returned Value: * Zero on success or a negated errno value on failure. * ****************************************************************************/ diff --git a/include/nuttx/power/pm.h b/include/nuttx/power/pm.h index 482131911f6c85ba6b0f5896611e51a606b7faa5..92df1c7749165ec690fe0dbeac551fa370e4de7f 100644 --- a/include/nuttx/power/pm.h +++ b/include/nuttx/power/pm.h @@ -364,10 +364,10 @@ extern "C" * *before* any other device drivers are initialized (since they may * attempt to register with the power management subsystem). * - * Input parameters: + * Input Parameters: * None. * - * Returned value: + * Returned Value: * None. * ****************************************************************************/ @@ -381,11 +381,11 @@ void pm_initialize(void); * This function is called by a device driver in order to register to * receive power management event callbacks. * - * Input parameters: + * Input Parameters: * callbacks - An instance of struct pm_callback_s providing the driver * callback functions. * - * Returned value: + * Returned Value: * Zero (OK) on success; otherwise a negater errno value is returned. * ****************************************************************************/ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 86046e4d71079fe35daf57f300ab5a5123db7589..8f80165d762b1687986028a7be2142628dc3e0c0 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -1,7 +1,7 @@ /******************************************************************************** * include/nuttx/sched.h * - * Copyright (C) 2007-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -178,6 +178,38 @@ #define SPORADIC_FLAG_REPLENISH (1 << 2) /* Bit 2: Replenishment cycle */ /* Bits 3-7: Available */ +/* Most internal nxsched_* interfaces are not available in the user space in + * PROTECTED and KERNEL builds. In that context, the application semaphore + * interfaces must be used. The differences between the two sets of + * interfaces are: (1) the nxsched_* interfaces do not cause cancellation + * points and (2) they do not modify the errno variable. + * + * This is only important when compiling libraries (libc or libnx) that are + * used both by the OS (libkc.a and libknx.a) or by the applications + * (libuc.a and libunx.a). The that case, the correct interface must be + * used for the build context. + */ + +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) +# define _SCHED_GETPARAM(t,p) nxsched_getparam(t,p) +# define _SCHED_SETPARAM(t,p) nxsched_setparam(t,p) +# define _SCHED_GETSCHEDULER(t) nxsched_getscheduler(t) +# define _SCHED_SETSCHEDULER(t,s,p) nxsched_setscheduler(t,s,p) +# define _SCHED_GETAFFINITY(t,c,m) nxsched_getaffinity(t,c,m) +# define _SCHED_SETAFFINITY(t,c,m) nxsched_setaffinity(t,c,m) +# define _SCHED_ERRNO(r) (-(r)) +# define _SCHED_ERRVAL(r) (r) +#else +# define _SCHED_GETPARAM(t,p) sched_getparam(t,p) +# define _SCHED_SETPARAM(t,p) sched_setparam(t,p) +# define _SCHED_GETSCHEDULER(t) sched_getscheduler(t) +# define _SCHED_SETSCHEDULER(t,s,p) sched_setscheduler(t,s,p) +# define _SCHED_GETAFFINITY(t,c,m) sched_getaffinity(t,c,m) +# define _SCHED_SETAFFINITY(t,c,m) sched_setaffinity(t,c,m) +# define _SCHED_ERRNO(r) errno +# define _SCHED_ERRVAL(r) (-errno) +#endif + /******************************************************************************** * Public Type Definitions ********************************************************************************/ @@ -791,12 +823,12 @@ FAR struct socketlist *sched_getsockets(void); * The start hook is useful, for example, for setting up automatic * configuration of C++ constructors. * - * Inputs: + * Input Parameters: * tcb - The new, unstarted task task that needs the start hook * starthook - The pointer to the start hook function * arg - The argument to pass to the start hook function. * - * Return: + * Returned Value: * None * ********************************************************************************/ @@ -851,7 +883,7 @@ void task_vforkabort(FAR struct task_tcb_s *child, int errcode); ********************************************************************************/ #if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) || \ - defined(CONFIG_SCHED_INSTRUMENTATION) + defined(CONFIG_SCHED_INSTRUMENTATION) || defined(CONFIG_SMP) void sched_resume_scheduler(FAR struct tcb_s *tcb); #else # define sched_resume_scheduler(tcb) @@ -879,6 +911,212 @@ void sched_suspend_scheduler(FAR struct tcb_s *tcb); # define sched_suspend_scheduler(tcb) #endif +/**************************************************************************** + * Name: nxsched_getparam + * + * Description: + * This function gets the scheduling priority of the task specified by + * pid. It is identical in function, differing only in its return value: + * This function does not modify the errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getparam(). + * + * Input Parameters: + * pid - the task ID of the task. If pid is zero, the priority + * of the calling task is returned. + * param - A structure whose member sched_priority is the integer + * priority. The task's priority is copied to the sched_priority + * element of this structure. + * + * Returned Value: + * 0 (OK) if successful, otherwise a negated errno value is returned to + * indicate the nature of the failure.. + * + * This function can fail if param is null (EINVAL) or if pid does + * not correspond to any task (ESRCH). + * + ****************************************************************************/ + +struct sched_param; /* Forward reference */ +int nxsched_getparam (pid_t pid, FAR struct sched_param *param); + +/**************************************************************************** + * Name: nxsched_setparam + * + * Description: + * This function sets the priority of a specified task. It is identical + * to the function sched_setparam(), differing only in its return value: + * This function does not modify the errno variable. + * + * NOTE: Setting a task's priority to the same value has a similar effect + * to sched_yield() -- The task will be moved to after all other tasks + * with the same priority. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_setparam(). + * + * Input Parameters: + * pid - the task ID of the task to reprioritize. If pid is zero, the + * priority of the calling task is changed. + * param - A structure whose member sched_priority is the integer priority. + * The range of valid priority numbers is from SCHED_PRIORITY_MIN + * through SCHED_PRIORITY_MAX. + * + * Returned Value: + * 0 (OK) if successful, otherwise a negated errno value is returned to + * indicate the nature of the failure.. + * + * EINVAL The parameter 'param' is invalid or does not make sense for the + * current scheduling policy. + * EPERM The calling task does not have appropriate privileges. + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +struct sched_param; /* Forward reference */ +int nxsched_setparam(pid_t pid, FAR const struct sched_param *param); + +/**************************************************************************** + * Name: nxsched_getscheduler + * + * Description: + * sched_getscheduler() returns the scheduling policy currently + * applied to the task identified by pid. If pid equals zero, the + * policy of the calling task will be retrieved. + * + * This functions is identical to the function sched_getscheduler(), + * differing only in its return value: This function does not modify + * the errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getscheduler(). + * + * Input Parameters: + * pid - the task ID of the task to query. If pid is zero, the + * calling task is queried. + * + * Returned Value: + * On success, sched_getscheduler() returns the policy for the task + * (either SCHED_FIFO or SCHED_RR). On error, a negated errno value + * returned: + * + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +int nxsched_getscheduler(pid_t pid); + +/**************************************************************************** + * Name: nxsched_setscheduler + * + * Description: + * nxsched_setscheduler() sets both the scheduling policy and the priority + * for the task identified by pid. If pid equals zero, the scheduler of + * the calling task will be set. The parameter 'param' holds the priority + * of the thread under the new policy. + * + * nxsched_setscheduler() is identical to the function sched_getparam(), + * differing only in its return value: This function does not modify the + * errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getparam(). + * + * Input Parameters: + * pid - the task ID of the task to modify. If pid is zero, the calling + * task is modified. + * policy - Scheduling policy requested (either SCHED_FIFO or SCHED_RR) + * param - A structure whose member sched_priority is the new priority. + * The range of valid priority numbers is from SCHED_PRIORITY_MIN + * through SCHED_PRIORITY_MAX. + * + * Returned Value: + * On success, nxsched_setscheduler() returns OK (zero). On error, a + * negated errno value is returned: + * + * EINVAL The scheduling policy is not one of the recognized policies. + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +int nxsched_setscheduler(pid_t pid, int policy, + FAR const struct sched_param *param); + +/**************************************************************************** + * Name: nxsched_getaffinity + * + * Description: + * nxsched_getaffinity() writes the affinity mask of the thread whose ID + * is pid into the cpu_set_t pointed to by mask. The cpusetsize + * argument specifies the size (in bytes) of mask. If pid is zero, then + * the mask of the calling thread is returned. + * + * nxsched_getaffinity() is identical to the function sched_getaffinity(), + * differing only in its return value: This function does not modify the + * errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getparam(). + * + * Input Parameters: + * pid - The ID of thread whose affinity set will be retrieved. + * cpusetsize - Size of mask. MUST be sizeofcpu_set_t(). + * mask - The location to return the thread's new affinity set. + * + * Returned Value: + * Zero (OK) if successful. Otherwise, a negated errno value is returned: + * + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +#ifdef CONFIG_SMP +int nxsched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask); +#endif + +/**************************************************************************** + * Name: nxsched_setaffinity + * + * Description: + * sched_setaffinity() sets the CPU affinity mask of the thread whose ID + * is pid to the value specified by mask. If pid is zero, then the + * calling thread is used. The argument cpusetsize is the length (i + * bytes) of the data pointed to by mask. Normally this argument would + * be specified as sizeof(cpu_set_t). + * + * If the thread specified by pid is not currently running on one of the + * CPUs specified in mask, then that thread is migrated to one of the + * CPUs specified in mask. + * + * nxsched_setaffinity() is identical to the function sched_setparam(), + * differing only in its return value: This function does not modify + * the errno variable. This is a non-standard, internal OS function and + * is not intended for use by application logic. Applications should + * use the standard sched_setparam(). + * + * Input Parameters: + * pid - The ID of thread whose affinity set will be modified. + * cpusetsize - Size of mask. MUST be sizeofcpu_set_t(). + * mask - The location to return the thread's new affinity set. + * + * Returned Value: + * Zero (OK) if successful. Otherwise, a negated errno value is returned: + * + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +#ifdef CONFIG_SMP +int nxsched_setaffinity(pid_t pid, size_t cpusetsize, + FAR const cpu_set_t *mask); +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/include/nuttx/semaphore.h b/include/nuttx/semaphore.h index 6e525f6e1c707ed79f01af7b324fb1e9bf1d1915..850e3c77189bc8bdef750a004c2b62f149ec48be 100644 --- a/include/nuttx/semaphore.h +++ b/include/nuttx/semaphore.h @@ -159,7 +159,7 @@ extern "C" * pshared - Process sharing (not used) * value - Semaphore initialization value * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -185,7 +185,7 @@ int nxsem_init(FAR sem_t *sem, int pshared, unsigned int value); * Parameters: * sem - Semaphore to be destroyed. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -211,7 +211,7 @@ int nxsem_destroy (FAR sem_t *sem); * Parameters: * sem - Semaphore descriptor. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -235,7 +235,7 @@ int nxsem_wait(FAR sem_t *sem); * Parameters: * sem - the semaphore descriptor * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -276,7 +276,7 @@ int nxsem_trywait(FAR sem_t *sem); * sem - Semaphore object * abstime - The absolute time to wait until a timeout is declared. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -313,7 +313,7 @@ int nxsem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime); * posted. If ticks is zero, then this function is equivalent * to sem_trywait(). * - * Return Value: + * Returned Value: * This is an internal OS interface, not available to applications, and * hence follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -342,7 +342,7 @@ int nxsem_tickwait(FAR sem_t *sem, systime_t start, uint32_t delay); * Parameters: * sem - Semaphore descriptor * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -373,7 +373,7 @@ int nxsem_post(FAR sem_t *sem); * sem - Semaphore descriptor * sval - Buffer by which the value is returned * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -395,7 +395,7 @@ int nxsem_getvalue(FAR sem_t *sem, FAR int *sval); * sem - Semaphore descriptor to be reset * count - The requested semaphore count * - * Return Value: + * Returned Value: * This is an internal OS interface, not available to applications, and * hence follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -416,7 +416,7 @@ int nxsem_reset(FAR sem_t *sem, int16_t count); * protocol - The user provided location in which to store the protocol * value. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -437,7 +437,7 @@ int nxsem_reset(FAR sem_t *sem, int16_t count); * protocol - The user provided location in which to store the protocol * value. * - * Return Value: + * Returned Value: * This function is exposed as a non-standard application interface. It * returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. @@ -476,7 +476,7 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol); * modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -515,7 +515,7 @@ int nxsem_setprotocol(FAR sem_t *sem, int protocol); * modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * This function is exposed as a non-standard application interface. It * returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. diff --git a/include/nuttx/sensors/ioctl.h b/include/nuttx/sensors/ioctl.h index 62d33b9f5299872a0db05e9fd4db2e3d2bb5e538..96ac4d5acec93663608d61105c57c7b96f42de07 100644 --- a/include/nuttx/sensors/ioctl.h +++ b/include/nuttx/sensors/ioctl.h @@ -118,10 +118,10 @@ /* IOCTL commands to the HTS221 & LPS25H */ #define SNIOC_CFGR _SNIOC(0x002a) +#define SNIOC_GET_DEV_ID _SNIOC(0x002b) /* IOCTL commands unique to the HTS221 */ -#define SNIOC_GET_DEV_ID _SNIOC(0x002b) #define SNIOC_START_CONVERSION _SNIOC(0x002c) #define SNIOC_CHECK_STATUS_REG _SNIOC(0x002d) #define SNIOC_READ_RAW_DATA _SNIOC(0x002e) @@ -130,19 +130,29 @@ /* IOCTL commands unique to the LPS25H */ -#define SNIOC_GET_DEV_ID _SNIOC(0x0031) -#define SNIOC_TEMPERATURE_OUT _SNIOC(0x0032) -#define SNIOC_PRESSURE_OUT _SNIOC(0x0033) -#define SNIOC_SENSOR_OFF _SNIOC(0x0034) +#define SNIOC_TEMPERATURE_OUT _SNIOC(0x0031) +#define SNIOC_PRESSURE_OUT _SNIOC(0x0032) +#define SNIOC_SENSOR_OFF _SNIOC(0x0033) /* IOCTL commands unique to the LIS2DH */ -#define SNIOC_WRITESETUP _SNIOC(0x0035) /* Arg: uint8_t value */ -#define SNIOC_WRITE_INT1THRESHOLD _SNIOC(0x0036) /* Arg: uint8_t value */ -#define SNIOC_WRITE_INT2THRESHOLD _SNIOC(0x0037) /* Arg: uint8_t value */ -#define SNIOC_RESET_HPFILTER _SNIOC(0x0038) /* Arg: uint8_t value */ -#define SNIOC_START_SELFTEST _SNIOC(0x0039) /* Arg: uint8_t value */ -#define SNIOC_WHO_AM_I _SNIOC(0x003a) -#define SNIOC_READ_TEMP _SNIOC(0x003b) /* Arg: int16_t value */ +#define SNIOC_WRITESETUP _SNIOC(0x0034) /* Arg: uint8_t value */ +#define SNIOC_WRITE_INT1THRESHOLD _SNIOC(0x0035) /* Arg: uint8_t value */ +#define SNIOC_WRITE_INT2THRESHOLD _SNIOC(0x0036) /* Arg: uint8_t value */ +#define SNIOC_RESET_HPFILTER _SNIOC(0x0037) /* Arg: uint8_t value */ +#define SNIOC_START_SELFTEST _SNIOC(0x0038) /* Arg: uint8_t value */ +#define SNIOC_WHO_AM_I _SNIOC(0x0039) +#define SNIOC_READ_TEMP _SNIOC(0x003a) /* Arg: int16_t value */ + +/* IOCTL commands unique to the MAX44009 */ + +#define SNIOC_INIT _SNIOC(0x003b) +#define SNIOC_THRESHOLD _SNIOC(0x003c) + +/* IOCTL commands unique to LIS3DH */ + +#define SNIOC_SET_POWER_MODE _SNIOC(0x003d) /* Arg: LIS3DH_POWER_xxx */ +#define SNIOC_SET_DATA_RATE _SNIOC(0x003e) /* Arg: LIS3DH_ODR_xxx */ +#define SNIOC_SET_DATA_FORMAT _SNIOC(0x003f) /* Arg: LIS3DH_FORMAT_xxx */ #endif /* __INCLUDE_NUTTX_SENSORS_IOCTL_H */ diff --git a/include/nuttx/sensors/lis3dh.h b/include/nuttx/sensors/lis3dh.h new file mode 100644 index 0000000000000000000000000000000000000000..849d7a72d35a6a712e6db151c1f8bcd1fecb5dcb --- /dev/null +++ b/include/nuttx/sensors/lis3dh.h @@ -0,0 +1,304 @@ +/**************************************************************************** + * include/nuttx/sensors/lis3dh.h + * + * Copyright (C) 2018 Extent3D. All rights reserved. + * Author: Matt Thompson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_SENSORS_LIS3DH_H +#define __INCLUDE_NUTTX_SENSORS_LIS3DH_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#if defined(CONFIG_SPI) && defined(CONFIG_LIS3DH) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LIS3DH Device Identification *********************************************/ + +#define LIS3DH_DEVICE_ID (0x33) + +/* LIS3DH Register Definitions **********************************************/ + +#define LIS3DH_STATUS_REG_AUX (0x07) +#define LIS3DH_OUT_ADC1_L (0x08) +#define LIS3DH_OUT_ADC1_H (0x09) +#define LIS3DH_OUT_ADC2_L (0x0A) +#define LIS3DH_OUT_ADC2_H (0x0B) +#define LIS3DH_OUT_ADC3_L (0x0C) +#define LIS3DH_OUT_ADC3_H (0x0D) +#define LIS3DH_WHO_AM_I (0x0F) +#define LIS3DH_CTRL_REG0 (0x1E) +#define LIS3DH_TEMP_CFG_REG (0x1F) +#define LIS3DH_CTRL_REG1 (0x20) +#define LIS3DH_CTRL_REG2 (0x21) +#define LIS3DH_CTRL_REG3 (0x22) +#define LIS3DH_CTRL_REG4 (0x23) +#define LIS3DH_CTRL_REG5 (0x24) +#define LIS3DH_CTRL_REG6 (0x25) +#define LIS3DH_REFERENCE (0x26) +#define LIS3DH_STATUS_REG (0x27) +#define LIS3DH_OUT_X_L (0x28) +#define LIS3DH_OUT_X_H (0x29) +#define LIS3DH_OUT_Y_L (0x2A) +#define LIS3DH_OUT_Y_H (0x2B) +#define LIS3DH_OUT_Z_L (0x2C) +#define LIS3DH_OUT_Z_H (0x2D) +#define LIS3DH_FIFO_CTRL_REG (0x2E) +#define LIS3DH_FIFO_SRC_REG (0x2F) +#define LIS3DH_INT1_CFG (0x30) +#define LIS3DH_INT1_SRC (0x31) +#define LIS3DH_INT1_THS (0x32) +#define LIS3DH_INT1_DURATION (0x33) +#define LIS3DH_INT2_CFG (0x34) +#define LIS3DH_INT2_SRC (0x35) +#define LIS3DH_INT2_THS (0x36) +#define LIS3DH_INT2_DURATION (0x37) +#define LIS3DH_CLICK_CFG (0x38) +#define LIS3DH_CLICK_SRC (0x39) +#define LIS3DH_CLICK_THS (0x3A) +#define LIS3DH_TIME_LIMIT (0x3B) +#define LIS3DH_TIME_LATENCY (0x3C) +#define LIS3DH_TIME_WINDOW (0x3D) +#define LIS3DH_ACT_THS (0x3E) +#define LIS3DH_ACT_DUR (0x3F) + +/* LIS3DH STATUS_REG_AUX Definitions **********************************************/ + +#define LIS3DH_STATUS_REG_AUX_321OR (1 << 7) +#define LIS3DH_STATUS_REG_AUX_3OR (1 << 6) +#define LIS3DH_STATUS_REG_AUX_2OR (1 << 5) +#define LIS3DH_STATUS_REG_AUX_1OR (1 << 4) +#define LIS3DH_STATUS_REG_AUX_321DA (1 << 3) +#define LIS3DH_STATUS_REG_AUX_3DA (1 << 2) +#define LIS3DH_STATUS_REG_AUX_2DA (1 << 1) +#define LIS3DH_STATUS_REG_AUX_1DA (1 << 0) + +/* LIS3DH CTRL_REG0 Definitions **********************************************/ + +#define LIS3DH_CTRL_REG0_SDO_PU_DISC (1 << 7) /* Disconnect SDO/SA0 pull-up */ + +/* LIS3DH TEMP_CFG_REG Definitions **********************************************/ + +#define LIS3DH_TEMP_CFG_REG_ADC_EN (1 << 7) /* ADC enable */ +#define LIS3DH_TEMP_CFG_REG_TEMP_EN (1 << 6) /* Temperator sensor enable */ + +/* LIS3DH CTRL_REG1 Definitions **********************************************/ + +#define LIS3DH_CTRL_REG1_ODR_SHIFT (4) +#define LIS3DH_CTRL_REG1_ODR_MASK (0xf << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR(n) ((n) << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_POWER_DOWN (0) +#define LIS3DH_CTRL_REG1_ODR_1HZ (0x1 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_10HZ (0x2 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_25HZ (0x3 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_50HZ (0x4 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_100HZ (0x5 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_200HZ (0x6 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_400HZ (0x7 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_LP_1600HZ (0x8 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_1344HZ (0x9 << LIS3DH_CTRL_REG1_ODR_SHIFT) +#define LIS3DH_CTRL_REG1_ODR_LP_5376HZ (0x9 << LIS3DH_CTRL_REG1_ODR_SHIFT) + +#define LIS3DH_CTRL_REG1_LPEN (1 << 3) /* Low-power mode enable */ +#define LIS3DH_CTRL_REG1_ZEN (1 << 2) /* Z axis enable */ +#define LIS3DH_CTRL_REG1_YEN (1 << 1) /* Y axis enable */ +#define LIS3DH_CTRL_REG1_XEN (1 << 0) /* X axis enable */ + +/* LIS3DH CTRL_REG2 Definitions **********************************************/ + +/* LIS3DH CTRL_REG3 Definitions **********************************************/ + +#define LIS3DH_CTRL_REG3_I1_CLICK (1 << 6) /* Click interrupt on INT1 */ +#define LIS3DH_CTRL_REG3_I1_IA1 (1 << 6) /* IA1 interrupt on INT1 */ +#define LIS3DH_CTRL_REG3_I1_IA2 (1 << 5) /* IA2 interrupt on INT1 */ +#define LIS3DH_CTRL_REG3_I1_ZYXDA (1 << 4) /* ZYX data available interrupt on INT1 */ +#define LIS3DH_CTRL_REG3_I1_321DA (1 << 3) /* 321 data available interrupt on INT1 */ +#define LIS3DH_CTRL_REG3_I1_WTM (1 << 2) /* FIFO watermark interrupt on INT1 */ +#define LIS3DH_CTRL_REG3_I1_OVERRUN (1 << 1) /* FIFO overrun interrupt on INT1 */ + +/* LIS3DH CTRL_REG4 Definitions **********************************************/ + +#define LIS3DH_CTRL_REG4_BDU (1 << 7) /* Block data update */ +#define LIS3DH_CTRL_REG4_BLE (1 << 6) /* Endian selection. 0: LSB first, 1: MSB first */ +#define LIS3DH_CTRL_REG4_FS_16G (3 << 4) /* 16g full scale range */ +#define LIS3DH_CTRL_REG4_FS_8G (2 << 4) /* 8g full scale range */ +#define LIS3DH_CTRL_REG4_FS_4G (1 << 4) /* 4g full scale range */ +#define LIS3DH_CTRL_REG4_FS_2G (0 << 4) /* 2g full scale range */ +#define LIS3DH_CTRL_REG4_HR (1 << 3) /* High resolution output enable */ +#define LIS3DH_CTRL_REG4_ST1 (2 << 1) /* Self test 1 */ +#define LIS3DH_CTRL_REG4_ST0 (1 << 1) /* Self test 0 */ +#define LIS3DH_CTRL_REG4_SIM (1 << 0) /* SPI serial interface mode selection (0: 4-wire, 1: 3-wire) */ + +/* LIS3DH CTRL_REG5 Definitions **********************************************/ + +#define LIS3DH_CTRL_REG5_BOOT (1 << 7) /* Reboot memory content */ +#define LIS3DH_CTRL_REG5_FIFO_EN (1 << 6) /* FIFO enable */ +#define LIS3DH_CTRL_REG5_LIR_INT1 (1 << 3) /* Latch interrupt request on INT1_SRC register */ +#define LIS3DH_CTRL_REG5_D4D_INT1 (1 << 2) /* 4D detection enable on INT1 */ +#define LIS3DH_CTRL_REG5_LIR_INT2 (1 << 1) /* Latch interrupt request on INT2_SRC register */ +#define LIS3DH_CTRL_REG5_D4D_INT2 (1 << 0) /* 4D detection enable on INT2 */ + +/* LIS3DH CTRL_REG6 Definitions **********************************************/ + +#define LIS3DH_CTRL_REG6_I2_CLICK (1 << 6) /* Click interrupt on INT2 */ +#define LIS3DH_CTRL_REG6_I2_IA1 (1 << 6) /* IA1 interrupt on INT2 */ +#define LIS3DH_CTRL_REG6_I2_IA2 (1 << 5) /* IA2 interrupt on INT2 */ +#define LIS3DH_CTRL_REG6_I2_BOOT (1 << 4) /* Enable boot on INT2 */ +#define LIS3DH_CTRL_REG6_I2_ACT (1 << 3) /* Enable activity interrupt on INT2 */ +#define LIS3DH_CTRL_REG6_INT_POLARITY (1 << 1) /* INT1 and INT2 pin polarity */ + +/* LIS3DH STATUS_REG Definitions **********************************************/ + +#define LIS3DH_STATUS_ZYXOR (1 << 7) /* X,Y,Z axis data overrun */ +#define LIS3DH_STATUS_ZOR (1 << 6) /* Z axis data overrun */ +#define LIS3DH_STATUS_YOR (1 << 5) /* Y axis data overrun */ +#define LIS3DH_STATUS_XOR (1 << 4) /* X axis data overrun */ +#define LIS3DH_STATUS_REG_ZYXDA (1 << 3) /* X,Y,Z axis data available */ +#define LIS3DH_STATUS_REG_ZDA (1 << 2) /* Z axis data available */ +#define LIS3DH_STATUS_REG_YDA (1 << 1) /* Y axis data available */ +#define LIS3DH_STATUS_REG_XDA (1 << 0) /* X axis data available */ + +/* LIS3DH FIFO_CTRL_REG Definitions **********************************************/ + +#define LIS3DH_FIFO_CTRL_REG_MODE_STREAM2 (3 << 6) +#define LIS3DH_FIFO_CTRL_REG_MODE_STREAM (2 << 6) +#define LIS3DH_FIFO_CTRL_REG_MODE_FIFO (1 << 6) +#define LIS3DH_FIFO_CTRL_REG_MODE_BYPASS (0 << 6) +#define LIS3DH_FIFO_CTRL_REG_TR (1 << 5) + +/* LIS3DH FIFO_SRC_REG Definitions **********************************************/ + +#define LIS3DH_FIFO_SRC_REG_WTM (1 << 7) +#define LIS3DH_FIFO_SRC_REG_OVRN_FIFO (1 << 6) +#define LIS3DH_FIFO_SRC_REG_EMPTY (1 << 5) + +/* SPI parameters ***************************************************************/ + +#define LIS3DH_SPI_FREQUENCY (9600000) /* SPI Clock Frequency */ +#define LIS3DH_SPI_MODE (SPIDEV_MODE3) /* Device uses SPI Mode 3: CPOL=1, CPHA=1 */ + +/* Power Modes ******************************************************************/ + +#define LIS3DH_POWER_LOW (0x0) /* Lower power 8bit output */ +#define LIS3DH_POWER_NORMAL (0x1) /* Normal 10bit */ +#define LIS3DH_POWER_HIGH (0x2) /* HR 12bit mode */ + +/* Output Data Rates ***********************************************************/ + +#define LIS3DH_ODR_POWER_DOWN (0) /* Disable output */ +#define LIS3DH_ODR_1HZ (0x1) /* 1Hz in all power modes */ +#define LIS3DH_ODR_10HZ (0x2) /* 10Hz in all power modes */ +#define LIS3DH_ODR_25HZ (0x3) /* 25Hz in all power modes */ +#define LIS3DH_ODR_50HZ (0x4) /* 50Hz in all power modes */ +#define LIS3DH_ODR_100HZ (0x5) /* 100Hz in all power modes */ +#define LIS3DH_ODR_200HZ (0x6) /* 200Hz in all power modes */ +#define LIS3DH_ODR_400HZ (0x7) /* 400Hz in all power modes */ +#define LIS3DH_ODR_LP_1600HZ (0x8) /* 1.6kHz in low power mode only */ +#define LIS3DH_ODR_1344HZ (0x9) /* 1.344kHz in normal and high power modes only */ +#define LIS3DH_ODR_LP_5376HZ (0x9) /* 5.376kHz in low power mode only */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct lis3dh_sensor_data_s +{ + float x_acc; /* X axis acceleration */ + float y_acc; /* Y axis acceleration */ + float z_acc; /* Z axis acceleration */ +}; + +/* Configuration structure used to register the driver */ + +struct lis3dh_config_s +{ + /* SPI device ID used to select the CS line of the sensor */ + + int spi_devid; + + /* IRQ number associated with this driver instance */ + + int irq; + + /* Attach callback used to configure the interrupt line */ + + int (*irq_attach)(FAR struct lis3dh_config_s *, xcpt_t, void *arg); + int (*irq_detach)(FAR struct lis3dh_config_s *); +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: lis3dh_register + * + * Description: + * Register the LIS3DH character device at the specified device path + * + * Input Parameters: + * devpath - Full path of device node to register ie "/dev/accel0" + * spi - SPI bus device instance + * config - Driver instance configuration structure + * + * Returned Value: + * OK on success or a negative errno value on failure. + * + ****************************************************************************/ + +int lis3dh_register(FAR const char *devpath, FAR struct spi_dev_s *spi, + FAR struct lis3dh_config_s *); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_SPI && CONFIG_LIS3DH */ +#endif /* __INCLUDE_NUTTX_SENSORS_LIS3DH_H */ diff --git a/include/nuttx/sensors/max44009.h b/include/nuttx/sensors/max44009.h new file mode 100644 index 0000000000000000000000000000000000000000..9cf1a2723bc60ef7d9affdb0ca1e2484644a0395 --- /dev/null +++ b/include/nuttx/sensors/max44009.h @@ -0,0 +1,118 @@ +/**************************************************************************** + * include/nuttx/sensors/max44009.h + * + * Copyright (C) 2014-2018 Haltian Ltd. All rights reserved. + * Authors: Dmitry Nikolaev + * Juha Niskanen + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_SENSORS_MAX44009 +#define __INCLUDE_NUTTX_SENSORS_MAX44009 + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct i2c_master_s; + +/* Integration time, ms */ + +enum max44009_integration_time_e +{ + MAX44009_INTEGR_TIME_800 = 0x0, /* Preferred mode for boosting + * low-light sensitivity */ + MAX44009_INTEGR_TIME_400, + MAX44009_INTEGR_TIME_200, + MAX44009_INTEGR_TIME_100, /* Preferred mode for high-brightness + * applications */ + MAX44009_INTEGR_TIME_50, /* Manual mode only */ + MAX44009_INTEGR_TIME_25, /* Manual mode only */ + MAX44009_INTEGR_TIME_12_5, /* Manual mode only */ + MAX44009_INTEGR_TIME_6_25 /* Manual mode only */ +}; + +/* Board configuration data structure */ + +struct max44009_config_s +{ + CODE int (*irq_attach)(FAR struct max44009_config_s * state, xcpt_t isr, FAR void *arg); + CODE void (*irq_enable)(FAR const struct max44009_config_s * state, bool enable); + CODE int (*set_power)(FAR const struct max44009_config_s * state, bool on); +}; + +/* Configuration structure for MAX44009 */ + +struct max44009_init_s +{ + bool is_cont; /* Needs more power, if it's in continuous + * mode. This one is useful in test-mode for + * instance */ + bool is_manual; /* Timer's settings must be specified manually */ + bool is_cdr; /* Current division ratio: false - All of the + * photodiode current goes to the ADC, true - + * 1/8 (must be used in high-brightness + * situations) */ + enum max44009_integration_time_e integr_time; /* Integration time */ +}; + +struct max44009_threshold_s +{ + uint8_t upper_threshold; /* Upper threshold high-byte */ + uint8_t lower_threshold; /* Lower threshold high-byte */ + uint8_t threshold_timer; /* 0 - interrupt will be triggered as soon as + * the light level exceeds either threshold */ +} ; + +/* Data transfer structure */ + +struct max44009_data_s +{ + uint32_t lux; /* Converted lux value */ + uint16_t mlux; /* Converted millilux (decimals for lux) */ + uint16_t raw_value; /* Raw unconverted value */ + uint8_t test_value; /* For self-test only */ +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int max44009_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, + uint8_t addr, FAR struct max44009_config_s *config); + +#endif /* __INCLUDE_NUTTX_SENSORS_MAX44009 */ diff --git a/include/nuttx/signal.h b/include/nuttx/signal.h index 0c9e4107129fd86adb8d16f672521fc5c4e1b94c..51a5dbe0e5f975b2cda6206116331a789a742203 100644 --- a/include/nuttx/signal.h +++ b/include/nuttx/signal.h @@ -127,7 +127,7 @@ struct timespec; /* Forward reference */ * set - Location of the new signal mask * oset - Location to store the old signal mask * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -160,7 +160,7 @@ int nxsig_procmask(int how, FAR const sigset_t *set, FAR sigset_t *oset); * signo - Signal number * value - Value to pass to task with signal * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -232,7 +232,7 @@ int nxsig_kill(pid_t pid, int signo); * set - The pending signal set * info - The returned value * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -270,7 +270,7 @@ int nxsig_kill(pid_t pid, int signo); * info - The returned value (may be NULL). * timeout - The amount of time to wait (may be NULL) * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. diff --git a/include/nuttx/spi/spi.h b/include/nuttx/spi/spi.h index 8f4ceb8762e9cce0e9c639db062179194fbe5a1d..05176cd2d7b2ac24d15b9f1978a6e39ed7808f78 100644 --- a/include/nuttx/spi/spi.h +++ b/include/nuttx/spi/spi.h @@ -70,8 +70,8 @@ * Name: SPI_LOCK * * Description: - * On SPI busses where there are multiple devices, it will be necessary to - * lock SPI to have exclusive access to the busses for a sequence of + * On SPI buses where there are multiple devices, it will be necessary to + * lock SPI to have exclusive access to the buses for a sequence of * transfers. The bus should be locked before the chip is selected. After * locking the SPI bus, the caller should then also call the setfrequency, * setbits, and setmode methods to make sure that the SPI is properly diff --git a/include/nuttx/spi/spi_bitbang.h b/include/nuttx/spi/spi_bitbang.h index 9f3a010671acd185305c14cdd489fe20b8aad7a3..228fbd6a500ba418aa184f3c21d0eb60548e7f84 100644 --- a/include/nuttx/spi/spi_bitbang.h +++ b/include/nuttx/spi/spi_bitbang.h @@ -129,7 +129,7 @@ extern "C" /**************************************************************************** * Name: spi_create_bitbang * - * Descripton: + * Description: * Create an instance of the SPI bit-bang driver. * * Input Parameters: diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index 3798e177ff5755ea7ba4878531391d9a3b420295..dc551e6d2b7c21454b208ac63c3334b6f66ec76a 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -122,7 +122,7 @@ struct spinlock_s * Description: * Perform an atomic test and set operation on the provided spinlock. * - * This function must be provided via the architecture-specific logoic. + * This function must be provided via the architecture-specific logic. * * Input Parameters: * lock - The address of spinlock object. @@ -197,6 +197,30 @@ void spin_initializer(FAR struct spinlock_s *lock); void spin_lock(FAR volatile spinlock_t *lock); +/**************************************************************************** + * Name: spin_lock_wo_note + * + * Description: + * If this CPU does not already hold the spinlock, then loop until the + * spinlock is successfully locked. + * + * This implementation is the same as the above spin_lock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to lock. + * + * Returned Value: + * None. When the function returns, the spinlock was successfully locked + * by this CPU. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_lock_wo_note(FAR volatile spinlock_t *lock); + /**************************************************************************** * Name: spin_trylock * @@ -268,6 +292,28 @@ void spin_unlock(FAR volatile spinlock_t *lock); # define spin_unlock(l) do { *(l) = SP_UNLOCKED; } while (0) #endif +/**************************************************************************** + * Name: spin_unlock_wo_note + * + * Description: + * Release one count on a non-reentrant spinlock. + * + * This implementation is the same as the above spin_unlock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to unlock. + * + * Returned Value: + * None. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_unlock_wo_note(FAR volatile spinlock_t *lock); + /**************************************************************************** * Name: spin_unlockr * diff --git a/include/nuttx/streams.h b/include/nuttx/streams.h index ccb7054f7fc4527adb7a8f639e4adc98299d10a4..d615c85609e555435d4ae91d01f3d01dec65b575 100644 --- a/include/nuttx/streams.h +++ b/include/nuttx/streams.h @@ -230,7 +230,7 @@ extern "C" * Seekable versions are defined in lib/stdio/lib_memsistream.c and * lib/stdio/lib_memsostream.c. * - * Input parameters: + * Input Parameters: * memstream - User allocated, uninitialized instance of struct * lib_meminstream_s to be initialized. * memstream - User allocated, uninitialized instance of struct @@ -259,7 +259,7 @@ void lib_memsostream(FAR struct lib_memsostream_s *outstream, * Initializes a stream for use with a FILE instance. * Defined in lib/stdio/lib_stdinstream.c and lib/stdio/lib_stdoutstream.c * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_stdinstream_s to be initialized. * outstream - User allocated, uninitialized instance of struct @@ -291,7 +291,7 @@ void lib_stdsostream(FAR struct lib_stdsostream_s *outstream, * Seekable versions are defined in lib/stdio/lib_rawsistream.c and * lib/stdio/lib_rawsostream.c * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_rawinstream_s to be initialized. * outstream - User allocated, uninitialized instance of struct @@ -316,7 +316,7 @@ void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd); * Initializes a stream for use with low-level, architecture-specific output. * Defined in ib/stdio/lib_lowoutstream.c * - * Input parameters: + * Input Parameters: * lowoutstream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * @@ -342,7 +342,7 @@ void lib_lowoutstream(FAR struct lib_outstream_s *lowoutstream); * o The stream created by lib_nulloutstream will write all data to the * bit-bucket. Defined in lib/stdio/lib_nulloutstream.c * - * Input parameters: + * Input Parameters: * zeroinstream - User allocated, uninitialized instance of struct * lib_instream_s to be initialized. * nullinstream - User allocated, uninitialized instance of struct @@ -366,7 +366,7 @@ void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream); * Initializes a stream for use with the configured syslog interface. * Only accessible from with the OS SYSLOG logic. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * @@ -383,7 +383,7 @@ void syslogstream_create(FAR struct lib_syslogstream_s *stream); * Description: * Free resources held by the syslog stream. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * @@ -405,7 +405,7 @@ void syslogstream_destroy(FAR struct lib_syslogstream_s *stream); * Initializes a stream for use with the configured emergency syslog * interface. Only accessible from with the OS SYSLOG logic. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * @@ -423,7 +423,7 @@ void emergstream(FAR struct lib_outstream_s *stream); * lib_noflush() provides a common, dummy flush method for output streams * that are not flushable. * - * Return: + * Returned Value: * Always returns OK * ****************************************************************************/ @@ -438,7 +438,7 @@ int lib_noflush(FAR struct lib_outstream_s *stream); * streams that are not flushable. * is selected. * - * Return: + * Returned Value: * Always returns OK * ****************************************************************************/ diff --git a/include/nuttx/syslog/syslog.h b/include/nuttx/syslog/syslog.h index bce437d7a76c2b43191491167c96fe329d1fe3f5..1ea41be2ef38139398ad003600cb0af48aefe0ed 100644 --- a/include/nuttx/syslog/syslog.h +++ b/include/nuttx/syslog/syslog.h @@ -149,7 +149,7 @@ extern "C" * Configure the SYSLOGging function to use the provided channel to * generate SYSLOG output. * - * Input buffer: + * Input Parameters: * channel - Provides the interface to the channel to be used. * * Returned Value: diff --git a/include/nuttx/time.h b/include/nuttx/time.h index 2a6c59697878e0b059714f4fa1822987875448ca..ee4705ba30792cd8b5818bfa5058f92637437ded 100644 --- a/include/nuttx/time.h +++ b/include/nuttx/time.h @@ -111,7 +111,7 @@ int clock_daysbeforemonth(int month, bool leapyear); * month - The month of the year 1 - 12 * year - the year including the 1900 * - * Returned value: + * Returned Value: * Zero based day of the week 0-6, 0 = Sunday, 1 = Monday... 6 = Saturday * ****************************************************************************/ diff --git a/include/nuttx/timers/timer.h b/include/nuttx/timers/timer.h index ab78f5ea977516a4de6b508bb61b689e8a6a89cb..db59e81819e077a7adbd834b938480637bcc98a5 100644 --- a/include/nuttx/timers/timer.h +++ b/include/nuttx/timers/timer.h @@ -225,7 +225,7 @@ extern "C" * Rather it is called indirectly through the architecture-specific * initialization. * - * Input parameters: + * Input Parameters: * dev path - The full path to the driver to be registers in the NuttX * pseudo-filesystem. The recommended convention is to name all timer * drivers as "/dev/timer0", "/dev/timer1", etc. where the driver @@ -250,7 +250,7 @@ FAR void *timer_register(FAR const char *path, * This function can be called to disable and unregister the timer * device driver. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was returned by timer_register() * * Returned Value: @@ -272,7 +272,7 @@ void timer_unregister(FAR void *handle); * to handle timer expirations. This is a strictly OS internal interface * and may NOT be used by appliction code. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was returned by timer_register() * callback - The new timer interrupt callback * arg - Argument provided when the callback is called. diff --git a/include/nuttx/timers/watchdog.h b/include/nuttx/timers/watchdog.h index 9c7d9001fa3ae25796de315e570fd2dd64fec7a9..4759556e81fc7c424e37b5995c77454f6cfe3c05 100644 --- a/include/nuttx/timers/watchdog.h +++ b/include/nuttx/timers/watchdog.h @@ -217,7 +217,7 @@ extern "C" * NOTE: This function would not be called by application code. Rather it is * called indirectly through the architecture-specific interfaces. * - * Input parameters: + * Input Parameters: * dev path - The full path to the driver to be registers in the NuttX * pseudo-filesystem. The recommended convention is to name all watchdog * drivers as "/dev/watchdog0", "/dev/watchdog1", etc. where the driver @@ -242,7 +242,7 @@ FAR void *watchdog_register(FAR const char *path, * This function can be called to disable and unregister the watchdog * device driver. * - * Input parameters: + * Input Parameters: * handle - This is the handle that was returned by watchdog_register() * * Returned Value: diff --git a/include/nuttx/usb/cdcacm.h b/include/nuttx/usb/cdcacm.h index d490adc0985d33ac32944ddb7a595e8004fb60f3..24109a98a0ab5eada14c6efc5770e36ef6647602 100644 --- a/include/nuttx/usb/cdcacm.h +++ b/include/nuttx/usb/cdcacm.h @@ -336,7 +336,7 @@ typedef FAR void (*cdcacm_callback_t)(enum cdcacm_event_e event); * Register USB serial port (and USB serial console if so configured) and * return the class object. * - * Input Parameter: + * Input Parameters: * minor - Device minor number. E.g., minor 0 would correspond to * /dev/ttyACM0. * classdev - The location to return the CDC serial class' device @@ -360,7 +360,7 @@ int cdcacm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo, * Description: * Register USB serial port (and USB serial console if so configured). * - * Input Parameter: + * Input Parameters: * minor - Device minor number. E.g., minor 0 would correspond to * /dev/ttyACM0. * handle - An optional opaque reference to the CDC/ACM class object that diff --git a/include/nuttx/usb/composite.h b/include/nuttx/usb/composite.h index 7d5f90c01d52072a166ca7c90d938dfd1c453985..38d0122fa46eb878e652c6993e206841ae99c196 100644 --- a/include/nuttx/usb/composite.h +++ b/include/nuttx/usb/composite.h @@ -88,7 +88,7 @@ extern "C" * board-specific implementations in order to obtain the class objects for * each of the members of the composite. * - * Input Parameter: + * Input Parameters: * None * * Returned Value: diff --git a/include/nuttx/usb/hid_parser.h b/include/nuttx/usb/hid_parser.h index 809a8fb0cadf135504af8a6c5cc802e6a7073897..08fd4b053c093f485225c419109fad61eb729c55 100644 --- a/include/nuttx/usb/hid_parser.h +++ b/include/nuttx/usb/hid_parser.h @@ -227,7 +227,7 @@ struct hid_rptinfo_s * Input Parameters: * item Pointer to the current report item for user checking. * - * Returned value: + * Returned Value: * Boolean true if the item should be stored into the struct hid_rptinfo_s * structure, false if it should be ignored. */ @@ -283,7 +283,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen, * report. If the given item does not exist in the report, the function * does not modify the report item's data. * - * Input Parameters + * Input Parameters: * report Buffer containing an IN or FEATURE report from an attached * device. * item Pointer to the report item of interest in a struct hid_rptinfo_s @@ -330,7 +330,7 @@ void hid_putitem(FAR uint8_t *report, FAR struct hid_rptitem_s *item); * Description: * Retrieves the size of a given HID report in bytes from it's Report ID. * - * InputParameters: + * Input Parameters: * rptinfo Pointer to a struct hid_rptinfo_s instance containing the parser * output. * id Report ID of the report whose size is to be retrieved. diff --git a/include/nuttx/usb/usbhost.h b/include/nuttx/usb/usbhost.h index 7f95b1d5b3770d00bb0517ddf342b00320bc1db6..9dc98450da95bb09746cac3cf3a64ba4e6653488 100644 --- a/include/nuttx/usb/usbhost.h +++ b/include/nuttx/usb/usbhost.h @@ -91,7 +91,7 @@ * id - In the case where the device supports multiple base classes, subclasses, or * protocols, this specifies which to configure for. * - * Returned Values: + * Returned Value: * On success, this function will return a non-NULL instance of struct * usbhost_class_s that can be used by the USB host driver to communicate with the * USB host class. NULL is returned on failure; this function will fail only if @@ -121,7 +121,7 @@ * configdesc - A pointer to a uint8_t buffer container the configuration descriptor. * desclen - The length in bytes of the configuration descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -152,7 +152,7 @@ * Input Parameters: * devclass - The USB host class entry previously obtained from a call to create(). * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -175,7 +175,7 @@ * hport - The location to return the hub port descriptor that detected the * connection related event. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success when a device in connected or * disconnected. This function will not return until either (1) a device is * connected or disconnect to/from any hub port or until (2) some failure @@ -209,7 +209,7 @@ * hport - The descriptor of the hub port that has the newly connected * device. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -238,7 +238,7 @@ * mps (maxpacketsize) - The maximum number of bytes that can be sent to or * received from the endpoint in a single data packet * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -262,7 +262,7 @@ * devinfo - A pointer to memory provided by the caller in which to return the * device information. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -286,7 +286,7 @@ * ep - A memory location provided by the caller in which to receive the * allocated endpoint descriptor. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -308,7 +308,7 @@ * the class create() method. * ep - The endpoint to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -341,7 +341,7 @@ * maxlen - The address of a memory location provided by the caller in which to * return the maximum size of the allocated buffer memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -366,7 +366,7 @@ * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -395,7 +395,7 @@ * return the allocated buffer memory address. * buflen - The size of the buffer required. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -420,7 +420,7 @@ * the class create() method. * buffer - The address of the allocated buffer memory to be freed. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -456,7 +456,7 @@ * NOTE: On an IN transaction, req and buffer may refer to the same allocated * memory. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * @@ -489,7 +489,7 @@ * (IN endpoint). buffer must have been allocated using DRVR_ALLOC * buflen - The length of the data to be sent or received. * - * Returned Values: + * Returned Value: * On success, a non-negative value is returned that indicates the number * of bytes successfully transferred. On a failure, a negated errno value is * returned that indicates the nature of the failure: @@ -534,7 +534,7 @@ * arg - The arbitrary parameter that will be passed to the callback function * when the transfer completes. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -561,7 +561,7 @@ * ep - The IN or OUT endpoint descriptor for the device endpoint on which an * asynchronous transfer should be transferred. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -584,7 +584,7 @@ * related event * connected - True: device connected; false: device disconnected * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure. * @@ -611,7 +611,7 @@ * hport - The port from which the device is being disconnected. Might be a port * on a hub. * - * Returned Values: + * Returned Value: * None * * Assumptions: @@ -949,7 +949,7 @@ extern "C" * devclass - An write-able instance of struct usbhost_registry_s that will be * maintained in a registry. * - * Returned Values: + * Returned Value: * On success, this function will return zero (OK). Otherwise, a negated errno * value is returned. * @@ -969,7 +969,7 @@ int usbhost_registerclass(struct usbhost_registry_s *devclass); * Input Parameters: * id - Identifies the USB device class that has connect to the USB host. * - * Returned Values: + * Returned Value: * On success this function will return a non-NULL instance of struct * usbhost_registry_s. NULL will be returned on failure. This function can only * fail if (1) id is NULL, or (2) no USB host class is registered that matches the @@ -991,7 +991,7 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * @@ -1012,7 +1012,7 @@ int usbhost_hub_initialize(void); * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * @@ -1054,7 +1054,7 @@ int usbhost_cdcacm_initialize(void); * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * @@ -1075,7 +1075,7 @@ int usbhost_kbdinit(void); * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * @@ -1096,7 +1096,7 @@ int usbhost_mouse_init(void); * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * @@ -1116,7 +1116,7 @@ int usbhost_xboxcontroller_init(void); * Input Parameters: * None * - * Returned Values: + * Returned Value: * On success this function will return zero (OK); A negated errno value * will be returned on failure. * @@ -1147,7 +1147,7 @@ int usbhost_wlaninit(void); * and bound to the hub, the allocated class instance is returned into * this caller-provided memory location. * - * Returned Values: + * Returned Value: * On success, zero (OK) is returned. On a failure, a negated errno value is * returned indicating the nature of the failure * diff --git a/include/nuttx/usb/usbmonitor.h b/include/nuttx/usb/usbmonitor.h index d5be243e0546592ab653206ec753c48dbbce74af..fe360c0cc23662b3c05c577b0455e7506b5d1912 100644 --- a/include/nuttx/usb/usbmonitor.h +++ b/include/nuttx/usb/usbmonitor.h @@ -72,7 +72,7 @@ extern "C" * Input Parameters: * None * - * Returned values: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is return on * any failure. * diff --git a/include/nuttx/userspace.h b/include/nuttx/userspace.h index 6e1afc2aa1514e1a47255ff59adebe0360610c9d..b7bb1cf65c4c9353fadf6ba951e2db9368f44be9 100644 --- a/include/nuttx/userspace.h +++ b/include/nuttx/userspace.h @@ -157,11 +157,11 @@ extern "C" * This function is the user-space, task startup function. It is called * from up_task_start() in user-mode. * - * Inputs: + * Input Parameters: * entrypt - The user-space address of the task entry point * argc and argv - Standard arguments for the task entry point * - * Return: + * Returned Value: * None. This function does not return. * ****************************************************************************/ @@ -177,11 +177,11 @@ void task_startup(main_t entrypt, int argc, FAR char *argv[]) noreturn_function; * This function is the user-space, pthread startup function. It is called * from up_pthread_start() in user-mode. * - * Inputs: + * Input Parameters: * entrypt - The user-space address of the pthread entry point * arg - Standard argument for the pthread entry point * - * Return: + * Returned Value: * None. This function does not return. * ****************************************************************************/ diff --git a/include/nuttx/video/fb.h b/include/nuttx/video/fb.h index 4d6c7f1d49a1228c64cd53d6ba01a4dd232dbf4c..83857ebc83de9aaf53256738b17711b360e3976d 100644 --- a/include/nuttx/video/fb.h +++ b/include/nuttx/video/fb.h @@ -410,7 +410,7 @@ extern "C" * Description: * Initialize the framebuffer video hardware associated with the display. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * @@ -429,7 +429,7 @@ int up_fbinitialize(int display); * Return a a reference to the framebuffer object for the specified video * plane of the specified plane. Many OSDs support multiple planes of video. * - * Input parameters: + * Input Parameters: * display - In the case of hardware with multiple displays, this * specifies the display. Normally this is zero. * vplane - Identifies the plane being queried. diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h index 7aacca711c71a38c45c669ad935fee741bc49698..a57d50e6ae45e72f996564341bebb8077d30f7a1 100644 --- a/include/nuttx/wdog.h +++ b/include/nuttx/wdog.h @@ -1,7 +1,8 @@ /**************************************************************************** * include/nuttx/wdog.h * - * Copyright (C) 2007-2009, 2014-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014-2015, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -175,7 +176,7 @@ extern "C" * Parameters: * None * - * Return Value: + * Returned Value: * Pointer to watchdog (i.e., the watchdog ID), or NULL if insufficient * watchdogs are available. * @@ -195,8 +196,9 @@ WDOG_ID wd_create(void); * wdog - The watchdog ID to delete. This is actually a pointer to a * watchdog structure. * - * Return Value: - * Returns OK or ERROR + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is return to + * indicate the nature of any failure. * * Assumptions: * The caller has assured that the watchdog is no longer in use. @@ -229,8 +231,9 @@ int wd_delete(WDOG_ID wdog); * wdentry - function to call on timeout * parm1..4 - parameters to pass to wdentry * - * Return Value: - * OK or ERROR + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is return to + * indicate the nature of any failure. * * Assumptions: * The watchdog routine runs in the context of the timer interrupt handler @@ -250,7 +253,7 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...); * Parameters: * wdog - ID of the watchdog to cancel. * - * Return Value: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned to * indicate the nature of any failure. * @@ -268,7 +271,7 @@ int wd_cancel(WDOG_ID wdog); * Parameters: * wdog - watchdog ID * - * Return Value: + * Returned Value: * The time in system ticks remaining until the watchdog time expires. * Zero means either that wdog is not valid or that the wdog has already * expired. diff --git a/include/nuttx/wireless/cc3000/evnt_handler.h b/include/nuttx/wireless/cc3000/evnt_handler.h index fe5f4ecdad024d1a9580fb12dfa464941e9bbab4..a720a04de9915658543d68b22722265d9e7e6e76 100644 --- a/include/nuttx/wireless/cc3000/evnt_handler.h +++ b/include/nuttx/wireless/cc3000/evnt_handler.h @@ -131,7 +131,7 @@ extern unsigned long socket_active_status; * from from information (in case of data received) * fromlen from information length (in case of data received) * - * Returned Values: + * Returned Value: * None * ****************************************************************************/ @@ -147,7 +147,7 @@ uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen); * Input Parameters: * event_hdr event header * - * Returned Values: + * Returned Value: * 1 if event supported and handled; 0 if event is not supported * ****************************************************************************/ @@ -164,7 +164,7 @@ long hci_unsol_event_handler(char *event_hdr); * Input Parameters: * None * - * Returned Values: + * Returned Value: * ESUCCESS if successful, EFAIL if an error occurred * ****************************************************************************/ diff --git a/include/nuttx/wireless/cc3000/wlan.h b/include/nuttx/wireless/cc3000/wlan.h index b0a07c67d83813a5b5244f7dada0ebec330de5ac..70f2601ab34951aaa3cb53231c579fb8f088611f 100644 --- a/include/nuttx/wireless/cc3000/wlan.h +++ b/include/nuttx/wireless/cc3000/wlan.h @@ -499,7 +499,7 @@ long wlan_smart_config_set_prefix(char* cNewPrefix); * Input Parameters: * key AES128 key of size 16 bytes * - * Returned Value + * Returned Value: * On success 0, error otherwise. * ****************************************************************************/ @@ -516,7 +516,7 @@ signed long aes_read_key(FAR uint8_t *key); * Input Parameters: * key AES128 key of size 16 bytes * - * Returned Value + * Returned Value: * On success 0, error otherwise. * ****************************************************************************/ diff --git a/include/nuttx/wireless/ieee802154/ieee802154_mac.h b/include/nuttx/wireless/ieee802154/ieee802154_mac.h index 10647638485c002b28141166955db258df7b7038..398134b696acb73f4a619d0839fc9a796642d651 100644 --- a/include/nuttx/wireless/ieee802154/ieee802154_mac.h +++ b/include/nuttx/wireless/ieee802154/ieee802154_mac.h @@ -1783,7 +1783,7 @@ MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev); * minor - The device minor number. The IEEE802.15.4 MAC character device * will be registered as /dev/ieeeN where N is the minor number * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * @@ -1801,7 +1801,7 @@ int mac802154dev_register(MACHANDLE mac, int minor); * Input Parameters: * mac - Pointer to the mac layer struct to be registered. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * @@ -1819,10 +1819,10 @@ int mac802154netdev_register(MACHANDLE mac); * be called early in the initialization sequence before any radios * begin operation. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -1845,10 +1845,10 @@ void ieee802154_primitivepool_initialize(void); * list. If that the list is empty, then the primitive structure will be * allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * A reference to the allocated primitive structure. All user fields in this * structure have been zeroed. On a failure to allocate, NULL is * returned. @@ -1865,10 +1865,10 @@ FAR struct ieee802154_primitive_s *ieee802154_primitive_allocate(void); * the free pool if it was a pre-allocated primitive structure. If the primitive * was allocated dynamically it will be deallocated. * - * Inputs: + * Input Parameters: * prim - primitive structure to free * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/include/nuttx/wireless/nrf24l01.h b/include/nuttx/wireless/nrf24l01.h index 123eb935036d404a381bd150406e2b6470d5229d..7cff670dc1025fdbe8cb5610dfdca2009d83e9af 100644 --- a/include/nuttx/wireless/nrf24l01.h +++ b/include/nuttx/wireless/nrf24l01.h @@ -196,7 +196,7 @@ struct nrf24l01_config_s /************************************************************************************ * Register the nRF24L01+ device. * - * Input Parmeters: + * Input Parameters: * spi - SPI Device structure * cfg Board specific configuration info * @@ -214,7 +214,7 @@ int nrf24l01_register(FAR struct spi_dev_s *spi, FAR struct nrf24l01_config_s *c /************************************************************************************ * Initialize the nRF24L01+ chip to a default initial state. * - * Input Parmeters: + * Input Parameters: * dev Pointer to a registered nRF24L01 device structure * ************************************************************************************/ @@ -224,7 +224,7 @@ int nrf24l01_init(FAR struct nrf24l01_dev_s *dev); /************************************************************************************ * Set the default TX address. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * addr TX address (LSByte first) * @@ -238,7 +238,7 @@ int nrf24l01_settxaddr(FAR struct nrf24l01_dev_s *dev, FAR const uint8_t *addr); /************************************************************************************ * Get the default TX address. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * addr TX address (LSByte first) * @@ -252,7 +252,7 @@ int nrf24l01_gettxaddr(FAR struct nrf24l01_dev_s *dev, FAR uint8_t *addr); /************************************************************************************ * Configure auto-retransmit * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * retrdelay Auto-retransmit delay * retrcount Auto-retransmit count (0 - 15) @@ -268,7 +268,7 @@ int nrf24l01_setretransmit(FAR struct nrf24l01_dev_s *dev, /************************************************************************************ * Configure a RX pipe. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * pipeno Pipe number to configure * pipecfg Pointer to configuration data @@ -284,7 +284,7 @@ int nrf24l01_setpipeconfig(FAR struct nrf24l01_dev_s *dev, unsigned int pipeno, /************************************************************************************ * Get pipe configuration. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * pipeno Pipe number to configure * pipecfg Pointer to configuration data used to store the config @@ -300,7 +300,7 @@ int nrf24l01_getpipeconfig(FAR struct nrf24l01_dev_s *dev, unsigned int pipeno, /************************************************************************************ * Enable a RX pipe. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * pipeno Pipe number * enable true to enable the pipe, false to disable it @@ -316,7 +316,7 @@ int nrf24l01_enablepipe(FAR struct nrf24l01_dev_s *dev, unsigned int pipeno, /************************************************************************************ * Configure RF. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * datarate Datarate * outpower Output power @@ -334,7 +334,7 @@ int nrf24l01_setuprf(FAR struct nrf24l01_dev_s *dev, nrf24l01_datarate_t datarat * * Note that hardware supports only -18, -12, -6 and 0 dBm values. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * outpower Output power (in dBm). * @@ -350,7 +350,7 @@ int nrf24l01_settxpower(FAR struct nrf24l01_dev_s *dev, int outpower); * * Note that hardware supports only -18, -12, -6 and 0 dBm values. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * * Returned Value: @@ -363,7 +363,7 @@ int nrf24l01_gettxpower(FAR struct nrf24l01_dev_s *dev); /************************************************************************************ * Set transmission data rate * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * * Returned Value: @@ -377,7 +377,7 @@ int nrf24l01_setdatarate(FAR struct nrf24l01_dev_s *dev, /************************************************************************************ * Set radio frequency. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * freq New frequency value (in Mhz: 2400 to 2525) * @@ -391,7 +391,7 @@ int nrf24l01_setradiofreq(FAR struct nrf24l01_dev_s *dev, uint32_t freq); /************************************************************************************ * Get current radio frequency. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * * Returned Value: @@ -404,7 +404,7 @@ uint32_t nrf24l01_getradiofreq(FAR struct nrf24l01_dev_s *dev); /************************************************************************************ * Configure address length. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * width Address width to use (3-5) * @@ -418,7 +418,7 @@ int nrf24l01_setaddrwidth(FAR struct nrf24l01_dev_s *dev, uint32_t width); /************************************************************************************ * Change the current lifecycle state of the nRF24L01+ chip. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * state New state to put the nRF24L01 module into * @@ -429,7 +429,7 @@ int nrf24l01_changestate(FAR struct nrf24l01_dev_s *dev, nrf24l01_state_t state) /************************************************************************************ * Send data to the default address. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * data Pointer on the data buffer * datalen Length of the buffer (in bytes) @@ -444,7 +444,7 @@ int nrf24l01_send(FAR struct nrf24l01_dev_s *dev, FAR const uint8_t *data, /************************************************************************************ * Send data to the specified address. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * data Pointer on the data buffer * datalen Length of the buffer (in bytes) @@ -461,7 +461,7 @@ int nrf24l01_sendto(FAR struct nrf24l01_dev_s *dev, FAR const uint8_t *data, * Get the retransmits count of the last transmission. * This value is meaningful only if auto-acknowledge is enabled. * - * Input Parmeters: + * Input Parameters: * dev Pointer to an nRF24L01 device structure * * Returned Value: diff --git a/include/nuttx/wireless/pktradio.h b/include/nuttx/wireless/pktradio.h index d4f405b4142c685cad0ff1bb602ce7faaf3de98c..829de17909d6950a174e5a05dca12a1ed56e5bdb 100644 --- a/include/nuttx/wireless/pktradio.h +++ b/include/nuttx/wireless/pktradio.h @@ -181,10 +181,10 @@ struct pktradio_metadata_s * called. Therefore, it may be called during packet radio driver * initialization, even if there are multiple packet radio drivers. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -202,10 +202,10 @@ void pktradio_metadata_initialize(void); * list. If that the list is empty, then the meta-data structure will be * allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * A reference to the allocated metadata structure. All user fields in this * structure have been zeroed. On a failure to allocate, NULL is * returned. @@ -223,10 +223,10 @@ FAR struct pktradio_metadata_s *pktradio_metadata_allocate(void); * structure. If the metadata structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * metadata - metadata structure to free * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/include/nuttx/wqueue.h b/include/nuttx/wqueue.h index b5ee23e022ae2888814a824e09ffdf9701d890db..8fe684a9a5cfd45d7fc36b5057ffb89184e4b5c6 100644 --- a/include/nuttx/wqueue.h +++ b/include/nuttx/wqueue.h @@ -318,7 +318,7 @@ extern "C" * Description: * Start the user mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -345,7 +345,7 @@ int work_usrstart(void); * previous work as been performed and removed from the queue, then any * pending work will be canceled and lost. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked @@ -371,7 +371,7 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker, * After work has been cancelled, it may be re-queue by calling work_queue() * again. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * work - The previously queue work structure to cancel * @@ -393,7 +393,7 @@ int work_cancel(int qid, FAR struct work_s *work); * is used internally by the work logic but could also be used by the * user to force an immediate re-assessment of pending work. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * * Returned Value: @@ -409,7 +409,7 @@ int work_signal(int qid); * Description: * Check if the work structure is available. * - * Input parameters: + * Input Parameters: * work - The work queue structure to check. * None * @@ -431,7 +431,7 @@ int work_signal(int qid); * Parameters: * reqprio - Requested minimum worker thread priority * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -453,7 +453,7 @@ void lpwork_boostpriority(uint8_t reqprio); * reqprio - Previously requested minimum worker thread priority to be * "unboosted" * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index d059b9f8283173ffb7acf5ddb4ea787e2532e94a..907fbd66067422382f9a028f6cf5207ae6dfd211 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/sys/boardctl.h * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -114,18 +114,6 @@ * ARG: None * CONFIGURATION: CONFIG_NX * DEPENDENCIES: Base graphics logic provides nx_start() - * - * CMD: BOARDIOC_TSCTEST_SETUP - * DESCRIPTION: Touchscreen controller test configuration - * ARG: Touch controller device minor number - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_setup() - * - * CMD: BOARDIOC_TSCTEST_TEARDOWN - * DESCRIPTION: Touchscreen controller test configuration - * ARG: None - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_teardown() */ #define BOARDIOC_INIT _BOARDIOC(0x0001) @@ -136,8 +124,6 @@ #define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0006) #define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0007) #define BOARDIOC_NX_START _BOARDIOC(0x0008) -#define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0009) -#define BOARDIOC_TSCTEST_TEARDOWN _BOARDIOC(0x000a) /* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support. * In this case, all commands not recognized by boardctl() will be forwarded @@ -146,7 +132,7 @@ * User defined board commands may begin with this value: */ -#define BOARDIOC_USER _BOARDIOC(0x000b) +#define BOARDIOC_USER _BOARDIOC(0x0009) /**************************************************************************** * Public Type Definitions diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h index cc697c040a3be115e88c5945fee1b9b1aaa091cf..d8da7a121b237d3fc4ebe6c317cb877110a9ef3a 100644 --- a/include/sys/ioctl.h +++ b/include/sys/ioctl.h @@ -110,7 +110,7 @@ extern "C" * arg The argument of the ioctl cmd, OR * ... A third argument of type unsigned long is still expected. * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * -1 on failure with errno set properly: * diff --git a/include/sys/sendfile.h b/include/sys/sendfile.h index 22cb8271ef6521c34b150f3b6d10d9eb5a54ba9f..c414532671e7ebd6ef443f636ff13efda3aac3c1 100644 --- a/include/sys/sendfile.h +++ b/include/sys/sendfile.h @@ -87,7 +87,7 @@ extern "C" * different semantics and prototypes. sendfile() should not be used * in portable programs. * - * Input Parmeters: + * Input Parameters: * infd - A file (or socket) descriptor opened for reading * outfd - A descriptor opened for writing. * offset - If 'offset' is not NULL, then it points to a variable diff --git a/include/sys/time.h b/include/sys/time.h index ece75bc10fc14c6150b1ae99d7b343fd3735086f..36ba9822be012128f3f32019993ad942f9a9c7c3 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -160,7 +160,7 @@ extern "C" * tv - The location to return the current time * tz - Ignored * - * Returned value: + * Returned Value: * Zero (OK) on success; -1 is returned on failure with the errno variable * set appropriately. * @@ -183,7 +183,7 @@ int gettimeofday(FAR struct timeval *tv, FAR struct timezone *tz); * tv - The net to time to be set * tz - Ignored * - * Returned value: + * Returned Value: * Zero (OK) on success; -1 is returned on failure with the errno variable * set appropriately. * diff --git a/include/termios.h b/include/termios.h index 8427cbf5991cf1462845ef15a5e7809d54b9ac8a..10e88d7e0008f58e3ec7c0cde5e30a1a76115ef3 100644 --- a/include/termios.h +++ b/include/termios.h @@ -58,7 +58,8 @@ #define INLCR (1 << 5) /* Bit 5: Map NL to CR on input */ #define INPCK (1 << 6) /* Bit 6: Enable input parity check */ #define ISTRIP (1 << 7) /* Bit 7: Strip character */ -#define IUCLC (1 << 8) /* Bit 8: Map upper-case to lower-case on input (LEGACY) */ +#define IUCLC (1 << 8) /* Bit 8: Map upper-case to lower-case on input + * (LEGACY) */ #define IXANY (1 << 9) /* Bit 9: Enable any character to restart output */ #define IXOFF (1 << 10) /* Bit 10: Enable start/stop input control */ #define IXON (1 << 11) /* Bit 11: Enable start/stop output control */ @@ -67,7 +68,8 @@ /* Terminal output modes (c_oflag in the termios structure) */ #define OPOST (1 << 0) /* Bit 0: Post-process output */ -#define OLCUC (1 << 1) /* Bit 1: Map lower-case to upper-case on output (LEGACY) */ +#define OLCUC (1 << 1) /* Bit 1: Map lower-case to upper-case on +* * output (LEGACY) */ #define ONLCR (1 << 2) /* Bit 2: Map NL to CR-NL on output */ #define OCRNL (1 << 3) /* Bit 3: Map CR to NL on output */ #define ONOCR (1 << 4) /* Bit 4: No CR output at column 0 */ @@ -116,22 +118,47 @@ /* Local Modes (c_lflag in the termios structure) */ #define ECHO (1 << 0) /* Bit 0: Enable echo */ -#define ECHOE (1 << 1) /* Bit 1: Echo erase character as error-correcting backspace */ +#define ECHOE (1 << 1) /* Bit 1: Echo erase character as error- + * correcting backspace */ #define ECHOK (1 << 2) /* Bit 2: Echo KILL */ #define ECHONL (1 << 3) /* Bit 3: Echo NL */ -#define ICANON (1 << 4) /* Bit 4: Canonical input (erase and kill processing) */ -#define IEXTEN (1 << 5) /* Bit 5: Enable extended input character processing */ +#define ICANON (1 << 4) /* Bit 4: Canonical input (erase and kill + * processing) */ +#define IEXTEN (1 << 5) /* Bit 5: Enable extended input character + * processing */ #define ISIG (1 << 6) /* Bit 6: Enable signals */ #define NOFLSH (1 << 7) /* Bit 7: Disable flush after interrupt or quit */ #define TOSTOP (1 << 8) /* Bit 8: Send SIGTTOU for background output */ -#define XCASE (1 << 9) /* Bit 9: Canonical upper/lower presentation (LEGACY) */ +#define XCASE (1 << 9) /* Bit 9: Canonical upper/lower presentation + * (LEGACY) */ -/* The following are subscript names for the termios c_cc array */ +/* The following are subscript names for the termios c_cc array. + * + * Common characters: VINTR, VQUIT, VSTART, VSTOP, VSUSP + * + * VINTR: Interrupt character (Default ETX, Control-C) + * VQUIT: Quit character (Default FS, Control-\) + * VSTART: Start character (Default DC1, Control-Q) + * VSTOP: Stop character (Default DC3, Control-S) + * VSUSP: Suspend character (Default SUB, Control-Z) + * + * Canonical mode: Adds VEOF, VEOL, VERASE, VKILL + * + * VEOL: End-of-file character (Default SUB, Control-Z) + * VEOF: End-of-line character (Default NUL) + * VERASE: Erase character (Default DEL or BS, Control-H) + * VKILL: Kill character (Default NAK or BS, Control-U) + * + * Non-canonical mode: Adds VMIN, VTIME + * + * VMIN: Minimum number of characters for non-canonical read + * VTIME: Timeout in deciseconds for non-canonical read + */ #define VEOF 0 /* Bit 0: EOF character (canonical mode) */ -#define VMIN VEOF /* Bit 0: MIN value (Non-canonical mode) */ +#define VMIN VEOF /* Bit 0: MIN value (non-canonical mode) */ #define VEOL 1 /* Bit 1: EOL character (canonical mode) */ -#define VTIME VEOL /* Bit 1: TIME value (Non-canonical mode) */ +#define VTIME VEOL /* Bit 1: TIME value (non-canonical mode) */ #define VERASE 2 /* Bit 2: ERASE character (canonical mode) */ #define VINTR 3 /* Bit 3: INTR character */ #define VKILL 4 /* Bit 4: KILL character (canonical mode) */ @@ -139,11 +166,13 @@ #define VSTART 6 /* Bit 6: START character */ #define VSTOP 7 /* Bit 7: STOP character */ #define VSUSP 8 /* Bit 8: SUSP character */ -#define NCCS 9 /* Bit 9: Size of the array c_cc for control characters */ +#define NCCS 9 /* Bit 9: Size of the array c_cc for control + * characters */ -/* Baud Rate Selection. These are instances of type speed_t. Values of 38400 - * and below are specified by POSIX; values above 38400 are sometimes referred - * to as extended values and most values appear in most termios.h implementations. +/* Baud Rate Selection. These are instances of type speed_t. Values of + * 38400 and below are specified by POSIX; values above 38400 are sometimes + * referred to as extended values and most values appear in most termios.h + * implementations. * * NOTE that is NuttX that the encoding of the speed_t values is simply the * value of the baud itself. So this opens a window for non-portable abuse @@ -188,18 +217,23 @@ #define TCSANOW 0 /* Change attributes immediately */ #define TCSADRAIN 1 /* Change attributes when output has drained */ -#define TCSAFLUSH 2 /* Change attributes when output has drained; also flush pending input */ +#define TCSAFLUSH 2 /* Change attributes when output has drained; + * also flush pending input */ /* Line Control (used with tcflush()) */ -#define TCIFLUSH 0 /* Flush pending input. Flush untransmitted output */ -#define TCIOFLUSH 1 /* Flush both pending input and untransmitted output */ +#define TCIFLUSH 0 /* Flush pending input. Flush untransmitted + * output */ +#define TCIOFLUSH 1 /* Flush both pending input and untransmitte + * output */ #define TCOFLUSH 2 /* Flush untransmitted output */ /* Constants for use with tcflow() */ -#define TCIOFF 0 /* Transmit a STOP character, intended to suspend input data */ -#define TCION 1 /* Transmit a START character, intended to restart input data */ +#define TCIOFF 0 /* Transmit a STOP character, intended to + * suspend input data */ +#define TCION 1 /* Transmit a START character, intended to + * restart input data */ #define TCOOFF 2 /* Suspend output */ #define TCOON 3 /* Restart output */ diff --git a/libc/dirent/lib_readdirr.c b/libc/dirent/lib_readdirr.c index ffbe91056aff71531bc7aa6f886ef18a764110ce..d383651c636a136667ad7b6e4cd53c2f6253f3dd 100644 --- a/libc/dirent/lib_readdirr.c +++ b/libc/dirent/lib_readdirr.c @@ -62,7 +62,7 @@ * directory stream pointed to by dir. It returns NULL on * reaching the end-of-file or if an error occurred. * - * Inputs: + * Input Parameters: * dirp -- An instance of type DIR created by a previous * call to opendir(); * entry -- The storage pointed to by entry must be large @@ -73,7 +73,7 @@ * argument entry. Upon reaching the end of the directory * stream, this pointer shall have the value NULL. * - * Return: + * Returned Value: * If successful, the readdir_r() function return s zero; * otherwise, an error number is returned to indicate the * error. diff --git a/libc/dirent/lib_telldir.c b/libc/dirent/lib_telldir.c index f77a4a1c21c4c0aceb6f741039c41947da12f94e..af12ff902b1f5289d6d6c13f98072eea4e36a759 100644 --- a/libc/dirent/lib_telldir.c +++ b/libc/dirent/lib_telldir.c @@ -61,11 +61,11 @@ * The telldir() function returns the current location * associated with the directory stream dirp. * - * Inputs: + * Input Parameters: * dirp -- An instance of type DIR created by a previous * call to opendir(); * - * Return: + * Returned Value: * On success, the telldir() function returns the current * location in the directory stream. On error, -1 is * returned, and errno is set appropriately. diff --git a/libc/hex2bin/lib_fhex2mem.c b/libc/hex2bin/lib_fhex2mem.c index 1967dd1adeb6faf90245ebb87853ca6497f9d203..13b344adf991191f03b5ed493ce5021507cbc9bc 100644 --- a/libc/hex2bin/lib_fhex2mem.c +++ b/libc/hex2bin/lib_fhex2mem.c @@ -52,7 +52,7 @@ ****************************************************************************/ /**************************************************************************** - * Name fhex2mem + * Name: fhex2mem * * Description: * Read the Intel HEX ASCII data provided on the standard stream @@ -69,7 +69,7 @@ * swap - Controls byte ordering. See enum hex2bin_swap_e for * description of the values. * - * Returned Value + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * failure. * diff --git a/libc/hex2bin/lib_hex2bin.c b/libc/hex2bin/lib_hex2bin.c index 2dc5d32d97b7175e62ba511911e296f357354b66..3815eb062702c8ec767a104dd5f3654ff6f1207f 100644 --- a/libc/hex2bin/lib_hex2bin.c +++ b/libc/hex2bin/lib_hex2bin.c @@ -403,7 +403,7 @@ static inline void writedata(FAR struct lib_sostream_s *outstream, * swap - Controls byte ordering. See enum hex2bin_swap_e for * description of the values. * - * Returned Value + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * failure. * diff --git a/libc/hex2bin/lib_hex2mem.c b/libc/hex2bin/lib_hex2mem.c index 12c284cf5403019affd8a71af7b577293389434e..fa21e59124ba4dceb2a06f0dc95985e18384a45e 100644 --- a/libc/hex2bin/lib_hex2mem.c +++ b/libc/hex2bin/lib_hex2mem.c @@ -52,7 +52,7 @@ ****************************************************************************/ /**************************************************************************** - * Name hex2mem + * Name: hex2mem * * Description: * Read the Intel HEX ASCII data provided on the file descriptor 'fd' and @@ -69,7 +69,7 @@ * swap - Controls byte ordering. See enum hex2bin_swap_e for * description of the values. * - * Returned Value + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * failure. * diff --git a/libc/inttypes/lib_strtoimax.c b/libc/inttypes/lib_strtoimax.c index 0acaca315514aeb29431a59f5b27e4353f3fce31..d4eff8232fe6b69fc6de5f63ad47d03156212f9a 100644 --- a/libc/inttypes/lib_strtoimax.c +++ b/libc/inttypes/lib_strtoimax.c @@ -64,7 +64,7 @@ * nptr to a intmax_t integer value according to the given base, which * must be between 2 and 36 inclusive, or be the special value 0. * - * Returns: + * Returned Value: * - The converted value, if the base and number are valid * - 0 if an error occurs, and set errno to: * * EINVAL if base < 2 or base > 36 diff --git a/libc/inttypes/lib_strtoumax.c b/libc/inttypes/lib_strtoumax.c index 9440908c93c31358aacee9b9626919fa186396b7..90cf6005ff46e7a7821f6600771798b4e8677139 100644 --- a/libc/inttypes/lib_strtoumax.c +++ b/libc/inttypes/lib_strtoumax.c @@ -57,7 +57,7 @@ * nptr to a long unsigned integer value according to the given base, which * must be between 2 and 36 inclusive, or be the special value 0. * - * Returns: + * Returned Value: * - The converted value, if the base and number are valid * - 0 if an error occurs, and set errno to: * * EINVAL if base < 2 or base > 36 diff --git a/libc/libgen/lib_basename.c b/libc/libgen/lib_basename.c index 18b2168fad3e1426d25085ea253d71beb82e4103..c83793820987112dd5067810212b5b5bcd61810a 100644 --- a/libc/libgen/lib_basename.c +++ b/libc/libgen/lib_basename.c @@ -73,7 +73,7 @@ static char g_retchar[2]; * Parameter: * path The null-terminated string referring to the path to be decomposed * - * Return: + * Returned Value: * On success the filename component of the path is returned. * ****************************************************************************/ diff --git a/libc/libgen/lib_dirname.c b/libc/libgen/lib_dirname.c index 0acd03c71fdcc78f07b8f6f73a081a2e039ee102..ce260e2a4f326b416ad083dc03e0a892d4d1a8bc 100644 --- a/libc/libgen/lib_dirname.c +++ b/libc/libgen/lib_dirname.c @@ -73,7 +73,7 @@ static char g_retchar[2]; * Parameter: * path The null-terminated string referring to the path to be decomposed * - * Return: + * Returned Value: * On success the directory component of the path is returned. * ****************************************************************************/ diff --git a/libc/misc/lib_ioctl.c b/libc/misc/lib_ioctl.c index 0e7ca015d33755ab16b2a2e5db30e2f9dd860e22..f9acafba8a34ec8fee317e44af24b8fd471843d4 100644 --- a/libc/misc/lib_ioctl.c +++ b/libc/misc/lib_ioctl.c @@ -65,7 +65,7 @@ * req The ioctl command * ... A third argument of type unsigned long is expected * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * -1 on failure with errno set properly: * diff --git a/libc/misc/lib_mkfifo.c b/libc/misc/lib_mkfifo.c index deb919aad1c82498380c169165ac5984a4537021..4bcd412096bfa9e0316030a5f6fe2de19ff99c77 100644 --- a/libc/misc/lib_mkfifo.c +++ b/libc/misc/lib_mkfifo.c @@ -68,12 +68,12 @@ * If all threads that write to the FIFO have closed, subsequent calls to * read() on the FIFO will return 0 (end-of-file). * - * Inputs: + * Input Parameters: * pathname - The full path to the FIFO instance to attach to or to create * (if not already created). * mode - Ignored for now * - * Return: + * Returned Value: * 0 is returned on success; otherwise, -1 is returned with errno set * appropriately. * diff --git a/libc/misc/lib_ncompress.c b/libc/misc/lib_ncompress.c new file mode 100644 index 0000000000000000000000000000000000000000..8f8b116ebc92cd5780f5ee048e28fd019be742e8 --- /dev/null +++ b/libc/misc/lib_ncompress.c @@ -0,0 +1,985 @@ + +/**************************************************************************** + * libc/misc/lib_ncompress.c + * File compression ala IEEE Computer, Mar 1992. + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * This is the file compress24.c extracted from the ncompress-4.2.4 release + * and adapted for NuttX. The original code was released into the public + * domain. This NuttX version is re-released under the standard NuttX + * BSD 3-clause license. The original authors are listed below: + * + * Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) + * Jim McKie (decvax!mcvax!jim) + * Steve Davies (decvax!vax135!petsd!peora!srd) + * Ken Turkowski (decvax!decwrl!turtlevax!ken) + * James A. Woods (decvax!ihnp4!ames!jaw) + * Joe Orost (decvax!vax135!petsd!joe) + * Dave Mack (csu@alembic.acs.com) + * Peter Jannesen, Network Communication Systems + * (peter@ncs.nl) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RECURSIVE 1 + +#ifdef __STDC__ +# define ARGS(a) a +#else +# define ARGS(a) () +#endif + +#define LARGS(a) () /* Relay on include files for libary func defs. + */ + +#ifndef SIG_TYPE +# define SIG_TYPE void (*)() +#endif + +#define MARK(a) { asm(" .globl M.a"); asm("M.a:"); } + +#undef min +#define min(a,b) ((a>b) ? b : a) + +#ifndef IBUFSIZ +# define IBUFSIZ BUFSIZ /* Defailt input buffer size */ +#endif +#ifndef OBUFSIZ +# define OBUFSIZ BUFSIZ /* Default output buffer size */ +#endif + +#define MAXPATHLEN 1024 /* MAXPATHLEN - maximum length of a pathname we + * allow */ +#define SIZE_INNER_LOOP 256 /* Size of the inter (fast) compress loop */ + + /* Defines for third byte of header */ +#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */ +#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */ +#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */ + /* Masks 0x20 and 0x40 are free. */ + /* I think 0x20 should mean that there is */ + /* a fourth header byte (for expansion). */ +#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */ + /* compression rate is dropping flush tables */ + + /* the next two codes should not be changed lightly, as they must not */ + /* lie within the contiguous general code space. */ +#define FIRST 257 /* first free entry */ +#define CLEAR 256 /* table clear output code */ + +#define INIT_BITS 9 /* initial number of bits/code */ + +#ifndef SACREDMEM + /* + * SACREDMEM is the amount of physical memory saved for others; compress + * will hog the rest. + */ +# define SACREDMEM 0 +#endif + +#ifndef USERMEM + /* + * Set USERMEM to the maximum amount of physical user memory available + * in bytes. USERMEM is used to determine the maximum BITS that can be used + * for compression. + */ +# define USERMEM 450000 /* default user memory */ +#endif + +#ifndef BYTEORDER +# define BYTEORDER 0000 +#endif + +#ifndef NOALLIGN +# define NOALLIGN 0 +#endif + +/* + * machine variants which require cc -Dmachine: pdp11, z8000, DOS + */ + +#ifdef interdata /* Perkin-Elmer */ +# define SIGNED_COMPARE_SLOW /* signed compare is slower than unsigned */ +#endif + +#ifdef pdp11 /* PDP11: don't forget to compile with -i */ +# define BITS 12 /* max bits/code for 16-bit machine */ +# define NO_UCHAR /* also if "unsigned char" functions as signed + * char */ +#endif /* pdp11 */ + +#ifdef z8000 /* Z8000: */ +# define BITS 12 /* 16-bits processor max 12 bits */ +# undef vax /* weird preprocessor */ +#endif /* z8000 */ + +#ifdef DOS /* PC/XT/AT (8088) processor */ +# define BITS 16 /* 16-bits processor max 12 bits */ +# if BITS == 16 +# define MAXSEG_64K +# endif +# undef BYTEORDER +# define BYTEORDER 4321 +# undef NOALLIGN +# define NOALLIGN 1 +#endif /* DOS */ + +#ifndef O_BINARY +# define O_BINARY 0 /* System has no binary mode */ +#endif + +#ifdef M_XENIX /* Stupid compiler can't handle arrays with */ +# if BITS == 16 /* more than 65535 bytes - so we fake it */ +# define MAXSEG_64K +# else +# if BITS > 13 /* Code only handles BITS = 12, 13, or 16 */ +# define BITS 13 +# endif +# endif +#endif + +#ifndef BITS /* General processor calculate BITS */ +# if USERMEM >= (800000+SACREDMEM) +# define FAST +# else +# if USERMEM >= (433484+SACREDMEM) +# define BITS 16 +# else +# if USERMEM >= (229600+SACREDMEM) +# define BITS 15 +# else +# if USERMEM >= (127536+SACREDMEM) +# define BITS 14 +# else +# if USERMEM >= (73464+SACREDMEM) +# define BITS 13 +# else +# define BITS 12 +# endif +# endif +# endif +# endif +# endif +#endif /* BITS */ + +#ifdef FAST +# define HBITS 17 /* 50% occupancy */ +# define HSIZE (1<>3]) |= ((long)(c))<<((o)&0x7);\ + (o) += (n); \ + } +#else +# ifdef BYTEORDER +# define output(b,o,c,n) { char_type *p = &(b)[(o)>>3]; \ + union bytes i; \ + i.word = ((long)(c))<<((o)&0x7); \ + p[0] |= i.bytes.b1; \ + p[1] |= i.bytes.b2; \ + p[2] |= i.bytes.b3; \ + (o) += (n); \ + } +# else +# define output(b,o,c,n) { char_type *p = &(b)[(o)>>3]; \ + long i = ((long)(c))<<((o)&0x7); \ + p[0] |= (char_type)(i); \ + p[1] |= (char_type)(i>>8); \ + p[2] |= (char_type)(i>>16); \ + (o) += (n); \ + } +# endif +#endif +#if BYTEORDER == 4321 && NOALLIGN == 1 +# define input(b,o,c,n,m){ \ + (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \ + (o) += (n); \ + } +#else +# define input(b,o,c,n,m){ char_type *p = &(b)[(o)>>3]; \ + (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \ + ((long)(p[2])<<16))>>((o)&0x7))&(m); \ + (o) += (n); \ + } +#endif + +char *progname; /* Program name */ +int silent = 0; /* don't tell me about errors */ +int quiet = 1; /* don't tell me about compression */ +int do_decomp = 0; /* Decompress mode */ +int force = 0; /* Force overwrite of files and links */ +int nomagic = 0; /* Use a 3-byte magic number header, */ + /* unless old file */ +int block_mode = BLOCK_MODE; /* Block compress mode -C compatible with 2.0 */ +int maxbits = BITS; /* user settable max # bits/code */ +int zcat_flg = 0; /* Write output on stdout, suppress messages */ +int recursive = 0; /* compress directories */ +int exit_code = -1; /* Exitcode of compress (-1 no file compressed) + */ + +char_type inbuf[IBUFSIZ + 64]; /* Input buffer */ +char_type outbuf[OBUFSIZ + 2048]; /* Output buffer */ + +struct stat infstat; /* Input file status */ +char *ifname; /* Input filename */ +int remove_ofname = 0; /* Remove output file on a error */ +char ofname[MAXPATHLEN]; /* Output filename */ +int fgnd_flag = 0; /* Running in background (SIGINT=SIGIGN) */ + +long bytes_in; /* Total number of byte from input */ +long bytes_out; /* Total number of byte to output */ + +/* + * To save much memory, we overlay the table used by compress() with those + * used by decompress(). The tab_prefix table is the same size and type + * as the codetab. The tab_suffix table needs 2**BITS characters. We + * get this from the beginning of htab. The output stack uses the rest + * of htab, and contains characters. There is plenty of room for any + * possible stack (stack used to be 8000 characters). + */ +#ifdef MAXSEG_64K +count_int htab0[8192]; +count_int htab1[8192]; +count_int htab2[8192]; +count_int htab3[8192]; +count_int htab4[8192]; +count_int htab5[8192]; +count_int htab6[8192]; +count_int htab7[8192]; +count_int htab8[HSIZE - 65536]; +count_int *htab[9] = + { htab0, htab1, htab2, htab3, htab4, htab5, htab6, htab7, htab8 }; + +unsigned short code0tab[16384]; +unsigned short code1tab[16384]; +unsigned short code2tab[16384]; +unsigned short code3tab[16384]; +unsigned short code4tab[16384]; +unsigned short *codetab[5] = + { code0tab, code1tab, code2tab, code3tab, code4tab }; + +# define htabof(i) (htab[(i) >> 13][(i) & 0x1fff]) +# define codetabof(i) (codetab[(i) >> 14][(i) & 0x3fff]) +# define tab_prefixof(i) codetabof(i) +# define tab_suffixof(i) ((char_type *)htab[(i)>>15])[(i) & 0x7fff] +# define de_stack ((char_type *)(&htab2[8191])) +void clear_htab() +{ + memset(htab0, -1, sizeof(htab0)); + memset(htab1, -1, sizeof(htab1)); + memset(htab2, -1, sizeof(htab2)); + memset(htab3, -1, sizeof(htab3)); + memset(htab4, -1, sizeof(htab4)); + memset(htab5, -1, sizeof(htab5)); + memset(htab6, -1, sizeof(htab6)); + memset(htab7, -1, sizeof(htab7)); + memset(htab8, -1, sizeof(htab8)); +} + +# define clear_tab_prefixof() memset(code0tab, 0, 256); +#else /* Normal machine */ +count_int htab[HSIZE]; +unsigned short codetab[HSIZE]; + +# define htabof(i) htab[i] +# define codetabof(i) codetab[i] +# define tab_prefixof(i) codetabof(i) +# define tab_suffixof(i) ((char_type *)(htab))[i] +# define de_stack ((char_type *)&(htab[HSIZE-1])) +# define clear_htab() memset(htab, -1, sizeof(htab)) +# define clear_tab_prefixof() memset(codetab, 0, 256); + +# ifdef FAST +int primetab[256] = /* Special secudary hash table. */ +{ + 1013, -1061, 1109, -1181, 1231, -1291, 1361, -1429, + 1481, -1531, 1583, -1627, 1699, -1759, 1831, -1889, + 1973, -2017, 2083, -2137, 2213, -2273, 2339, -2383, + 2441, -2531, 2593, -2663, 2707, -2753, 2819, -2887, + 2957, -3023, 3089, -3181, 3251, -3313, 3361, -3449, + 3511, -3557, 3617, -3677, 3739, -3821, 3881, -3931, + 4013, -4079, 4139, -4219, 4271, -4349, 4423, -4493, + 4561, -4639, 4691, -4783, 4831, -4931, 4973, -5023, + 5101, -5179, 5261, -5333, 5413, -5471, 5521, -5591, + 5659, -5737, 5807, -5857, 5923, -6029, 6089, -6151, + 6221, -6287, 6343, -6397, 6491, -6571, 6659, -6709, + 6791, -6857, 6917, -6983, 7043, -7129, 7213, -7297, + 7369, -7477, 7529, -7577, 7643, -7703, 7789, -7873, + 7933, -8017, 8093, -8171, 8237, -8297, 8387, -8461, + 8543, -8627, 8689, -8741, 8819, -8867, 8963, -9029, + 9109, -9181, 9241, -9323, 9397, -9439, 9511, -9613, + 9677, -9743, 9811, -9871, 9941, -10061, 10111, -10177, + 10259, -10321, 10399, -10477, 10567, -10639, 10711, -10789, + 10867, -10949, 11047, -11113, 11173, -11261, 11329, -11423, + 11491, -11587, 11681, -11777, 11827, -11903, 11959, -12041, + 12109, -12197, 12263, -12343, 12413, -12487, 12541, -12611, + 12671, -12757, 12829, -12917, 12979, -13043, 13127, -13187, + 13291, -13367, 13451, -13523, 13619, -13691, 13751, -13829, + 13901, -13967, 14057, -14153, 14249, -14341, 14419, -14489, + 14557, -14633, 14717, -14767, 14831, -14897, 14983, -15083, + 15149, -15233, 15289, -15359, 15427, -15497, 15583, -15649, + 15733, -15791, 15881, -15937, 16057, -16097, 16189, -16267, + 16363, -16447, 16529, -16619, 16691, -16763, 16879, -16937, + 17021, -17093, 17183, -17257, 17341, -17401, 17477, -17551, + 17623, -17713, 17791, -17891, 17957, -18041, 18097, -18169, + 18233, -18307, 18379, -18451, 18523, -18637, 18731, -18803, + 18919, -19031, 19121, -19211, 19273, -19381, 19429, -19477 +}; +# endif + +/* + * compress fdin to fdout + * + * Algorithm: use open addressing double hashing (no chaining) on the + * prefix code / next character combination. We do a variant of Knuth's + * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime + * secondary probe. Here, the modular division first probe is gives way + * to a faster exclusive-or manipulation. Also do block compression with + * an adaptive reset, whereby the code table is cleared when the compression + * ratio decreases, but after the table fills. The variable-length output + * codes are re-sized at this point, and a special CLEAR code is generated + * for the decompressor. Late addition: construct the table according to + * file size for noticeable speed improvement on small files. Please direct + * questions about this implementation to ames!jaw. + */ +void compress(int fdin, int fdout) +{ + long hp; + int rpos; + long fc; + int outbits; + int rlop; + int rsize; + int stcode; + code_int free_ent; + int boff; + int n_bits; + int ratio; + long checkpoint; + code_int extcode; + union + { + long code; + struct + { + char_type c; + unsigned short ent; + } e; + } fcode; + + ratio = 0; + checkpoint = CHECK_GAP; + extcode = MAXCODE(n_bits = INIT_BITS) + 1; + stcode = 1; + free_ent = FIRST; + + memset(outbuf, 0, sizeof(outbuf)); + bytes_out = 0; + bytes_in = 0; + outbuf[0] = MAGIC_1; + outbuf[1] = MAGIC_2; + outbuf[2] = (char)(maxbits | block_mode); + boff = outbits = (3 << 3); + fcode.code = 0; + + clear_htab(); + + while ((rsize = read(fdin, inbuf, IBUFSIZ)) > 0) + { + if (bytes_in == 0) + { + fcode.e.ent = inbuf[0]; + rpos = 1; + } + else + rpos = 0; + + rlop = 0; + + do + { + if (free_ent >= extcode && fcode.e.ent < FIRST) + { + if (n_bits < maxbits) + { + boff = outbits = (outbits - 1) + ((n_bits << 3) - + ((outbits - boff - 1 + + (n_bits << 3)) % + (n_bits << 3))); + if (++n_bits < maxbits) + extcode = MAXCODE(n_bits) + 1; + else + extcode = MAXCODE(n_bits); + } + else + { + extcode = MAXCODE(16) + OBUFSIZ; + stcode = 0; + } + } + + if (!stcode && bytes_in >= checkpoint && fcode.e.ent < FIRST) + { + long int rat; + + checkpoint = bytes_in + CHECK_GAP; + + if (bytes_in > 0x007fffff) + { /* shift will overflow */ + rat = (bytes_out + (outbits >> 3)) >> 8; + + if (rat == 0) /* Don't divide by zero */ + rat = 0x7fffffff; + else + rat = bytes_in / rat; + } + else + rat = (bytes_in << 8) / (bytes_out + (outbits >> 3)); /* 8 + * fractional + * bits + */ + if (rat >= ratio) + ratio = (int)rat; + else + { + ratio = 0; + clear_htab(); + output(outbuf, outbits, CLEAR, n_bits); + boff = outbits = (outbits - 1) + ((n_bits << 3) - + ((outbits - boff - 1 + + (n_bits << 3)) % + (n_bits << 3))); + extcode = MAXCODE(n_bits = INIT_BITS) + 1; + free_ent = FIRST; + stcode = 1; + } + } + + if (outbits >= (OBUFSIZ << 3)) + { + if (write(fdout, outbuf, OBUFSIZ) != OBUFSIZ) + write_error(); + + outbits -= (OBUFSIZ << 3); + boff = -(((OBUFSIZ << 3) - boff) % (n_bits << 3)); + bytes_out += OBUFSIZ; + + memcpy(outbuf, outbuf + OBUFSIZ, (outbits >> 3) + 1); + memset(outbuf + (outbits >> 3) + 1, '\0', OBUFSIZ); + } + + { + int i; + + i = rsize - rlop; + + if ((code_int) i > extcode - free_ent) + i = (int)(extcode - free_ent); + if (i > ((sizeof(outbuf) - 32) * 8 - outbits) / n_bits) + i = ((sizeof(outbuf) - 32) * 8 - outbits) / n_bits; + + if (!stcode && (long)i > checkpoint - bytes_in) + i = (int)(checkpoint - bytes_in); + + rlop += i; + bytes_in += i; + } + + goto next; + hfound:fcode.e.ent = codetabof(hp); + next:if (rpos >= rlop) + goto endlop; + next2:fcode.e.c = inbuf[rpos++]; +# ifndef FAST + { + code_int i; + fc = fcode.code; + + hp = (((long)(fcode.e.c)) << (BITS - 8)) ^ (long)(fcode.e.ent); + + if ((i = htabof(hp)) == fc) + goto hfound; + + if (i != -1) + { + long disp; + + disp = (HSIZE - hp) - 1; /* secondary hash (after G. + * Knott) */ + + do + { + if ((hp -= disp) < 0) + hp += HSIZE; + + if ((i = htabof(hp)) == fc) + goto hfound; + } + while (i != -1); + } + } +# else + { + long i; + long p; + fc = fcode.code; + + hp = ((((long)(fcode.e.c)) << (HBITS - 8)) ^ (long)(fcode.e.ent)); + + if ((i = htabof(hp)) == fc) + goto hfound; + if (i == -1) + goto out; + + p = primetab[fcode.e.c]; + lookup:hp = (hp + p) & HMASK; + if ((i = htabof(hp)) == fc) + goto hfound; + if (i == -1) + goto out; + hp = (hp + p) & HMASK; + if ((i = htabof(hp)) == fc) + goto hfound; + if (i == -1) + goto out; + hp = (hp + p) & HMASK; + if ((i = htabof(hp)) == fc) + goto hfound; + if (i == -1) + goto out; + goto lookup; + } + out:; +# endif + output(outbuf, outbits, fcode.e.ent, n_bits); + + { + long fc = fcode.code; + fcode.e.ent = fcode.e.c; + + if (stcode) + { + codetabof(hp) = (unsigned short)free_ent++; + htabof(hp) = fc; + } + } + + goto next; + + endlop:if (fcode.e.ent >= FIRST && rpos < rsize) + goto next2; + + if (rpos > rlop) + { + bytes_in += rpos - rlop; + rlop = rpos; + } + } + while (rlop < rsize); + } + + if (rsize < 0) + read_error(); + + if (bytes_in > 0) + output(outbuf, outbits, fcode.e.ent, n_bits); + + if (write(fdout, outbuf, (outbits + 7) >> 3) != (outbits + 7) >> 3) + write_error(); + + bytes_out += (outbits + 7) >> 3; + + return; +} + +/* + * Decompress stdin to stdout. This routine adapts to the codes in the + * file building the "string" table on-the-fly; requiring no table to + * be stored in the compressed file. The tables used herein are shared + * with those of the compress() routine. See the definitions above. + */ + +void decompress(int fdin, int fdout) + int fdin; + int fdout; +{ + char_type *stackp; + code_int code; + int finchar; + code_int oldcode; + code_int incode; + int inbits; + int posbits; + int outpos; + int insize; + int bitmask; + code_int free_ent; + code_int maxcode; + code_int maxmaxcode; + int n_bits; + int rsize; + + bytes_in = 0; + bytes_out = 0; + insize = 0; + + while (insize < 3 && (rsize = read(fdin, inbuf + insize, IBUFSIZ)) > 0) + insize += rsize; + + if (insize < 3 || inbuf[0] != MAGIC_1 || inbuf[1] != MAGIC_2) + { + if (rsize < 0) + read_error(); + + if (insize > 0) + { + fprintf(stderr, "%s: not in compressed format\n", + (ifname[0] != '\0' ? ifname : "stdin")); + exit_code = 1; + } + + return; + } + + maxbits = inbuf[2] & BIT_MASK; + block_mode = inbuf[2] & BLOCK_MODE; + + if (maxbits > BITS) + { + fprintf(stderr, + "%s: compressed with %d bits, can only handle %d bits\n", + (*ifname != '\0' ? ifname : "stdin"), maxbits, BITS); + exit_code = 4; + return; + } + + maxmaxcode = MAXCODE(maxbits); + + bytes_in = insize; + maxcode = MAXCODE(n_bits = INIT_BITS) - 1; + bitmask = (1 << n_bits) - 1; + oldcode = -1; + finchar = 0; + outpos = 0; + posbits = 3 << 3; + + free_ent = ((block_mode) ? FIRST : 256); + + clear_tab_prefixof(); /* As above, initialize the first 256 entries + * in the table. */ + + for (code = 255; code >= 0; --code) + tab_suffixof(code) = (char_type) code; + + do + { + resetbuf:; + { + int i; + int e; + int o; + + o = posbits >> 3; + e = o <= insize ? insize - o : 0; + + for (i = 0; i < e; ++i) + inbuf[i] = inbuf[i + o]; + + insize = e; + posbits = 0; + } + + if (insize < sizeof(inbuf) - IBUFSIZ) + { + if ((rsize = read(fdin, inbuf + insize, IBUFSIZ)) < 0) + read_error(); + + insize += rsize; + } + + inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 : + (insize << 3) - (n_bits - 1)); + + while (inbits > posbits) + { + if (free_ent > maxcode) + { + posbits = ((posbits - 1) + ((n_bits << 3) - + (posbits - 1 + + (n_bits << 3)) % (n_bits << 3))); + + ++n_bits; + if (n_bits == maxbits) + maxcode = maxmaxcode; + else + maxcode = MAXCODE(n_bits) - 1; + + bitmask = (1 << n_bits) - 1; + goto resetbuf; + } + + input(inbuf, posbits, code, n_bits, bitmask); + + if (oldcode == -1) + { + if (code >= 256) + { + fprintf(stderr, "oldcode:-1 code:%i\n", (int)(code)); + fprintf(stderr, "uncompress: corrupt input\n"); + abort_compress(); + } + outbuf[outpos++] = (char_type) (finchar = (int)(oldcode = code)); + continue; + } + + if (code == CLEAR && block_mode) + { + clear_tab_prefixof(); + free_ent = FIRST - 1; + posbits = ((posbits - 1) + ((n_bits << 3) - + (posbits - 1 + + (n_bits << 3)) % (n_bits << 3))); + maxcode = MAXCODE(n_bits = INIT_BITS) - 1; + bitmask = (1 << n_bits) - 1; + goto resetbuf; + } + + incode = code; + stackp = de_stack; + + if (code >= free_ent) /* Special case for KwKwK string. */ + { + if (code > free_ent) + { + char_type *p; + + posbits -= n_bits; + p = &inbuf[posbits >> 3]; + + fprintf(stderr, + "insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)\n", + insize, posbits, p[-1], p[0], p[1], p[2], p[3], + (posbits & 07)); + fprintf(stderr, "uncompress: corrupt input\n"); + abort_compress(); + } + + *--stackp = (char_type) finchar; + code = oldcode; + } + + while ((cmp_code_int) code >= (cmp_code_int) 256) + { /* Generate output characters in reverse order */ + *--stackp = tab_suffixof(code); + code = tab_prefixof(code); + } + + *--stackp = (char_type) (finchar = tab_suffixof(code)); + + /* And put them out in forward order */ + + { + int i; + + if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) + { + do + { + if (i > OBUFSIZ - outpos) + i = OBUFSIZ - outpos; + + if (i > 0) + { + memcpy(outbuf + outpos, stackp, i); + outpos += i; + } + + if (outpos >= OBUFSIZ) + { + if (write(fdout, outbuf, outpos) != outpos) + write_error(); + + outpos = 0; + } + stackp += i; + } + while ((i = (de_stack - stackp)) > 0); + } + else + { + memcpy(outbuf + outpos, stackp, i); + outpos += i; + } + } + + if ((code = free_ent) < maxmaxcode) /* Generate the new entry. */ + { + tab_prefixof(code) = (unsigned short)oldcode; + tab_suffixof(code) = (char_type) finchar; + free_ent = code + 1; + } + + oldcode = incode; /* Remember previous code. */ + } + + bytes_in += rsize; + } + while (rsize > 0); + + if (outpos > 0 && write(fdout, outbuf, outpos) != outpos) + write_error(); +} + +void read_error() +{ + fprintf(stderr, "\nread error on"); + perror((ifname[0] != '\0') ? ifname : "stdin"); + abort_compress(); +} + +void write_error() +{ + fprintf(stderr, "\nwrite error on"); + perror((ofname[0] != '\0') ? ofname : "stdout"); + abort_compress(); +} + +void abort_compress() +{ + if (remove_ofname) + unlink(ofname); + + exit(1); +} + +void prratio(stream, num, den) + FILE *stream; + long int num; + long int den; +{ + int q; + + if (den > 0) + { + if (num > 214748L) + q = (int)(num / (den / 10000L)); /* 2147483647/10000 */ + else + q = (int)(10000L * num / den); /* Long calculations, though */ + } + else + q = 10000; + + if (q < 0) + { + putc('-', stream); + q = -q; + } + + fprintf(stream, "%d.%02d%%", q / 100, q % 100); +} diff --git a/libc/misc/lib_sendfile.c b/libc/misc/lib_sendfile.c index be6fa94c01d05a52e62ccfb9c77d39675293c05b..e3eaf548380f07e3b0cb2257642387c402d1a523 100644 --- a/libc/misc/lib_sendfile.c +++ b/libc/misc/lib_sendfile.c @@ -72,7 +72,7 @@ * different semantics and prototypes. sendfile() should not be used * in portable programs. * - * Input Parmeters: + * Input Parameters: * infd - A file (or socket) descriptor opened for reading * outfd - A descriptor opened for writing. * offset - If 'offset' is not NULL, then it points to a variable diff --git a/libc/modlib/modlib_init.c b/libc/modlib/modlib_init.c index 964272ca0a0f13f52162fa2951076203ad34f51a..a8f10118e079e2ab70411345cb68ccf0f4148f6e 100644 --- a/libc/modlib/modlib_init.c +++ b/libc/modlib/modlib_init.c @@ -98,7 +98,7 @@ static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo, ret = stat(filename, &buf); if (ret < 0) { - int errval = errno; + int errval = get_errno(); serr("ERROR: Failed to stat file: %d\n", errval); return -errval; } @@ -163,7 +163,7 @@ int modlib_initialize(FAR const char *filename, loadinfo->filfd = open(filename, O_RDONLY); if (loadinfo->filfd < 0) { - int errval = errno; + int errval = get_errno(); serr("ERROR: Failed to open ELF binary %s: %d\n", filename, errval); return -errval; } diff --git a/libc/modlib/modlib_read.c b/libc/modlib/modlib_read.c index 169d58142968d83cc033cb4ea32f476fb4d3f286..00402ffcae064616ddd928c6c8ad6b064022cb30 100644 --- a/libc/modlib/modlib_read.c +++ b/libc/modlib/modlib_read.c @@ -121,7 +121,7 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer, rpos = lseek(loadinfo->filfd, offset, SEEK_SET); if (rpos != offset) { - int errval = errno; + int errval = get_errno(); serr("ERROR: Failed to seek to position %lu: %d\n", (unsigned long)offset, errval); return -errval; diff --git a/libc/net/lib_shutdown.c b/libc/net/lib_shutdown.c index a2c733dec232bfef467bfabe83b069a035eee604..b6cdaecdeaabcabfdd8c032a05c3dcd766d50f86 100644 --- a/libc/net/lib_shutdown.c +++ b/libc/net/lib_shutdown.c @@ -41,10 +41,6 @@ #ifdef CONFIG_NET -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -60,7 +56,7 @@ * The shutdown() function disables subsequent send and/or receive * operations on a socket, depending on the value of the how argument. * - * Input Paramteers: + * Input Parameters: * sockfd - Specifies the file descriptor of the socket. * how - Specifies the type of shutdown. The values are as follows: * diff --git a/libc/netdb/lib_dnsaddserver.c b/libc/netdb/lib_dnsaddserver.c index 3efbeb9ca0add813c72263b53a73cd94da4ec83d..21de6bcbaa335a3c2117970c74b6b29c8ca6f54b 100644 --- a/libc/netdb/lib_dnsaddserver.c +++ b/libc/netdb/lib_dnsaddserver.c @@ -90,7 +90,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); if (stream == NULL) { - int errcode = errno; + int errcode = get_errno(); nerr("ERROR: Failed to open %s: %d\n", CONFIG_NETDB_RESOLVCONF_PATH, errcode); DEBUGASSERT(errcode > 0); diff --git a/libc/netdb/lib_dnsforeach.c b/libc/netdb/lib_dnsforeach.c index cc34b1658f299c18313b374e8d8aeb61e55efc41..ab02f85a0b7d6f5f5ee208353cc4134129d3acc3 100644 --- a/libc/netdb/lib_dnsforeach.c +++ b/libc/netdb/lib_dnsforeach.c @@ -104,7 +104,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg) stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "rb"); if (stream == NULL) { - int errcode = errno; + int errcode = get_errno(); nerr("ERROR: Failed to open %s: %d\n", CONFIG_NETDB_RESOLVCONF_PATH, errcode); DEBUGASSERT(errcode > 0); diff --git a/libc/netdb/lib_gethostbyaddrr.c b/libc/netdb/lib_gethostbyaddrr.c index 53e91fda34785720e3b3729c65ed2e242a1912f2..8366425b16cd9116f3c6d9a087015172f1a1b442 100644 --- a/libc/netdb/lib_gethostbyaddrr.c +++ b/libc/netdb/lib_gethostbyaddrr.c @@ -263,7 +263,7 @@ int lib_hostfile_lookup(FAR const void *addr, socklen_t len, int type, stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r"); if (stream == NULL) { - int errcode = errno; + int errcode = get_errno(); nerr("ERROR: Failed to open the hosts file %s: %d\n", CONFIG_NETDB_HOSTCONF_PATH, errcode); diff --git a/libc/netdb/lib_gethostbynamer.c b/libc/netdb/lib_gethostbynamer.c index 8ad93ac6f38c00b5631880c1ea4fe4b2107c4c91..b66e0994e980848e036d84e8513f3b0e114f44ae 100644 --- a/libc/netdb/lib_gethostbynamer.c +++ b/libc/netdb/lib_gethostbynamer.c @@ -420,7 +420,7 @@ static int lib_find_answer(FAR const char *name, FAR struct hostent *host, /**************************************************************************** * Name: lib_dns_query * - * Descriptions: + * Description: * Combines the operations of dns_bind(), dns_query(), and dns_free() to * obtain the IP address ('ipaddr') associated with the 'hostname' in one * operation. @@ -597,7 +597,7 @@ static int lib_hostfile_lookup(FAR const char *name, FAR struct hostent *host, stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r"); if (stream == NULL) { - int errcode = errno; + int errcode = get_errno(); nerr("ERROR: Failed to open the hosts file %s: %d\n", CONFIG_NETDB_HOSTCONF_PATH, errcode); diff --git a/libc/pthread/pthread_attr_destroy.c b/libc/pthread/pthread_attr_destroy.c index 16dd2cc50ee667eb92ca0364da488fe88ce24554..d91530841bb309f8ad54b823d7a379a07e39cd69 100644 --- a/libc/pthread/pthread_attr_destroy.c +++ b/libc/pthread/pthread_attr_destroy.c @@ -57,7 +57,7 @@ * Parameters: * attr * - * Return Value: + * Returned Value: * 0 meaning success * * Assumptions: diff --git a/libc/pthread/pthread_attr_getaffinity.c b/libc/pthread/pthread_attr_getaffinity.c index 1371ceff379b8de67be1763036b62598ebf372e1..e74dafc553689cb82f3adb844322e30151ab7b21 100644 --- a/libc/pthread/pthread_attr_getaffinity.c +++ b/libc/pthread/pthread_attr_getaffinity.c @@ -56,7 +56,7 @@ * attr * cpuset * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_getinheritsched.c b/libc/pthread/pthread_attr_getinheritsched.c index d8e6515fa8cacce09dc257d34986f5c3b4d77a30..546e52a652f0d67cdfdbeb890840c38fb4d0124c 100644 --- a/libc/pthread/pthread_attr_getinheritsched.c +++ b/libc/pthread/pthread_attr_getinheritsched.c @@ -60,7 +60,7 @@ * attr * inheritsched * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_getschedparam.c b/libc/pthread/pthread_attr_getschedparam.c index 3de2a3b7a28bfaa94fb8a8c6d882833b4658f1f8..408fa938945ee38f4b4daaa5d80749c43cf3c9de 100644 --- a/libc/pthread/pthread_attr_getschedparam.c +++ b/libc/pthread/pthread_attr_getschedparam.c @@ -58,7 +58,7 @@ * attr * param * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_getschedpolicy.c b/libc/pthread/pthread_attr_getschedpolicy.c index ca819b8ffa48a9aa727bf52d020c14e394220a65..f3c06455b4f8a0c8c918d80531e1ba7dfd6b3834 100644 --- a/libc/pthread/pthread_attr_getschedpolicy.c +++ b/libc/pthread/pthread_attr_getschedpolicy.c @@ -57,7 +57,7 @@ * attr * policy * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_getstacksize.c b/libc/pthread/pthread_attr_getstacksize.c index 858cf88c9d18234b1a74bc1ed9586923be29cd83..ba64db65789138e57158bbe6ad508ba215ef3609 100644 --- a/libc/pthread/pthread_attr_getstacksize.c +++ b/libc/pthread/pthread_attr_getstacksize.c @@ -56,7 +56,7 @@ * attr * stacksize * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_init.c b/libc/pthread/pthread_attr_init.c index 256be4b2356af7b4ebd7c24a69ad82c2110f9961..60af413b87da79513cc378c840838692e5f6f201 100644 --- a/libc/pthread/pthread_attr_init.c +++ b/libc/pthread/pthread_attr_init.c @@ -76,7 +76,7 @@ const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER; * Parameters: * attr * - * Return Value: + * Returned Value: * 0 on success, otherwise an error number * * Assumptions: diff --git a/libc/pthread/pthread_attr_setaffinity.c b/libc/pthread/pthread_attr_setaffinity.c index 83f8e337cf568a28166e55169e59616984113c2e..ce2029f6093763b9a0d41139a5135b2eec4c5883 100644 --- a/libc/pthread/pthread_attr_setaffinity.c +++ b/libc/pthread/pthread_attr_setaffinity.c @@ -57,7 +57,7 @@ * attr * stacksize * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_setinheritsched.c b/libc/pthread/pthread_attr_setinheritsched.c index 36b1d1dba1adecb1af706d647ce6aa1d11195d9e..c202c9dbab3bf554c63089d36c7f9ef47f8b0eee 100644 --- a/libc/pthread/pthread_attr_setinheritsched.c +++ b/libc/pthread/pthread_attr_setinheritsched.c @@ -61,7 +61,7 @@ * attr * policy * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_setschedparam.c b/libc/pthread/pthread_attr_setschedparam.c index 812ebee8592c558c271902e19e0f40694b5d55ae..c6972ced3f48d218797a3049aeece9df353f34d2 100644 --- a/libc/pthread/pthread_attr_setschedparam.c +++ b/libc/pthread/pthread_attr_setschedparam.c @@ -58,7 +58,7 @@ * attr * param * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_setschedpolicy.c b/libc/pthread/pthread_attr_setschedpolicy.c index 9d7ce10fff30555f41bd89b62bdbd68978a6a671..724c442e06364b6763ba4fd44fa49b84fa081334 100644 --- a/libc/pthread/pthread_attr_setschedpolicy.c +++ b/libc/pthread/pthread_attr_setschedpolicy.c @@ -59,7 +59,7 @@ * attr * policy * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_attr_setstacksize.c b/libc/pthread/pthread_attr_setstacksize.c index f69fc7df9c40cecd417f489671ebfbbf6787009c..6a0b8d4aeb129a1434c6ae8111b72ab3b4b466d5 100644 --- a/libc/pthread/pthread_attr_setstacksize.c +++ b/libc/pthread/pthread_attr_setstacksize.c @@ -57,7 +57,7 @@ * attr * stacksize * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_barrierattr_destroy.c b/libc/pthread/pthread_barrierattr_destroy.c index 663f449981047c106b7c53e61d3d2a6e7480c66a..ca7dcd9e64683073051eaf614b82475837954ac8 100644 --- a/libc/pthread/pthread_barrierattr_destroy.c +++ b/libc/pthread/pthread_barrierattr_destroy.c @@ -59,7 +59,7 @@ * Parameters: * attr - barrier attributes to be destroyed. * - * Return Value: + * Returned Value: * 0 (OK) on success or EINVAL if attr is invalid. * * Assumptions: diff --git a/libc/pthread/pthread_barrierattr_getpshared.c b/libc/pthread/pthread_barrierattr_getpshared.c index 3964a801ca80079606087fdebcad69d9235c2869..2f4fd22533ef1ab7e8e1b3bc004481402d6d1bbc 100644 --- a/libc/pthread/pthread_barrierattr_getpshared.c +++ b/libc/pthread/pthread_barrierattr_getpshared.c @@ -58,7 +58,7 @@ * attr - barrier attributes to be queried. * pshared - the location to stored the current value of the pshared attribute. * - * Return Value: + * Returned Value: * 0 (OK) on success or EINVAL if either attr or pshared is invalid. * * Assumptions: diff --git a/libc/pthread/pthread_barrierattr_init.c b/libc/pthread/pthread_barrierattr_init.c index e8270f6b985409f0fa6260c30e5408310d6fadb2..f2a5527da732a92a1650cf79bdff723726b4bb96 100644 --- a/libc/pthread/pthread_barrierattr_init.c +++ b/libc/pthread/pthread_barrierattr_init.c @@ -58,7 +58,7 @@ * Parameters: * attr - barrier attributes to be initialized. * - * Return Value: + * Returned Value: * 0 (OK) on success or EINVAL if attr is invalid. * * Assumptions: diff --git a/libc/pthread/pthread_barrierattr_setpshared.c b/libc/pthread/pthread_barrierattr_setpshared.c index 76109ac08cf94df0983f7f60e0b5329ec5ed4d4b..b26ef1746edf5a7cd26a9142e169bc8e3aef9108 100644 --- a/libc/pthread/pthread_barrierattr_setpshared.c +++ b/libc/pthread/pthread_barrierattr_setpshared.c @@ -87,7 +87,7 @@ * attr - barrier attributes to be modified. * pshared - the new value of the pshared attribute. * - * Return Value: + * Returned Value: * 0 (OK) on success or EINVAL if either attr is invalid or pshared is not one * of PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE. * diff --git a/libc/pthread/pthread_barrierdestroy.c b/libc/pthread/pthread_barrierdestroy.c index 3f74e06c4927db6f7f839297a323e14bf1170157..19a007b02af55fd347b6c67cff4c4e52e6b9a884 100644 --- a/libc/pthread/pthread_barrierdestroy.c +++ b/libc/pthread/pthread_barrierdestroy.c @@ -63,7 +63,7 @@ * Parameters: * barrier - barrier to be destroyed. * - * Return Value: + * Returned Value: * 0 (OK) on success or on of the following error numbers: * * EBUSY The implementation has detected an attempt to destroy a barrier diff --git a/libc/pthread/pthread_barrierinit.c b/libc/pthread/pthread_barrierinit.c index 6f8d427dfe29f77a7fd5274687cd46264c32f1dc..c9c60cefaa582795019f9a3cfd339b76d290eed4 100644 --- a/libc/pthread/pthread_barrierinit.c +++ b/libc/pthread/pthread_barrierinit.c @@ -69,7 +69,7 @@ * pthread_barrier_wait() before any of them successfully return from * the call. The value specified by count must be greater than zero. * - * Return Value: + * Returned Value: * 0 (OK) on success or on of the following error numbers: * * EAGAIN The system lacks the necessary resources to initialize another diff --git a/libc/pthread/pthread_barrierwait.c b/libc/pthread/pthread_barrierwait.c index 8ba29d1d94dece211ef2537048dc8c3b39d945bc..ed51b62c01b5d14ca4dd0ae32e7256c22f46f151 100644 --- a/libc/pthread/pthread_barrierwait.c +++ b/libc/pthread/pthread_barrierwait.c @@ -86,7 +86,7 @@ * Parameters: * barrier - the barrier to wait on * - * Return Value: + * Returned Value: * 0 (OK) on success or EINVAL if the barrier is not valid. * * Assumptions: diff --git a/libc/pthread/pthread_condattr_destroy.c b/libc/pthread/pthread_condattr_destroy.c index 12bee245dccd840efd210752d061a5e139743dfc..2f97ffbd6fab60a5f5e5f4cb97dce9b1bd105ce0 100644 --- a/libc/pthread/pthread_condattr_destroy.c +++ b/libc/pthread/pthread_condattr_destroy.c @@ -56,7 +56,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/pthread/pthread_condattr_init.c b/libc/pthread/pthread_condattr_init.c index 8865868b81f32ff49517c6fc5c19b803dc381e4c..9f23736233212b6aba7c8804bd7b6fd11a35ffd3 100644 --- a/libc/pthread/pthread_condattr_init.c +++ b/libc/pthread/pthread_condattr_init.c @@ -56,7 +56,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/pthread/pthread_conddestroy.c b/libc/pthread/pthread_conddestroy.c index a691b60d7d6579e130924e09d8b3bbe261b5e8f0..44e6e4cab5105a033d5a926778d16295b7383eb8 100644 --- a/libc/pthread/pthread_conddestroy.c +++ b/libc/pthread/pthread_conddestroy.c @@ -56,7 +56,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/pthread/pthread_condinit.c b/libc/pthread/pthread_condinit.c index 81a31ea57fa0447c0add7605c91784d216a2277d..d19601f196f430233a4a946eb3804438bf6f4a7c 100644 --- a/libc/pthread/pthread_condinit.c +++ b/libc/pthread/pthread_condinit.c @@ -59,7 +59,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/pthread/pthread_mutexattr_destroy.c b/libc/pthread/pthread_mutexattr_destroy.c index 01c8a6589a607c7c9a260d407833e2d04efabed9..f8fe9e057e903819eb09ca61848ad88de3fd48da 100644 --- a/libc/pthread/pthread_mutexattr_destroy.c +++ b/libc/pthread/pthread_mutexattr_destroy.c @@ -56,7 +56,7 @@ * Parameters: * attr * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_mutexattr_getprotocol.c b/libc/pthread/pthread_mutexattr_getprotocol.c index 7cc6065d367b85181e52c86fbbfffdfe2bd64b92..b83e289f42fd31b4c450175817fea1f0a2f874e1 100644 --- a/libc/pthread/pthread_mutexattr_getprotocol.c +++ b/libc/pthread/pthread_mutexattr_getprotocol.c @@ -58,7 +58,7 @@ * protocol - The user provided location in which to store the protocol * value. * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * ****************************************************************************/ diff --git a/libc/pthread/pthread_mutexattr_getpshared.c b/libc/pthread/pthread_mutexattr_getpshared.c index 6d219fb08565d4e992787bb8c9111ad0f201041b..ea398bed6c5af2d07c1e733d79096953da4c4dff 100644 --- a/libc/pthread/pthread_mutexattr_getpshared.c +++ b/libc/pthread/pthread_mutexattr_getpshared.c @@ -57,7 +57,7 @@ * attr * pshared * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_mutexattr_getrobust.c b/libc/pthread/pthread_mutexattr_getrobust.c index 4db30f6b75ff22d9d9dec19aa8dbfde84b99c69d..4bf88ff7ea61091286e1dbb5b17a3ab752ee6827 100644 --- a/libc/pthread/pthread_mutexattr_getrobust.c +++ b/libc/pthread/pthread_mutexattr_getrobust.c @@ -55,7 +55,7 @@ * attr - The mutex attributes to query * robust - Location to return the robustness indication * - * Return Value: + * Returned Value: * 0, if the robustness was successfully return in 'robust', or * EINVAL, if any NULL pointers provided. * diff --git a/libc/pthread/pthread_mutexattr_gettype.c b/libc/pthread/pthread_mutexattr_gettype.c index c45008f8d4e9ba93d0817c85cd81e49cd300bf55..46e7076233b0beb7e759462ea494a923f913600f 100644 --- a/libc/pthread/pthread_mutexattr_gettype.c +++ b/libc/pthread/pthread_mutexattr_gettype.c @@ -55,7 +55,7 @@ * attr - The mutex attributes to query * type - Location to return the mutex type * - * Return Value: + * Returned Value: * 0, if the mutex type was successfully return in 'type', or * EINVAL, if any NULL pointers provided. * diff --git a/libc/pthread/pthread_mutexattr_init.c b/libc/pthread/pthread_mutexattr_init.c index 6f241881527996ea0e69df028fc6333ff02dece3..c0441c7ed2974dcacd8d5e33a3befe46f9608225 100644 --- a/libc/pthread/pthread_mutexattr_init.c +++ b/libc/pthread/pthread_mutexattr_init.c @@ -56,7 +56,7 @@ * Parameters: * attr * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_mutexattr_setprotocol.c b/libc/pthread/pthread_mutexattr_setprotocol.c index e2a8a45ac501f0cc7f00eadbba7be4d3a53db247..117c626248dae7885cf13d2f594e32978018f27c 100644 --- a/libc/pthread/pthread_mutexattr_setprotocol.c +++ b/libc/pthread/pthread_mutexattr_setprotocol.c @@ -58,7 +58,7 @@ * attr - A pointer to the mutex attributes to be modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * ****************************************************************************/ diff --git a/libc/pthread/pthread_mutexattr_setpshared.c b/libc/pthread/pthread_mutexattr_setpshared.c index 054c4db07e4531aafe6d4354bb43b1df48de9484..575e38036e0780085f3297e122b0c02f8bbbf0a5 100644 --- a/libc/pthread/pthread_mutexattr_setpshared.c +++ b/libc/pthread/pthread_mutexattr_setpshared.c @@ -57,7 +57,7 @@ * attr * pshared * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/libc/pthread/pthread_mutexattr_setrobust.c b/libc/pthread/pthread_mutexattr_setrobust.c index aeb2714e93d45db3cb0ec678985e8c52ae33bfd1..6a231bd2edfadb60ae388b88d31a046b91e06c4e 100644 --- a/libc/pthread/pthread_mutexattr_setrobust.c +++ b/libc/pthread/pthread_mutexattr_setrobust.c @@ -55,7 +55,7 @@ * attr - The mutex attributes in which to set the mutex type. * robust - The mutex type value to set. * - * Return Value: + * Returned Value: * 0, if the mutex robustness was successfully set in 'attr', or * EINVAL, if 'attr' is NULL or 'robust' unrecognized. * diff --git a/libc/pthread/pthread_mutexattr_settype.c b/libc/pthread/pthread_mutexattr_settype.c index 02e1832cd6c8762e36fa2eec8f04af4e9720f893..7c501b62217eb2f4320ab059002775694bce4ec8 100644 --- a/libc/pthread/pthread_mutexattr_settype.c +++ b/libc/pthread/pthread_mutexattr_settype.c @@ -55,7 +55,7 @@ * attr - The mutex attributes in which to set the mutex type. * type - The mutex type value to set. * - * Return Value: + * Returned Value: * 0, if the mutex type was successfully set in 'attr', or * EINVAL, if 'attr' is NULL or 'type' unrecognized. * diff --git a/libc/pthread/pthread_once.c b/libc/pthread/pthread_once.c index d73dde966fc1d9da17149a5f2c2f54cc98c76e5d..2f067decbb909dcbb1d32c735b190463a72538b0 100644 --- a/libc/pthread/pthread_once.c +++ b/libc/pthread/pthread_once.c @@ -67,7 +67,7 @@ * PTHREAD_ONCE_INIT is defined in pthread.h * init_routine - The initialization routine that will be called once. * - * Return Value: + * Returned Value: * 0 (OK) on success or EINVAL if either once_control or init_routine are * invalid * diff --git a/libc/pthread/pthread_rwlock_rdlock.c b/libc/pthread/pthread_rwlock_rdlock.c index 4eadfedccb5d4530b4d0f36d98f70375bf12833e..1b23abcc92557b0ad92902d88595a062855f9706 100644 --- a/libc/pthread/pthread_rwlock_rdlock.c +++ b/libc/pthread/pthread_rwlock_rdlock.c @@ -93,7 +93,7 @@ static int tryrdlock(FAR pthread_rwlock_t *rw_lock) * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/pthread/pthread_rwlock_wrlock.c b/libc/pthread/pthread_rwlock_wrlock.c index c9f4f3a7c56ad1b2f28aab579b46a587a40df1a1..73b1ce276204f499c6fce051435c94019b35fda3 100644 --- a/libc/pthread/pthread_rwlock_wrlock.c +++ b/libc/pthread/pthread_rwlock_wrlock.c @@ -73,7 +73,7 @@ static void wrlock_cleanup(FAR void *arg) * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/pthread/pthread_setcancelstate.c b/libc/pthread/pthread_setcancelstate.c index e81a4440f7a46536c0a29bbff42648e0d9e38bed..457d26f1ab17d74db250ed58d313a36f428362a9 100644 --- a/libc/pthread/pthread_setcancelstate.c +++ b/libc/pthread/pthread_setcancelstate.c @@ -85,7 +85,7 @@ int pthread_setcancelstate(int state, FAR int *oldstate) ret = task_setcancelstate(state, oldstate); if (ret < 0) { - ret = errno; + ret = get_errno(); } return ret; diff --git a/libc/pthread/pthread_setcanceltype.c b/libc/pthread/pthread_setcanceltype.c index 583376dfcc53e3401ab5ebd4290fc4c68c6f1610..590fa03b8c3438d8a24761fada02adb7f980dd72 100644 --- a/libc/pthread/pthread_setcanceltype.c +++ b/libc/pthread/pthread_setcanceltype.c @@ -85,7 +85,7 @@ int pthread_setcanceltype(int type, FAR int *oldtype) ret = task_setcanceltype(type, oldtype); if (ret < 0) { - ret = errno; + ret = get_errno(); } return ret; diff --git a/libc/pthread/pthread_startup.c b/libc/pthread/pthread_startup.c index 3d2b76ce8f95318d8070cc390c1112226bec5a5f..a1f8e64f5ebfd25aaf5a279ce192eb36d3e82985 100644 --- a/libc/pthread/pthread_startup.c +++ b/libc/pthread/pthread_startup.c @@ -82,11 +82,11 @@ * This function is the user-space, pthread startup function. It is called * from up_pthread_start() in user-mode. * - * Inputs: + * Input Parameters: * entrypt - The user-space address of the pthread entry point * arg - Standard argument for the pthread entry point * - * Return: + * Returned Value: * None. This function does not return. * ****************************************************************************/ diff --git a/libc/pthread/pthread_yield.c b/libc/pthread/pthread_yield.c index 2af7ea2b9334904206042724cb9f82d4dd49837f..78ee5a7bb7a8e5b76ebd9567f7cbf6bc306b1be4 100644 --- a/libc/pthread/pthread_yield.c +++ b/libc/pthread/pthread_yield.c @@ -54,7 +54,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/libc/queue/dq_addlast.c b/libc/queue/dq_addlast.c index a18ec9083bde3d2db878e0326a5aa2581506ec25..51a423b813a8745f557b596d0e0933b5f1613931 100644 --- a/libc/queue/dq_addlast.c +++ b/libc/queue/dq_addlast.c @@ -46,7 +46,7 @@ /**************************************************************************** * Name: dq_addlast * - * Description + * Description: * dq_addlast adds 'node' to the end of 'queue' * ****************************************************************************/ diff --git a/libc/queue/dq_rem.c b/libc/queue/dq_rem.c index 2c6176ae1dd2779fcb7d545338c7d6e7e2d95321..d53b6922340ff8970e28fe2f11586701ca9c22d7 100644 --- a/libc/queue/dq_rem.c +++ b/libc/queue/dq_rem.c @@ -46,7 +46,7 @@ /**************************************************************************** * Name: dq_rem * - * Descripton: + * Description: * dq_rem removes 'node' from 'queue' * ****************************************************************************/ diff --git a/libc/sched/sched_cpucount.c b/libc/sched/sched_cpucount.c index 6bdac1111763ac7fb1bcd12b6cb1d151ddd1c85f..5f7f151ec035f75c812384a3ae2364df8df757e6 100644 --- a/libc/sched/sched_cpucount.c +++ b/libc/sched/sched_cpucount.c @@ -54,10 +54,10 @@ * Return the number of bits set in the 'set'. This could be improved by * using CPU-specific bit counting instructions. * - * Inputs: + * Input Parameters: * set - The set of CPUs to be counted. * - * Return Value: + * Returned Value: * The number of CPUs in 'set' * ****************************************************************************/ diff --git a/libc/sched/sched_getprioritymax.c b/libc/sched/sched_getprioritymax.c index 03660cbb8d49dde907fa34b17de444922dd672f6..4ca6bf6119451e7c8e351c676caf84c9f6b6dead 100644 --- a/libc/sched/sched_getprioritymax.c +++ b/libc/sched/sched_getprioritymax.c @@ -54,10 +54,10 @@ * This function returns the value of the highest possible * task priority for a specified scheduling policy. * - * Inputs: + * Input Parameters: * policy - Scheduling policy requested. * - * Return Value: + * Returned Value: * The maximum priority value or -1 (ERROR) * (errno is not set) * diff --git a/libc/sched/sched_getprioritymin.c b/libc/sched/sched_getprioritymin.c index 660677f8ca458dd29cc536dcde1d8e8703d7c42a..4a39350107065a3e01d3e53511c192069a692949 100644 --- a/libc/sched/sched_getprioritymin.c +++ b/libc/sched/sched_getprioritymin.c @@ -54,10 +54,10 @@ * This function returns the value of the lowest possible * task priority for a specified scheduling policy. * - * Inputs: + * Input Parameters: * policy - Scheduling policy requested. * - * Return Value: + * Returned Value: * The minimum priority value or -1 (ERROR) * (errno is not set) * diff --git a/libc/sched/task_startup.c b/libc/sched/task_startup.c index c0895a16b81d49fca62089c7cfd33d30b498139d..2d14b47fa1f8c961476effadf5631f2403ead20c 100644 --- a/libc/sched/task_startup.c +++ b/libc/sched/task_startup.c @@ -57,11 +57,11 @@ * This function is the user-space, task startup function. It is called * from up_task_start() in user-mode. * - * Inputs: + * Input Parameters: * entrypt - The user-space address of the task entry point * argc and argv - Standard arguments for the task entry point * - * Return: + * Returned Value: * None. This function does not return. * ****************************************************************************/ diff --git a/libc/semaphore/sem_getprotocol.c b/libc/semaphore/sem_getprotocol.c index 308f1ea5208ef60d171e28dc6fbecd769e79030d..436113b015d1ad400a0354610d2734ff7c9749e1 100644 --- a/libc/semaphore/sem_getprotocol.c +++ b/libc/semaphore/sem_getprotocol.c @@ -59,7 +59,7 @@ * protocol - The user provided location in which to store the protocol * value. * - * Return Value: + * Returned Value: * This function is exposed as a non-standard application interface. It * returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. diff --git a/libc/semaphore/sem_getvalue.c b/libc/semaphore/sem_getvalue.c index 120dae1372b21e59fa892ab4b72df2e72d9fc8f8..bde910f16ebb4d487cb816c35fa1deaa1846941d 100644 --- a/libc/semaphore/sem_getvalue.c +++ b/libc/semaphore/sem_getvalue.c @@ -68,7 +68,7 @@ * sem - Semaphore descriptor * sval - Buffer by which the value is returned * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -77,7 +77,7 @@ int nxsem_getvalue(FAR sem_t *sem, FAR int *sval) { - if (sem && sval) + if (sem != NULL && sval != NULL) { *sval = sem->semcount; return OK; diff --git a/libc/semaphore/sem_init.c b/libc/semaphore/sem_init.c index 99b77317f6aaca663c4446d14206a501ba4aa965..b26b0b5937076e42cafaa2e57086feb4ef6a806f 100644 --- a/libc/semaphore/sem_init.c +++ b/libc/semaphore/sem_init.c @@ -68,7 +68,7 @@ * pshared - Process sharing (not used) * value - Semaphore initialization value * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -124,7 +124,7 @@ int nxsem_init(FAR sem_t *sem, int pshared, unsigned int value) * pshared - Process sharing (not used) * value - Semaphore initialization value * - * Return Value: + * Returned Value: * This returns zero (OK) if successful. Otherwise, -1 (ERROR) is * returned and the errno value is set appropriately. * diff --git a/libc/semaphore/sem_setprotocol.c b/libc/semaphore/sem_setprotocol.c index ac82cf719a7db399fc317f15bed6480a387ead5e..b64f4665462aa88dd1220a81e6334f5922ddf79e 100644 --- a/libc/semaphore/sem_setprotocol.c +++ b/libc/semaphore/sem_setprotocol.c @@ -80,7 +80,7 @@ * modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * This function is exposed as a non-standard application interface. It * returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. @@ -138,7 +138,7 @@ int nxsem_setprotocol(FAR sem_t *sem, int protocol) * modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * This function is exposed as a non-standard application interface. It * returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. diff --git a/libc/signal/sig_addset.c b/libc/signal/sig_addset.c index 392be1ca691d681f97bf436ce2d2a987945f63d9..6205ef98c66d98d7fe203b706567e13d13d6b91a 100644 --- a/libc/signal/sig_addset.c +++ b/libc/signal/sig_addset.c @@ -55,7 +55,7 @@ * set - Signal set to add signal to * signo - Signal to add * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if the signal number is invalid. * * Assumptions: diff --git a/libc/signal/sig_delset.c b/libc/signal/sig_delset.c index 9c6c608a2d16f2025cdaad5804e4e0822fcc3369..c38685fd723524087ed2f7ba9d4c8919134de263 100644 --- a/libc/signal/sig_delset.c +++ b/libc/signal/sig_delset.c @@ -55,7 +55,7 @@ * set - Signal set to delete the signal from * signo - Signal to delete * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if the signal number is invalid. * * Assumptions: diff --git a/libc/signal/sig_emptyset.c b/libc/signal/sig_emptyset.c index 01b398ad08832d71f8c5526ee73fe167da5ec8ee..7614e6ec6e54059d6b18853c31e59ca6bebfca80 100644 --- a/libc/signal/sig_emptyset.c +++ b/libc/signal/sig_emptyset.c @@ -53,7 +53,7 @@ * Parameters: * set - Signal set to initialize * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if the signal set cannot be initialized. * * Assumptions: diff --git a/libc/signal/sig_fillset.c b/libc/signal/sig_fillset.c index 2586646e37e849cad3c9a781b6b8bf2deda6fe5f..a9344abb1041bbe15cdba830b9d3c0daaf41cd5a 100644 --- a/libc/signal/sig_fillset.c +++ b/libc/signal/sig_fillset.c @@ -53,7 +53,7 @@ * Parameters: * set - Signal set to initalize * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if the signal set cannot be initialized. * * Assumptions: diff --git a/libc/signal/sig_ismember.c b/libc/signal/sig_ismember.c index 2fbac5f6c856c5e91bd337ccdceebf7bcb329b50..5624174e0e7c4b9ffaf8f88f2dad7c229da4741f 100644 --- a/libc/signal/sig_ismember.c +++ b/libc/signal/sig_ismember.c @@ -54,7 +54,7 @@ * set - Signal set to test * signo - Signal to test for * - * Return Value: + * Returned Value: * 1 (true), if the specified signal is a member of the set, * 0 (OK or FALSE), if it is not, or * -1 (ERROR) if the signal number is invalid. diff --git a/libc/spawn/lib_psa_init.c b/libc/spawn/lib_psa_init.c index 4ee16ff62627d1d68f6f0d1787fd85632c0a7811..64d58afc740e93a54d4133694f93051a2d55991c 100644 --- a/libc/spawn/lib_psa_init.c +++ b/libc/spawn/lib_psa_init.c @@ -1,7 +1,7 @@ /**************************************************************************** * libc/string/lib_psa_init.c * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,9 +44,7 @@ #include #include -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ +#include /**************************************************************************** * Public Functions @@ -82,17 +80,23 @@ int posix_spawnattr_init(posix_spawnattr_t *attr) /* Set the default priority to the same priority as this task */ - ret = sched_getparam(0, ¶m); + ret = _SCHED_GETPARAM(0, ¶m); if (ret < 0) { - return errno; + return _SCHED_ERRNO(ret); } attr->priority = param.sched_priority; /* Set the default scheduler policy to the policy of this task */ - attr->policy = sched_getscheduler(0); + ret = _SCHED_GETSCHEDULER(0); + if (ret < 0) + { + return _SCHED_ERRNO(ret); + } + + attr->policy = ret; #ifndef CONFIG_DISABLE_SIGNALS /* Empty signal mask */ diff --git a/libc/stdio/lib_fclose.c b/libc/stdio/lib_fclose.c index 022d7bde8eba14c6ce2138c4dc6e8d6a6a9b3daa..138cdc14f702136c4cbb6cb3808bccdf74fed3e7 100644 --- a/libc/stdio/lib_fclose.c +++ b/libc/stdio/lib_fclose.c @@ -54,7 +54,7 @@ /**************************************************************************** * Name: fclose * - * Description + * Description: * The fclose() function will flush the stream pointed to by stream * (writing any buffered output data using lib_fflush()) and close the * underlying file descriptor. @@ -89,7 +89,7 @@ int fclose(FAR FILE *stream) if ((stream->fs_oflags & O_WROK) != 0) { ret = lib_fflush(stream, true); - errcode = errno; + errcode = get_errno(); } /* Close the underlying file descriptor and save the return status */ @@ -103,7 +103,7 @@ int fclose(FAR FILE *stream) if (ret == OK) { ret = status; - errcode = errno; + errcode = get_errno(); } } diff --git a/libc/stdio/lib_ferror.c b/libc/stdio/lib_ferror.c index 4d324c8081106a21ca2d937528668e02452ca8ba..3bec087b6d4115aa5e1b802ba035ebbca1f229f7 100644 --- a/libc/stdio/lib_ferror.c +++ b/libc/stdio/lib_ferror.c @@ -57,7 +57,7 @@ * This function will test if the last operation resulted in an eror. This * is used to disambiguate EOF and error conditions. * - * Return Value: + * Returned Value: * A non-zero value is returned to indicate the error condition. * ****************************************************************************/ diff --git a/libc/stdio/lib_fflush.c b/libc/stdio/lib_fflush.c index dd3e17831691f39195e0a0367910f2ba641c13aa..032ee023f4983ff77e300f844cb9637e8e4c3f30 100644 --- a/libc/stdio/lib_fflush.c +++ b/libc/stdio/lib_fflush.c @@ -62,7 +62,7 @@ * * If the stream argument is NULL, fflush() flushes all open output streams. * - * Return: + * Returned Value: * OK on success EOF on failure (with errno set appropriately) * ****************************************************************************/ diff --git a/libc/stdio/lib_freopen.c b/libc/stdio/lib_freopen.c index 0fffc1bd9618d4d7e53703ea285d12e782f4ff13..950be9ce059162738493dc1543a41debcf6316d1 100644 --- a/libc/stdio/lib_freopen.c +++ b/libc/stdio/lib_freopen.c @@ -70,7 +70,7 @@ * The error indicator and eof indicator are automatically cleared (as if * clearerr was called). * - * Input Paramters: + * Input Parameters: * path - If non-NULL, refers to the name of the file to be opened. * mode - String describing the new file access mode * stream - Pointer to the type FILE to be reopened. diff --git a/libc/stdio/lib_libdtoa.c b/libc/stdio/lib_libdtoa.c index 6dff3bc0e992f1f8b524fa1438e91dc3999c2c93..80c9723d1560ae947f8f5a088b5a0f691b99879e 100644 --- a/libc/stdio/lib_libdtoa.c +++ b/libc/stdio/lib_libdtoa.c @@ -138,6 +138,7 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, int dsgn; /* Unused sign indicator */ int i; +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) /* This function may *NOT* be called within interrupt level logic. That is * because the logic in __dtoa may attempt to allocate memory. That will * lead to cryptic failures down the road within the memory manager. @@ -146,6 +147,7 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, */ DEBUGASSERT(up_interrupt_context() == false); +#endif /* Special handling for NaN and Infinity */ diff --git a/libc/stdio/lib_libfflush.c b/libc/stdio/lib_libfflush.c index 29a44cfe22e5089f16705b0628eb0228bf88c274..22482eb879005eebecb99854c93bacd8ca188d4d 100644 --- a/libc/stdio/lib_libfflush.c +++ b/libc/stdio/lib_libfflush.c @@ -65,7 +65,7 @@ * stream - the stream to flush * bforce - flush must be complete. * - * Return: + * Returned Value: * A negated errno value on failure, otherwise the number of bytes remaining * in the buffer. * diff --git a/libc/stdio/lib_libnoflush.c b/libc/stdio/lib_libnoflush.c index f862cd68748c99532d9cf35b07b69cf73caeb55c..b7daabb2d7c4bfbd30fbeee2bbef50d2709a3dd6 100644 --- a/libc/stdio/lib_libnoflush.c +++ b/libc/stdio/lib_libnoflush.c @@ -60,7 +60,7 @@ * lib_noflush() provides a common, dummy flush method for output streams * that are not flushable. * - * Return: + * Returned Value: * Always returns OK * ****************************************************************************/ diff --git a/libc/stdio/lib_libsnoflush.c b/libc/stdio/lib_libsnoflush.c index 652b977cf69a0ab5a4a8e5ce9ee5e3c2dc86f210..8d95fad48cc7277e93c752729bf53a7681d81aec 100644 --- a/libc/stdio/lib_libsnoflush.c +++ b/libc/stdio/lib_libsnoflush.c @@ -59,7 +59,7 @@ * lib_snoflush() provides a common, dummy flush method for seekable output * streams that are not flushable. * - * Return: + * Returned Value: * Always returns OK * ****************************************************************************/ diff --git a/libc/stdio/lib_lowoutstream.c b/libc/stdio/lib_lowoutstream.c index 8447051d39da32f6d7245ec9e9c01ac50b7a71e2..1896660d358b507be497f6c4388945804516b794 100644 --- a/libc/stdio/lib_lowoutstream.c +++ b/libc/stdio/lib_lowoutstream.c @@ -76,7 +76,7 @@ static void lowoutstream_putc(FAR struct lib_outstream_s *this, int ch) * Description: * Initializes a stream for use with low-level, architecture-specific I/O. * - * Input parameters: + * Input Parameters: * stream - User allocated, uninitialized instance of struct * lib_lowoutstream_s to be initialized. * diff --git a/libc/stdio/lib_meminstream.c b/libc/stdio/lib_meminstream.c index 0fdcd8f92f1438425967f6146e1d68302bfdebd3..ef888d9e7dda8941a59c9174c90449d51044eeca 100644 --- a/libc/stdio/lib_meminstream.c +++ b/libc/stdio/lib_meminstream.c @@ -81,7 +81,7 @@ static int meminstream_getc(FAR struct lib_instream_s *this) * Description: * Initializes a stream for use with a fixed-size memory buffer. * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_meminstream_s to be initialized. * bufstart - Address of the beginning of the fixed-size memory buffer diff --git a/libc/stdio/lib_memoutstream.c b/libc/stdio/lib_memoutstream.c index 28137d07ed72ce7965f5005273a7c4221648c170..80b8a36609ff83cbb11e5adb4f43b4577f84d885 100644 --- a/libc/stdio/lib_memoutstream.c +++ b/libc/stdio/lib_memoutstream.c @@ -78,7 +78,7 @@ static void memoutstream_putc(FAR struct lib_outstream_s *this, int ch) * Description: * Initializes a stream for use with a fixed-size memory buffer. * - * Input parameters: + * Input Parameters: * outstream - User allocated, uninitialized instance of struct * lib_memoutstream_s to be initialized. * bufstart - Address of the beginning of the fixed-size memory buffer diff --git a/libc/stdio/lib_memsistream.c b/libc/stdio/lib_memsistream.c index af241b4c2ed8f23a5fce6811d2e54fd907055754..1bfda9ea2fa533665637b2f8badafe4b2169f7bf 100644 --- a/libc/stdio/lib_memsistream.c +++ b/libc/stdio/lib_memsistream.c @@ -125,7 +125,7 @@ static off_t memsistream_seek(FAR struct lib_sistream_s *this, off_t offset, * Description: * Initializes a stream for use with a fixed-size memory buffer. * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_memsistream_s to be initialized. * bufstart - Address of the beginning of the fixed-size memory buffer diff --git a/libc/stdio/lib_memsostream.c b/libc/stdio/lib_memsostream.c index 93c19facad180ace15a98e7ba2add4527952da0f..93536a34069f2a1d40cca386ad3a0beba0a5595b 100644 --- a/libc/stdio/lib_memsostream.c +++ b/libc/stdio/lib_memsostream.c @@ -122,7 +122,7 @@ static off_t memsostream_seek(FAR struct lib_sostream_s *this, off_t offset, * Description: * Initializes a stream for use with a fixed-size memory buffer. * - * Input parameters: + * Input Parameters: * outstream - User allocated, uninitialized instance of struct * lib_memsostream_s to be initialized. * bufstart - Address of the beginning of the fixed-size memory buffer diff --git a/libc/stdio/lib_nullinstream.c b/libc/stdio/lib_nullinstream.c index 9ca50d6379b4174e9550516113c80cf454dbbf24..67d930b8d86caab5259f9452dde25d699ba7cc35 100644 --- a/libc/stdio/lib_nullinstream.c +++ b/libc/stdio/lib_nullinstream.c @@ -62,7 +62,7 @@ static int nullinstream_getc(FAR struct lib_instream_s *this) * Initializes a NULL stream. The initialized stream will will return only * EOF. * - * Input parameters: + * Input Parameters: * nullinstream - User allocated, uninitialized instance of struct * lib_instream_s to be initialized. * diff --git a/libc/stdio/lib_nulloutstream.c b/libc/stdio/lib_nulloutstream.c index 47f2acd58a401c3b1826835c7afd4e197ad05745..1f92028e3c9fa0400d099bcb817ecc581b2e4d9d 100644 --- a/libc/stdio/lib_nulloutstream.c +++ b/libc/stdio/lib_nulloutstream.c @@ -64,7 +64,7 @@ static void nulloutstream_putc(FAR struct lib_outstream_s *this, int ch) * Initializes a NULL streams. The initialized stream will write all data * to the bit-bucket. * - * Input parameters: + * Input Parameters: * nulloutstream - User allocated, uninitialized instance of struct * lib_outstream_s to be initialized. * diff --git a/libc/stdio/lib_rawinstream.c b/libc/stdio/lib_rawinstream.c index e37f3630fd5c6a1af0d0b0522100add2b58d5ca6..a0e4919c27c2cf24297ac220e9894a0de63df813 100644 --- a/libc/stdio/lib_rawinstream.c +++ b/libc/stdio/lib_rawinstream.c @@ -104,7 +104,7 @@ static off_t rawsistream_seek(FAR struct lib_sistream_s *this, off_t offset, * Description: * Initializes a stream for use with a file descriptor. * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_rawsistream_s to be initialized. * fd - User provided file/socket descriptor (must have been opened diff --git a/libc/stdio/lib_rawoutstream.c b/libc/stdio/lib_rawoutstream.c index 69155fc15c6d0e055b685baac46d9d0d0431636d..20e19e44a5a11b766cf90a97b855cc58f05e7325 100644 --- a/libc/stdio/lib_rawoutstream.c +++ b/libc/stdio/lib_rawoutstream.c @@ -111,7 +111,7 @@ static off_t rawsostream_seek(FAR struct lib_sostream_s *this, off_t offset, * Description: * Initializes a stream for use with a file descriptor. * - * Input parameters: + * Input Parameters: * outstream - User allocated, uninitialized instance of struct * lib_rawsostream_s to be initialized. * fd - User provided file/socket descriptor (must have been opened diff --git a/libc/stdio/lib_rawsistream.c b/libc/stdio/lib_rawsistream.c index d332728c07f0f45849fc53065ee07ad39357380f..3d8d4fd1fe2529510c397483f62bb2bdaf16d50b 100644 --- a/libc/stdio/lib_rawsistream.c +++ b/libc/stdio/lib_rawsistream.c @@ -91,7 +91,7 @@ static int rawinstream_getc(FAR struct lib_instream_s *this) * Description: * Initializes a stream for use with a file descriptor. * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_rawinstream_s to be initialized. * fd - User provided file/socket descriptor (must have been opened diff --git a/libc/stdio/lib_rawsostream.c b/libc/stdio/lib_rawsostream.c index 1579e1db6de25b7e36156e51c699413f5495950c..4f05a0bf742efbd39d3ec342d6fbe26968afd5a1 100644 --- a/libc/stdio/lib_rawsostream.c +++ b/libc/stdio/lib_rawsostream.c @@ -98,7 +98,7 @@ static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch) * Description: * Initializes a stream for use with a file descriptor. * - * Input parameters: + * Input Parameters: * outstream - User allocated, uninitialized instance of struct * lib_rawoutstream_s to be initialized. * fd - User provided file/socket descriptor (must have been opened diff --git a/libc/stdio/lib_remove.c b/libc/stdio/lib_remove.c index 3c2c8e6d3f0b34703145590a4055c3a9975dbe51..4e3e4765d5a1e7fb6e8a7971ed97ed317c6e884f 100644 --- a/libc/stdio/lib_remove.c +++ b/libc/stdio/lib_remove.c @@ -53,7 +53,7 @@ * The remove() function causes the object denoted by path to be removed. * The function is equivalent to unlink() or rmdir(). * - * Input Parmeters: + * Input Parameters: * path - A pointer to a file or directory to be removed. * * Returned Value: diff --git a/libc/stdio/lib_stdinstream.c b/libc/stdio/lib_stdinstream.c index f1b5f3da998e76502c8b5c8dfa9c8b12f3522f2b..da577595300829d9672bd978494fb7de8708f408 100644 --- a/libc/stdio/lib_stdinstream.c +++ b/libc/stdio/lib_stdinstream.c @@ -77,7 +77,7 @@ static int stdinstream_getc(FAR struct lib_instream_s *this) * Description: * Initializes a stream for use with a FILE instance. * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_stdinstream_s to be initialized. * stream - User provided stream instance (must have been opened for diff --git a/libc/stdio/lib_stdoutstream.c b/libc/stdio/lib_stdoutstream.c index 4c77c745fcc81883e7ef47b585818436604f558e..10fd58b4fbefd0068084ab1a9a29234f7569ab1a 100644 --- a/libc/stdio/lib_stdoutstream.c +++ b/libc/stdio/lib_stdoutstream.c @@ -102,7 +102,7 @@ static int stdoutstream_flush(FAR struct lib_outstream_s *this) * Description: * Initializes a stream for use with a FILE instance. * - * Input parameters: + * Input Parameters: * outstream - User allocated, uninitialized instance of struct * lib_stdoutstream_s to be initialized. * stream - User provided stream instance (must have been opened for diff --git a/libc/stdio/lib_stdsistream.c b/libc/stdio/lib_stdsistream.c index b569bb412222b8772ff827a5cce8990a23929e41..5fd2544729d701ca4bae921b91b6707b0e33fae1 100644 --- a/libc/stdio/lib_stdsistream.c +++ b/libc/stdio/lib_stdsistream.c @@ -90,7 +90,7 @@ static off_t stdsistream_seek(FAR struct lib_sistream_s *this, off_t offset, * Description: * Initializes a stream for use with a FILE instance. * - * Input parameters: + * Input Parameters: * instream - User allocated, uninitialized instance of struct * lib_stdsistream_s to be initialized. * stream - User provided stream instance (must have been opened for diff --git a/libc/stdio/lib_stdsostream.c b/libc/stdio/lib_stdsostream.c index 8654b635620b7d133ac58b33b5bb48621d3a8e50..c7891f0e8c280956ee89cc52b1091e5968da40e2 100644 --- a/libc/stdio/lib_stdsostream.c +++ b/libc/stdio/lib_stdsostream.c @@ -115,7 +115,7 @@ static off_t stdsostream_seek(FAR struct lib_sostream_s *this, off_t offset, * Description: * Initializes a stream for use with a FILE instance. * - * Input parameters: + * Input Parameters: * outstream - User allocated, uninitialized instance of struct * lib_stdsostream_s to be initialized. * stream - User provided stream instance (must have been opened for diff --git a/libc/stdio/lib_zeroinstream.c b/libc/stdio/lib_zeroinstream.c index 506d00587173ee2cc2f670442747ddaf2f530df4..a9d543f4df4301b9adfc6abfb449a2a66aafb3e9 100644 --- a/libc/stdio/lib_zeroinstream.c +++ b/libc/stdio/lib_zeroinstream.c @@ -62,7 +62,7 @@ static int zeroinstream_getc(FAR struct lib_instream_s *this) * Initializes a NULL stream. The initialized stream will return an * infinitely long stream of zeroes. * - * Input parameters: + * Input Parameters: * zeroinstream - User allocated, uninitialized instance of struct * lib_instream_s to be initialized. * diff --git a/libc/stdlib/lib_abort.c b/libc/stdlib/lib_abort.c index f037e8d8cc48068da2dd21bc9ccdd243eb5eab01..87751c5a45e5ea59f25f5d68f448d1953562c97d 100644 --- a/libc/stdlib/lib_abort.c +++ b/libc/stdlib/lib_abort.c @@ -87,7 +87,7 @@ * It does this by restoring the default disposition for SIGABRT and * then raising the signal for a second time. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/libc/stdlib/lib_checkbase.c b/libc/stdlib/lib_checkbase.c index a94140e81ec02dbc762694f63eae9dd94e6abb7a..9d11a1d5364edffe108fc6e0674658d10f97ca41 100644 --- a/libc/stdlib/lib_checkbase.c +++ b/libc/stdlib/lib_checkbase.c @@ -59,7 +59,7 @@ * Assumptions: * *ptr points to the first, non-whitespace character in the string. * - * Returns: + * Returned Value: * - if base is valid, the actual base to use, and pptr is updated to point * at the first digit. * - if base is invalid (<2 or >36), return -1. diff --git a/libc/stdlib/lib_ptsname.c b/libc/stdlib/lib_ptsname.c index 54cdabd69ef7313a9d6aed949f0fbe6b01784dd7..af08e494de8e121170987b2ad8285e9eca69b8e1 100644 --- a/libc/stdlib/lib_ptsname.c +++ b/libc/stdlib/lib_ptsname.c @@ -54,7 +54,7 @@ * The ptsname() function returns the name of the slave pseudoterminal * device corresponding to the master referred to by fd. * - * Returned Values: + * Returned Value: * On success, ptsname() returns a pointer to a string in static storage * which will be overwritten by subsequent calls. This pointer must not * be freed. On failure, NULL is returned. diff --git a/libc/stdlib/lib_ptsnamer.c b/libc/stdlib/lib_ptsnamer.c index e5df9c0ec7eb1b35808de0f5273107529d4914da..17a1ad4b3c108bb1f63bdae475423c939a0bc14e 100644 --- a/libc/stdlib/lib_ptsnamer.c +++ b/libc/stdlib/lib_ptsnamer.c @@ -59,7 +59,7 @@ * terminated string in the buffer pointed to by buf. The buflen * argument specifies the number of bytes available in buf. * - * Returned Values: + * Returned Value: * On success, ptsname_r() returns 0. On failure, a nonzero value is * returned and errno is set to indicate the error. * diff --git a/libc/stdlib/lib_strtol.c b/libc/stdlib/lib_strtol.c index 2c6c6a24dec02c1a46ce3aadbccf2960efffd86a..411f7d6d416609b4ce75bbc00c94d1136ed91089 100644 --- a/libc/stdlib/lib_strtol.c +++ b/libc/stdlib/lib_strtol.c @@ -61,7 +61,7 @@ * nptr to a long integer value according to the given base, which must be * between 2 and 36 inclusive, or be the special value 0. * - * Returns: + * Returned Value: * - The converted value, if the base and number are valid * - 0 if an error occurs, and set errno to: * * EINVAL if base < 2 or base > 36 diff --git a/libc/stdlib/lib_strtoll.c b/libc/stdlib/lib_strtoll.c index a5f8b2cdc3bee01b1182bb711b70a55c20ea42d5..865af86a21f6020c677101bd895341264050b6e1 100644 --- a/libc/stdlib/lib_strtoll.c +++ b/libc/stdlib/lib_strtoll.c @@ -63,7 +63,7 @@ * nptr to a long long integer value according to the given base, which * must be between 2 and 36 inclusive, or be the special value 0. * - * Returns: + * Returned Value: * - The converted value, if the base and number are valid * - 0 if an error occurs, and set errno to: * * EINVAL if base < 2 or base > 36 diff --git a/libc/stdlib/lib_strtoul.c b/libc/stdlib/lib_strtoul.c index 8828aa830c7aef33f91b77397fd87b4886635b00..82ea183d73e8e89bc226364da765e25017c509f8 100644 --- a/libc/stdlib/lib_strtoul.c +++ b/libc/stdlib/lib_strtoul.c @@ -56,7 +56,7 @@ * nptr to a long unsigned integer value according to the given base, which * must be between 2 and 36 inclusive, or be the special value 0. * - * Returns: + * Returned Value: * - The converted value, if the base and number are valid * - 0 if an error occurs, and set errno to: * * EINVAL if base < 2 or base > 36 diff --git a/libc/stdlib/lib_strtoull.c b/libc/stdlib/lib_strtoull.c index fe13b63249b84d340393d833e6114e55ba4817a2..1896aec570cb05e5a227184fdf4872ab653f831d 100644 --- a/libc/stdlib/lib_strtoull.c +++ b/libc/stdlib/lib_strtoull.c @@ -59,7 +59,7 @@ * nptr to a long unsigned integer value according to the given base, which * must be between 2 and 36 inclusive, or be the special value 0. * - * Returns: + * Returned Value: * - The converted value, if the base and number are valid * - 0 if an error occurs, and set errno to: * * EINVAL if base < 2 or base > 36 diff --git a/libc/stdlib/lib_unlockpt.c b/libc/stdlib/lib_unlockpt.c index 8ea6e4c7ef52832805858a63659805aee408744c..0626d8657161671e6c6cd0c85ad5b764f2214f03 100644 --- a/libc/stdlib/lib_unlockpt.c +++ b/libc/stdlib/lib_unlockpt.c @@ -57,7 +57,7 @@ * unlockpt() must be called before opening the slave side of a * pseudoterminal. * - * Returned Values: + * Returned Value: * When successful, unlockpt() returns 0. Otherwise, it returns -1 and * sets errno appropriately. * diff --git a/libc/stdlib/lib_wctomb.c b/libc/stdlib/lib_wctomb.c index cef60ad1495f96847651b2965b2d519d4fe21596..f60f347829fcdf5470440cbff202cd6d3a220a71 100644 --- a/libc/stdlib/lib_wctomb.c +++ b/libc/stdlib/lib_wctomb.c @@ -66,7 +66,7 @@ int wctomb(FAR char *s, wchar_t wc) if ((size_t) wc >= 0x100) { - errno = EILSEQ; + set_errno(EILSEQ); return -1; } diff --git a/libc/string/lib_stpcpy.c b/libc/string/lib_stpcpy.c index dd2917f7bc5f30d785b2a7b4154ddc2248060c55..edfdd4ca003d2a5b89b43a6e72c1a9f25a41adf0 100644 --- a/libc/string/lib_stpcpy.c +++ b/libc/string/lib_stpcpy.c @@ -52,7 +52,7 @@ * Copies the string pointed to by 'src' (including the terminating NUL * character) into the array pointed to by 'dest'. * - * Returned value: + * Returned Value: * The stpcpy() function returns a pointer to the terminating NUL * character copied into the 'dest' buffer * diff --git a/libc/string/lib_strcpy.c b/libc/string/lib_strcpy.c index a329dc2925f82a0fa985e30a603ede8001699486..9c1b197a616e724bab15f972c6cc4c71a925c278 100644 --- a/libc/string/lib_strcpy.c +++ b/libc/string/lib_strcpy.c @@ -52,7 +52,7 @@ * Copies the string pointed to by 'src' (including the terminating NUL * character) into the array pointed to by 'des'. * - * Returned value: + * Returned Value: * The strcpy() function returns the 'dest' pointer * ****************************************************************************/ diff --git a/libc/string/lib_strtok.c b/libc/string/lib_strtok.c index 937326555899719a41817a49a7c0a6bcd76a8b63..8821a7d7ea5ed4c7e460091b6f99cf9c002a39f5 100644 --- a/libc/string/lib_strtok.c +++ b/libc/string/lib_strtok.c @@ -75,7 +75,7 @@ static char *g_saveptr = NULL; * end of the string are ignored. The tokens returned by * strtok() are always non-empty strings. * - * Return + * Returned Value: * strtok() returns a pointer to the next token, or NULL * if there are no more tokens. * diff --git a/libc/string/lib_strtokr.c b/libc/string/lib_strtokr.c index 22579f91ee47b86d2e211c7aa1f510c042e6425d..c179521961563be862ec7b31f61cab160f4b32f4 100644 --- a/libc/string/lib_strtokr.c +++ b/libc/string/lib_strtokr.c @@ -84,7 +84,7 @@ * end of the string are ignored. The tokens returned by * strtok() are always non-empty strings. * - * Return + * Returned Value: * strtok_r() returns a pointer to the next token, or NULL * if there are no more tokens. * diff --git a/libc/termios/lib_cfgetspeed.c b/libc/termios/lib_cfgetspeed.c index 1471b23d36793858772f87f6c9532e42b0ca48d6..bac31bdd8a86e10fa8b25a9bb81ea9e3ab1dea61 100644 --- a/libc/termios/lib_cfgetspeed.c +++ b/libc/termios/lib_cfgetspeed.c @@ -47,7 +47,7 @@ /**************************************************************************** * Name: cfgetspeed * - * Descripton: + * Description: * The cfgetspeed() function is a non-POSIX function will extract the baud * from the termios structure to which the termiosp argument points. * diff --git a/libc/termios/lib_cfsetspeed.c b/libc/termios/lib_cfsetspeed.c index 0c3e1215860598cce018308ab62261164ecb87c6..6f742905abc683b941b445c7d138e24d7846097c 100644 --- a/libc/termios/lib_cfsetspeed.c +++ b/libc/termios/lib_cfsetspeed.c @@ -44,7 +44,7 @@ /**************************************************************************** * Name: cfsetspeed * - * Descripton: + * Description: * The cfsetspeed() function is a non-POSIX function that sets the baud * stored in the structure pointed to by termiosp to speed. * diff --git a/libc/termios/lib_tcflow.c b/libc/termios/lib_tcflow.c index 1ac7a7a7b43fb6abe5f0a2ab1fbbb62d87a56da1..13f3ec3c88e00558baad601862e8383b5eb4af1a 100644 --- a/libc/termios/lib_tcflow.c +++ b/libc/termios/lib_tcflow.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: tcflow * - * Descripton: + * Description: * The tcflow() function will suspend or restart transmission or reception * of data on the object referred to by 'fd', depending on the value of * 'action'. diff --git a/libc/termios/lib_tcflush.c b/libc/termios/lib_tcflush.c index 239e3610cf95b112bed794de170ea5cdd8988b28..1189686d131fe6d74bb61c344b0af9f9a4492298 100644 --- a/libc/termios/lib_tcflush.c +++ b/libc/termios/lib_tcflush.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: tcflush * - * Descripton: + * Description: * Function for flushing a terminal/serial device * * Input Parameters: diff --git a/libc/termios/lib_tcgetattr.c b/libc/termios/lib_tcgetattr.c index c7e0c2339e158fe6bb800a1f4934b70de055523f..c9354eef70a255983438dac00c01f6558f9c9b39 100644 --- a/libc/termios/lib_tcgetattr.c +++ b/libc/termios/lib_tcgetattr.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: tcgetattr * - * Descripton: + * Description: * The tcgetattr() function gets the parameters associated with the * terminal referred to by 'fd' and stores them in the termios structure * referenced by 'termiosp'. diff --git a/libc/termios/lib_tcsetattr.c b/libc/termios/lib_tcsetattr.c index 20903e202999107ed33cd0ff4a865df7834c7101..d77d964610220ddbd0b2777326213f00fc8d03c9 100644 --- a/libc/termios/lib_tcsetattr.c +++ b/libc/termios/lib_tcsetattr.c @@ -53,7 +53,7 @@ /**************************************************************************** * Name: tcsetattr * - * Descripton: + * Description: * The tcsetattr() function sets the parameters associated with the * terminal referred to by the open file descriptor 'fd' from the termios * structure referenced by 'termiop' as follows: diff --git a/libc/time/lib_asctime.c b/libc/time/lib_asctime.c index af633ebd7371fe644873b76b00ec5e622fba6557..3ddf1074f8d811f48d7b76d2899668372be25cb6 100644 --- a/libc/time/lib_asctime.c +++ b/libc/time/lib_asctime.c @@ -58,7 +58,7 @@ * Parameters: * tp - Pointer to the time to be converted. * - * Return Value: + * Returned Value: * One success a pointer to the string is returned; on failure, NULL is * returned. * diff --git a/libc/time/lib_asctimer.c b/libc/time/lib_asctimer.c index 11b25974fa9641a667fb17f62b5b06417ed2dc36..bebbd21a1228288d13592033b4e0c10d1dc25d2f 100644 --- a/libc/time/lib_asctimer.c +++ b/libc/time/lib_asctimer.c @@ -78,7 +78,7 @@ static const char * const g_mon_name[12] = * tp - Pointer to the time to be converted. * buf - A user provided buffer to receive the 26 character time string. * - * Return Value: + * Returned Value: * One success, the pointer to the 'buf' is returned; on failure, NULL is * returned. * diff --git a/libc/time/lib_ctime.c b/libc/time/lib_ctime.c index 4072663fb8c0f6270a7a49b5dbfde63458730a39..1151382816abe160b35487db94b3c6355ddd84ac 100644 --- a/libc/time/lib_ctime.c +++ b/libc/time/lib_ctime.c @@ -58,7 +58,7 @@ * Parameters: * timep - The current time represented as seconds since the epoch. * - * Return Value: + * Returned Value: * One success a pointer to the string is returned; on failure, NULL is * returned. * diff --git a/libc/time/lib_ctimer.c b/libc/time/lib_ctimer.c index ccc9c8f9284757877ad826557d02b2ff0e745e89..1286976c6d923e16db8cc52a60e17eed0f89d11f 100644 --- a/libc/time/lib_ctimer.c +++ b/libc/time/lib_ctimer.c @@ -63,7 +63,7 @@ * timep - The current time represented as seconds since the epoch. * buf - A user provided buffer to receive the 26 character time string. * - * Return Value: + * Returned Value: * One success, the pointer to the 'buf' is returned; on failure, NULL is * returned. * diff --git a/libc/time/lib_dayofweek.c b/libc/time/lib_dayofweek.c index 981e027025d960b257a25a977a1787d463aa8f25..9549dc3e4424890cbd65063d04e04d6eb4905a6f 100644 --- a/libc/time/lib_dayofweek.c +++ b/libc/time/lib_dayofweek.c @@ -90,7 +90,7 @@ * month - The month of the year 1 - 12 * year - the year including the 1900 * - * Returned value: + * Returned Value: * Zero based day of the week 0-6, 0 = Sunday, 1 = Monday... 6 = Saturday * ****************************************************************************/ diff --git a/libc/time/lib_gettimeofday.c b/libc/time/lib_gettimeofday.c index 6a1f01d16edcf0543e39492e79209012df11e9c7..89a8caefd8834a85808f1002b676669e75b1cf6d 100644 --- a/libc/time/lib_gettimeofday.c +++ b/libc/time/lib_gettimeofday.c @@ -64,7 +64,7 @@ * tv - The location to return the current time * tz - Ignored * - * Returned value: + * Returned Value: * Zero (OK) on success; -1 is returned on failure with the errno variable * set appropriately. * diff --git a/libc/time/lib_localtime.c b/libc/time/lib_localtime.c index ac5cd64f6439d25adacd236ecb79ed9a2e54b876..f1fc6ae08308e54da8b432e575561eb51ab6c9a5 100644 --- a/libc/time/lib_localtime.c +++ b/libc/time/lib_localtime.c @@ -2374,7 +2374,7 @@ static time_t time1(FAR struct tm *const tmp, if (tmp == NULL) { - errno = EINVAL; + set_errno(EINVAL); return -1; } diff --git a/libc/time/lib_settimeofday.c b/libc/time/lib_settimeofday.c index a36f32911bdf97266c4bafa699841556e58d79b5..1fc96d5ec756a5858cca5008f163a2d5c1ed0ee2 100644 --- a/libc/time/lib_settimeofday.c +++ b/libc/time/lib_settimeofday.c @@ -63,7 +63,7 @@ * tv - The net to time to be set * tz - Ignored * - * Returned value: + * Returned Value: * Zero (OK) on success; -1 is returned on failure with the errno variable * set appropriately. * diff --git a/libc/time/lib_time.c b/libc/time/lib_time.c index 504f7795f98d612cdcc0d77762b90c208c628ce5..683d8a71b9ba299dec19710835b1ce5c8a5dbc35 100644 --- a/libc/time/lib_time.c +++ b/libc/time/lib_time.c @@ -63,7 +63,7 @@ * parameter is not used, but a time_t object is still returned by the * function. * - * Return Value: + * Returned Value: * The current calendar time as a time_t object. If the argument is not * a null pointer, the return value is the same as the one stored in the * location pointed by the argument. diff --git a/libc/unistd/lib_chdir.c b/libc/unistd/lib_chdir.c index 16786a0f317817a74eb957ef89866a30fc7f0396..b87a3ebb82b96d03ecf0de1055d1999158dee69f 100644 --- a/libc/unistd/lib_chdir.c +++ b/libc/unistd/lib_chdir.c @@ -90,7 +90,7 @@ static inline void _trimdir(char *path) * is, the starting point for path searches for pathnames not beginning * with '/'. * - * Input Parmeters: + * Input Parameters: * path - A pointer to a directory to use as the new current working * directory * diff --git a/libc/unistd/lib_getcwd.c b/libc/unistd/lib_getcwd.c index 55587a599e2356cadfdf7c1dac0799f76b422305..9a04de995c94287a3b0ec629d56683a34a3300aa 100644 --- a/libc/unistd/lib_getcwd.c +++ b/libc/unistd/lib_getcwd.c @@ -71,7 +71,7 @@ * symbolic links. The 'size' argument is the size in bytes of the * character array pointed to by the 'buf' argument. * - * Input Parmeters: + * Input Parameters: * buf - a pointer to the location in which the current working directory * pathaname is returned. * size - The size in bytes avaiable at 'buf' diff --git a/libc/unistd/lib_getopt.c b/libc/unistd/lib_getopt.c index 47ac0855095dbd4101c4beac802a29ab2c380f7a..8826588ecab6628181ab856585b48e1735d1bf82 100644 --- a/libc/unistd/lib_getopt.c +++ b/libc/unistd/lib_getopt.c @@ -101,13 +101,14 @@ static bool g_binitialized = false; * errors are returned ('?' or ':') until getopt() finally returns -1. * (You can also set optind to -1 to force a reset). * - * Return: If an option was successfully found, then getopt() returns the - * option character. If all command-line options have been parsed, then - * getopt() returns -1. If getopt() encounters an option character that - * was not in optstring, then '?' is returned. If getopt() encounters an - * option with a missing argument, then the return value depends on the - * first character in optstring: if it is ':', then ':' is returned; - * otherwise '?' is returned. + * Return Value: + * If an option was successfully found, then getopt() returns the option + * haracter. If all command-line options have been parsed, then getopt() + * returns -1. If getopt() encounters an option character that was not + * in optstring, then '?' is returned. If getopt() encounters an option + * with a missing argument, then the return value depends on the first + * character in optstring: if it is ':', then ':' is returned; otherwise + * '?' is returned. * ****************************************************************************/ diff --git a/libc/unistd/lib_pipe.c b/libc/unistd/lib_pipe.c index 469dd5a1d508a1ba4d74aa498913dd20ba1db150..dc251b33c834e492a2c371f81bcbef89871609a1 100644 --- a/libc/unistd/lib_pipe.c +++ b/libc/unistd/lib_pipe.c @@ -57,11 +57,11 @@ * and places them in the array pointed to by 'fd'. fd[0] is for reading, * fd[1] is for writing. * - * Inputs: + * Input Parameters: * fd[2] - The user provided array in which to catch the pipe file * descriptors * - * Return: + * Returned Value: * 0 is returned on success; otherwise, -1 is returned with errno set * appropriately. * diff --git a/libc/userfs/lib_userfs.c b/libc/userfs/lib_userfs.c index 8f04c21f1d914d41ecc42bc232152b83dc7fe024..f08b936375ad2460a3da9f2a0c33ec0ae6620f38 100644 --- a/libc/userfs/lib_userfs.c +++ b/libc/userfs/lib_userfs.c @@ -901,7 +901,7 @@ static inline int userfs_destroy_dispatch(FAR struct userfs_info_s *info, * NOTE: This is a user function that is implemented as part of the * NuttX C library and is intended to be called by appliation logic. * - * Input parameters: + * Input Parameters: * mountpt - Mountpoint path * userops - The caller operations that implement the file system * interface. diff --git a/libc/wchar/lib_wcsnrtombs.c b/libc/wchar/lib_wcsnrtombs.c index a77cdc685f385a529369c5bfb5e54b96f1aeab96..c59975ace67404885edc4526039bc99f44d51893 100644 --- a/libc/wchar/lib_wcsnrtombs.c +++ b/libc/wchar/lib_wcsnrtombs.c @@ -51,7 +51,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: + * Name: wcsnrtombs * * Description: * The 'wcsrtombs' function converts a string of wide characters diff --git a/libc/wqueue/work_cancel.c b/libc/wqueue/work_cancel.c index 31ccbf68d330fbd5f014224483a32d30dd053ba5..c03530705661a34eee9c10cb8fcc763075c11d1b 100644 --- a/libc/wqueue/work_cancel.c +++ b/libc/wqueue/work_cancel.c @@ -62,7 +62,7 @@ * After work has been cancelled, it may be re-queue by calling work_queue() * again. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * work - The previously queue work structure to cancel * @@ -124,7 +124,7 @@ static int work_qcancel(FAR struct usr_wqueue_s *wqueue, FAR struct work_s *work * user mode work queue. After work has been cancelled, it may be re-queue * by calling work_queue() again. * - * Input parameters: + * Input Parameters: * qid - The work queue ID (must be USRWORK) * work - The previously queue work structure to cancel * diff --git a/libc/wqueue/work_lock.c b/libc/wqueue/work_lock.c index eec61847ac7f40bcb50d6cf6faf0bbf4652e40d6..8b8a5682c0bcf9ccb787d022e006e357e180640c 100644 --- a/libc/wqueue/work_lock.c +++ b/libc/wqueue/work_lock.c @@ -58,7 +58,7 @@ * Description: * Lock the user-mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -98,7 +98,7 @@ int work_lock(void) * Description: * Unlock the user-mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/libc/wqueue/work_queue.c b/libc/wqueue/work_queue.c index 5b9a0ac3e478372d69817a1fb41e6324486e2eb8..40cbdf5635a450c9f0550b1d29978022d9586bf1 100644 --- a/libc/wqueue/work_queue.c +++ b/libc/wqueue/work_queue.c @@ -70,7 +70,7 @@ * from the queue, or (2) work_cancel() has been called to cancel the work * and remove it from the work queue. * - * Input parameters: + * Input Parameters: * qid - The work queue ID (index) * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked @@ -141,7 +141,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue, * previous work as been performed and removed from the queue, then any * pending work will be canceled and lost. * - * Input parameters: + * Input Parameters: * qid - The work queue ID (index) * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked diff --git a/libc/wqueue/work_signal.c b/libc/wqueue/work_signal.c index da8b174cd585724f93f10630f1134b2d12758041..1854210cc5f84dff616d6cbdbc3f18b088ff2ab7 100644 --- a/libc/wqueue/work_signal.c +++ b/libc/wqueue/work_signal.c @@ -79,7 +79,7 @@ * is used internally by the work logic but could also be used by the * user to force an immediate re-assessment of pending work. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * * Returned Value: @@ -98,7 +98,7 @@ int work_signal(int qid) ret = kill(g_usrwork.pid, SIGWORK); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); ret = -errcode; } } diff --git a/libc/wqueue/work_usrthread.c b/libc/wqueue/work_usrthread.c index 17d3b10f25bb34e78b99a18ed23ce8c196e36c4a..bb62a8d645f4cb4d8c11ca687af0c4dddf58e986 100644 --- a/libc/wqueue/work_usrthread.c +++ b/libc/wqueue/work_usrthread.c @@ -106,7 +106,7 @@ pthread_mutex_t g_usrmutex; * part of the internal implementation of each work queue; it should not * be called from application level logic. * - * Input parameters: + * Input Parameters: * wqueue - Describes the work queue to be processed * * Returned Value: @@ -285,7 +285,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue) * miscellaneous operations. The user work thread must be started by * application start-up logic by calling work_usrstart(). * - * Input parameters: + * Input Parameters: * argc, argv (not used) * * Returned Value: @@ -327,7 +327,7 @@ static pthread_addr_t work_usrthread(pthread_addr_t arg) * Description: * Start the user mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -360,7 +360,7 @@ int work_usrstart(void) DEBUGASSERT(g_usrwork.pid > 0); if (g_usrwork.pid < 0) { - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode > 0); return -errcode; } diff --git a/libc/wqueue/wqueue.h b/libc/wqueue/wqueue.h index 6075ea00e80479e7580d4845fb4bdb4b8191aad5..f16574e663a0256d522bc316b36f55c8e2944f3c 100644 --- a/libc/wqueue/wqueue.h +++ b/libc/wqueue/wqueue.h @@ -92,7 +92,7 @@ extern pthread_mutex_t g_usrmutex; * Description: * Lock the user-mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -111,7 +111,7 @@ int work_lock(void); * Description: * Unlock the user-mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/libnx/nx/nx_drawcircle.c b/libnx/nx/nx_drawcircle.c index c06413b4586fdcd0ada920735c59bac055f661b9..05027479716b7e5245524f1f50ea27bc6b889fe5 100644 --- a/libnx/nx/nx_drawcircle.c +++ b/libnx/nx/nx_drawcircle.c @@ -102,7 +102,7 @@ * width - The width of the line * color - The color to use to fill the line * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nx/nx_drawline.c b/libnx/nx/nx_drawline.c index 6ca0ade436ee71ca49c1ebc6a1b0be2e28af1f4a..ecd0df074f75c1365be1248e4f201e349d083b14 100644 --- a/libnx/nx/nx_drawline.c +++ b/libnx/nx/nx_drawline.c @@ -86,7 +86,7 @@ * caps - Draw a circular cap on the ends of the line to support better * line joins * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nx/nx_fillcircle.c b/libnx/nx/nx_fillcircle.c index 7bfa1551f52391f4f951fa8d0d65e84dbfa41f32..adec60a4066cbc2443a935478640659b34964da7 100644 --- a/libnx/nx/nx_fillcircle.c +++ b/libnx/nx/nx_fillcircle.c @@ -84,7 +84,7 @@ * radius - The radius of the circle in pixels. * color - The color to use to fill the circle. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxfonts/.gitignore b/libnx/nxfonts/.gitignore index 707a097d9166429eebdf9bb3f9d131b324ad1b65..90466077267d998e8c3b91582ef9c32e83f82bbe 100644 --- a/libnx/nxfonts/.gitignore +++ b/libnx/nxfonts/.gitignore @@ -1,4 +1,4 @@ nxfonts_convert_*bpp.c nxfonts_bitmaps_*.c - +nxfonts_tom-thumb-4x6.c diff --git a/libnx/nxfonts/nxfonts_cache.c b/libnx/nxfonts/nxfonts_cache.c index fbf99eca87c8695a0df82950ae5f6a6f46dcd627..6276b91dc755e01793324d78e063eed383824d59 100644 --- a/libnx/nxfonts/nxfonts_cache.c +++ b/libnx/nxfonts/nxfonts_cache.c @@ -639,7 +639,7 @@ nxf_findcache(enum nx_fontid_e fontid, nxgl_mxpixel_t fgcolor, * bpp - Bits per pixel * maxglyphs - Maximum number of glyphs permitted in the cache * - * Returned value: + * Returned Value: * On success a non-NULL handle is returned that then may sequently be * used with nxf_getglyph() to extract fonts from the font cache. NULL * returned on any failure with the errno value set to indicate the nature @@ -798,7 +798,7 @@ errout_with_lock: * Input Parameters: * fhandle - A font cache handle previously returned by nxf_cache_connect(); * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -876,7 +876,7 @@ void nxf_cache_disconnect(FCACHE fhandle) * Input Parameters: * fhandle - A font cache handle previously returned by nxf_cache_connect(); * - * Returned value: + * Returned Value: * Zero (OK) is returned if the metrics were * * Returned Value: diff --git a/libnx/nxglib/nxglib_circlepts.c b/libnx/nxglib/nxglib_circlepts.c index 21d2340a71a1751a036e8958b0452e375d9bc4ef..a7132ce5f50cb61402c3a19afb98e302613833a9 100644 --- a/libnx/nxglib/nxglib_circlepts.c +++ b/libnx/nxglib/nxglib_circlepts.c @@ -89,13 +89,13 @@ * circumference of the circle. These points may then be used by * nx_drawcircle() or related APIs to draw a circle outline. * - * Input parameters: + * Input Parameters: * center - A pointer to the point that is the center of the circle * radius - The radius of the circle in pixels. * circle - A pointer the first entry in an array of 16 points where the * circle points will be returned. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ diff --git a/libnx/nxglib/nxglib_circletraps.c b/libnx/nxglib/nxglib_circletraps.c index f7038703ba61e360621bf453463ecd6b8202faba..158c044e4ea9b2c5785e9c6614f9f7640e66d8df 100644 --- a/libnx/nxglib/nxglib_circletraps.c +++ b/libnx/nxglib/nxglib_circletraps.c @@ -68,13 +68,13 @@ * Given a description of a a circle, return 8 trapezoids that can be * used to fill the circle by nx_fillcircle() and other interfaces. * - * Input parameters: + * Input Parameters: * center - A pointer to the point that is the center of the circle * radius - The radius of the circle in pixels. * circle - A pointer the first entry in an array of 8 trapezoids where * the circle description will be returned. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ diff --git a/libnx/nxglib/nxglib_splitline.c b/libnx/nxglib/nxglib_splitline.c index 31b5d914bdd38c9c00f73c635052735022ba591a..10bffa257b4ca191cfa490ab33db0c32c7cdfb55 100644 --- a/libnx/nxglib/nxglib_splitline.c +++ b/libnx/nxglib/nxglib_splitline.c @@ -104,12 +104,12 @@ static b16_t nxgl_interpolate(b16_t x, b16_t dy, b16_t dxdy) * this case, 3 trapezoids will be returned, but traps[1] will be * degenerate. * - * Input parameters: + * Input Parameters: * vector - A pointer to the vector described the line to be drawn. * traps - A pointer to a array of trapezoids (size 3). * rect - A pointer to a rectangle. * - * Returned value: + * Returned Value: * 0: Line successfully broken up into three trapezoids. Values in * traps[0], traps[1], and traps[2] are valid. * 1: Line successfully represented by one trapezoid. Value in traps[1] diff --git a/libnx/nxmu/nx_bitmap.c b/libnx/nxmu/nx_bitmap.c index 2c455d424be287eac0cbd129937f5dce39dd7c87..e1fcb8451b720a2998a400505c76b08df57407f7 100644 --- a/libnx/nxmu/nx_bitmap.c +++ b/libnx/nxmu/nx_bitmap.c @@ -69,7 +69,7 @@ * may lie outside of the display. * stride - The width of the full source image in pixels. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_block.c b/libnx/nxmu/nx_block.c index 4569a195adc030c4a3698a27fd4af4292f2577cf..2bf8efa64ccac1ee26dbec370a3e5d8b9eb46033 100644 --- a/libnx/nxmu/nx_block.c +++ b/libnx/nxmu/nx_block.c @@ -74,7 +74,7 @@ * arg - An argument that will accompany the block messages (This is arg2 * in the blocked callback). * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_closewindow.c b/libnx/nxmu/nx_closewindow.c index 6e5661f6b449d2c6a59d9bad0c7c452b44dc35d3..b0aac838b79211d67b99f23d96ea68d6026e17ba 100644 --- a/libnx/nxmu/nx_closewindow.c +++ b/libnx/nxmu/nx_closewindow.c @@ -60,7 +60,7 @@ * Input Parameters: * wnd - The window to be destroyed * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_connect.c b/libnx/nxmu/nx_connect.c index e69580bce81374762c7e4faa67162e94b0b0e7fb..d600666e8a57eb61b3dd93a835622ccbbb20c33a 100644 --- a/libnx/nxmu/nx_connect.c +++ b/libnx/nxmu/nx_connect.c @@ -93,7 +93,7 @@ static uint32_t g_nxcid = 1; * Input Parameters: * svrmqname - The name for the server incoming message queue * - * Return: + * Returned Value: * Success: A non-NULL handle used with subsequent NX accesses * Failure: NULL is returned and errno is set appropriately * diff --git a/libnx/nxmu/nx_constructwindow.c b/libnx/nxmu/nx_constructwindow.c index cc8b1656b147d1e95266c70dbab8288fca740091..3cfd88c12eba0b562a4ba6bc81d06416bd2020f8 100644 --- a/libnx/nxmu/nx_constructwindow.c +++ b/libnx/nxmu/nx_constructwindow.c @@ -75,7 +75,7 @@ * cb - Callbacks used to process window events * arg - User provided value that will be returned with NX callbacks. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately. In the * case of ERROR, NX will have deallocated the pre-allocated window. * diff --git a/libnx/nxmu/nx_disconnect.c b/libnx/nxmu/nx_disconnect.c index 6b1877efc3f110bb83ee0bbed59b2560d2fff392..2b6a9638e9339b932ae47766af3863d792af43a5 100644 --- a/libnx/nxmu/nx_disconnect.c +++ b/libnx/nxmu/nx_disconnect.c @@ -61,7 +61,7 @@ * Input Parameters: * handle - the handle returned by nx_connect * - * Return: + * Returned Value: * OK on success; ERROR on failure with the errno set appropriately. * NOTE that handle will no long be valid upon return. * diff --git a/libnx/nxmu/nx_eventhandler.c b/libnx/nxmu/nx_eventhandler.c index a82b10839a6361f4ced1d4c0b8d909b7a586e223..bc6a746850d98c03eaf2d1955eb7bbc28a34f66e 100644 --- a/libnx/nxmu/nx_eventhandler.c +++ b/libnx/nxmu/nx_eventhandler.c @@ -108,7 +108,7 @@ static inline void nx_disconnected(FAR struct nxfe_conn_s *conn) * Input Parameters: * handle - the handle returned by nx_connect * - * Return: + * Returned Value: * OK: No errors occurred. If CONFIG_NX_BLOCKING is defined, then * one or more server message was processed. * ERROR: An error occurred and errno has been set appropriately. Of diff --git a/libnx/nxmu/nx_eventnotify.c b/libnx/nxmu/nx_eventnotify.c index 70653f62e2e2d1d9c90067c6f1d2280c60d195ba..a136774349a1eb039413b1de10b31be9939170f4 100644 --- a/libnx/nxmu/nx_eventnotify.c +++ b/libnx/nxmu/nx_eventnotify.c @@ -69,7 +69,7 @@ * Input Parameters: * handle - the handle returned by nx_connect * - * Return: + * Returned Value: * OK: No errors occurred. If CONFIG_NX_BLOCKING is defined, then * one or more server message was processed. * ERROR: An error occurred and errno has been set appropriately diff --git a/libnx/nxmu/nx_fill.c b/libnx/nxmu/nx_fill.c index bb59f6b28119c73530b3935aebadefc20a657732..d8a6231caffaabc6524787b3facceee9ee43d262 100644 --- a/libnx/nxmu/nx_fill.c +++ b/libnx/nxmu/nx_fill.c @@ -63,7 +63,7 @@ * rect - The location to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_filltrapezoid.c b/libnx/nxmu/nx_filltrapezoid.c index 6dbdf27ab3b22c4d56d9f17bd771210ad8fd7a4b..a9c850842931a7cc8b5bcdd3f3462b0d9d1d2fc2 100644 --- a/libnx/nxmu/nx_filltrapezoid.c +++ b/libnx/nxmu/nx_filltrapezoid.c @@ -64,7 +64,7 @@ * trap - The trapezoidal region to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_getposition.c b/libnx/nxmu/nx_getposition.c index d18d1d3a593f8a4a0c3128b1071a6e2206f8534a..757c1621c53ca10a60fea8a1a9bfa0a58adf7f8a 100644 --- a/libnx/nxmu/nx_getposition.c +++ b/libnx/nxmu/nx_getposition.c @@ -61,7 +61,7 @@ * Input Parameters: * hwnd - The window handle * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_getrectangle.c b/libnx/nxmu/nx_getrectangle.c index 958a1e05e847530ecfab41f7c6044217a5e68a29..fb1843b52dda17ff2e48a81bf25086e36cd47501 100644 --- a/libnx/nxmu/nx_getrectangle.c +++ b/libnx/nxmu/nx_getrectangle.c @@ -68,7 +68,7 @@ * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_lower.c b/libnx/nxmu/nx_lower.c index 06952d17f7931212fac87936433d9ecf9348827f..8d0ceca40d46bdd0ed168550792740bf04aa6470 100644 --- a/libnx/nxmu/nx_lower.c +++ b/libnx/nxmu/nx_lower.c @@ -56,10 +56,10 @@ * Description: * Lower the specified window to the bottom of the display. * - * Input parameters: + * Input Parameters: * hwnd - the window to be lowered * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_move.c b/libnx/nxmu/nx_move.c index 144e9e588b589bc07b0990ad19df330ed2526c7b..71a4ca7f44c062e85e7e4a1fcdab1be399907e8b 100644 --- a/libnx/nxmu/nx_move.c +++ b/libnx/nxmu/nx_move.c @@ -61,7 +61,7 @@ * rect - Describes the rectangular region to move * offset - The offset to move the region * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_openwindow.c b/libnx/nxmu/nx_openwindow.c index 3280ee4225d1ff04f2de5c47dbe3b1c9c17ddab7..d5152192b74541c0606f4295f0fff124bafd80d7 100644 --- a/libnx/nxmu/nx_openwindow.c +++ b/libnx/nxmu/nx_openwindow.c @@ -63,7 +63,7 @@ * cb - Callbacks used to process window events * arg - User provided value that will be returned with NX callbacks. * - * Return: + * Returned Value: * Success: A non-NULL handle used with subsequent NX accesses * Failure: NULL is returned and errno is set appropriately * diff --git a/libnx/nxmu/nx_raise.c b/libnx/nxmu/nx_raise.c index a149acdb280f4738870590f521dc4ca104c9b0a5..92f82d456df1c41dfea9424d4fb5d24d121ed74f 100644 --- a/libnx/nxmu/nx_raise.c +++ b/libnx/nxmu/nx_raise.c @@ -56,10 +56,10 @@ * Description: * Bring the specified window to the top of the display. * - * Input parameters: + * Input Parameters: * hwnd - the window to be raised * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_redrawreq.c b/libnx/nxmu/nx_redrawreq.c index 520305bf80ddb1edc9e46709d9a33e01b2762a03..d2745a1cc8c51866a62fffa18f9b380ecbffbda5 100644 --- a/libnx/nxmu/nx_redrawreq.c +++ b/libnx/nxmu/nx_redrawreq.c @@ -54,7 +54,7 @@ /**************************************************************************** * Name: nx_redrawreq * - * Descripton: + * Description: * This will cause a NX re-draw callback to the client that owns the * window. This is not normally called from user code, but may be * used within middle-ware layers when redrawing is needed. diff --git a/libnx/nxmu/nx_releasebkgd.c b/libnx/nxmu/nx_releasebkgd.c index 9fe9a44c719591ce06e54198115795cd801ec28d..22620193cef895ef692cf97e4ec3e5d179e20c67 100644 --- a/libnx/nxmu/nx_releasebkgd.c +++ b/libnx/nxmu/nx_releasebkgd.c @@ -60,7 +60,7 @@ * Input Parameters: * hwnd - The handle returned (indirectly) by nx_requestbkgd * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_requestbkgd.c b/libnx/nxmu/nx_requestbkgd.c index 77a4ae8ed5445325401102fcfe87b4a4ec0e0bfa..d3eff5c55309bca6308705f38b62ae4e80cd1eaa 100644 --- a/libnx/nxmu/nx_requestbkgd.c +++ b/libnx/nxmu/nx_requestbkgd.c @@ -84,7 +84,7 @@ * cb - Callbacks to use for processing background window events * arg - User provided argument (see nx_openwindow, nx_constructwindow) * - * Return: + * Returned Value: * OK: Success; ERROR of failure with errno set appropriately. * ****************************************************************************/ diff --git a/libnx/nxmu/nx_setbgcolor.c b/libnx/nxmu/nx_setbgcolor.c index 74c683acf34c0a9ab02c9b1a0280f8897438054d..43d74187a84b64562e28d083e02bf4ef9e5be6e5 100644 --- a/libnx/nxmu/nx_setbgcolor.c +++ b/libnx/nxmu/nx_setbgcolor.c @@ -59,7 +59,7 @@ * handle - The connection handle * color - The color to use in the background * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_setpixel.c b/libnx/nxmu/nx_setpixel.c index 376f85b04c4bee6fef21770773c8765ccf665ce0..bef376807319fc244cb86c85339aa40762922869 100644 --- a/libnx/nxmu/nx_setpixel.c +++ b/libnx/nxmu/nx_setpixel.c @@ -64,7 +64,7 @@ * pos - The pixel location to be set * col - The color to use in the set * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_setposition.c b/libnx/nxmu/nx_setposition.c index a537d1b79a706e09665a624a48b03cb7e81d335f..e8d6887271e3ba3b82ab9304739c182a00ab13bb 100644 --- a/libnx/nxmu/nx_setposition.c +++ b/libnx/nxmu/nx_setposition.c @@ -60,7 +60,7 @@ * hwnd - The window handle * pos - The new position of the window * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nx_setsize.c b/libnx/nxmu/nx_setsize.c index dd2ee119ff1dd9dc4bc8009b6b78a0d8710c856a..7a73710d9e29e8ec3b308b115d4540bd3daedabe 100644 --- a/libnx/nxmu/nx_setsize.c +++ b/libnx/nxmu/nx_setsize.c @@ -60,7 +60,7 @@ * hwnd - The window handle * size - The new size of the window. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nxmu_sendserver.c b/libnx/nxmu/nxmu_sendserver.c index 2072ad28942fe980338089b3d278d3d500885127..833d03f9d9f88a2f2530f9ce59ad4e77e4449daf 100644 --- a/libnx/nxmu/nxmu_sendserver.c +++ b/libnx/nxmu/nxmu_sendserver.c @@ -61,7 +61,7 @@ * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxmu/nxmu_sendwindow.c b/libnx/nxmu/nxmu_sendwindow.c index 350fecd41dcb74af3bbe6c06c8f36c58f3508aea..aa5920424929dd100a04d5cedacb37caeced4a10 100644 --- a/libnx/nxmu/nxmu_sendwindow.c +++ b/libnx/nxmu/nxmu_sendwindow.c @@ -62,7 +62,7 @@ * msg - A pointer to the message to send * msglen - The length of the message in bytes. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk.h b/libnx/nxtk/nxtk.h index 44d507ee015e2c6bcafb1db887f4971a7488035b..97f5b486ec4233d3d4aaaccfbb3f947dd22d89a1 100644 --- a/libnx/nxtk/nxtk.h +++ b/libnx/nxtk/nxtk.h @@ -125,13 +125,13 @@ void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd); * then move the rectangle to that it is relative to the containing * window. * - * Input parameters: + * Input Parameters: * fwnd - The framed window to be used * dest - The locaton to put the result * src - The src rectangle in relative sub-window coordinates * bounds - The subwindow bounds in absolute screen coordinates. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -152,13 +152,13 @@ void nxtk_subwindowclip(FAR struct nxtk_framedwindow_s *fwnd, * relative to the sub-window (i.e., (0,0) is the top left corner of the * sub-window). * - * Input parameters: + * Input Parameters: * fwnd - The framed window to be used * dest - The location to put the result * src - The src rectangle in relative container-window coordinates * bounds - The subwindow bounds in absolute screen coordinates. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -185,7 +185,7 @@ void nxtk_containerclip(FAR struct nxtk_framedwindow_s *fwnd, * srcoffset - The offset to move the region * bounds - The subwindow bounds in absolute screen coordinates. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ @@ -203,13 +203,13 @@ void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, * Description: * Redraw the window frame. * - * Input parameters: + * Input Parameters: * fwnd - the framed window whose frame needs to be re-drawn. This must * have been previously created by nxtk_openwindow(). * bounds - Only draw the ports of the frame within this bounding box. * (window relative coordinates). * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_bitmaptoolbar.c b/libnx/nxtk/nxtk_bitmaptoolbar.c index 6f31d9300992ae7366323a75a3074684448c5ace..6ba5d383c99ffc92f411f15605e02d648fdfdfea 100644 --- a/libnx/nxtk/nxtk_bitmaptoolbar.c +++ b/libnx/nxtk/nxtk_bitmaptoolbar.c @@ -89,7 +89,7 @@ * origin may lie outside of the sub-window display. * stride - The width of the full source image in pixels. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_bitmapwindow.c b/libnx/nxtk/nxtk_bitmapwindow.c index 0371715ba7c400fdf6c2f9ab506559d1e9995b86..8ba53f948510b97e5e630a456ef3d737edac1f9b 100644 --- a/libnx/nxtk/nxtk_bitmapwindow.c +++ b/libnx/nxtk/nxtk_bitmapwindow.c @@ -89,7 +89,7 @@ * origin may lie outside of the sub-window display. * stride - The width of the full source image in pixels. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_block.c b/libnx/nxtk/nxtk_block.c index d68dbe8fc237cf49704d63e0210a50c5bf635085..625e862d179d463f56db6b8d790f5abd65185ac5 100644 --- a/libnx/nxtk/nxtk_block.c +++ b/libnx/nxtk/nxtk_block.c @@ -71,7 +71,7 @@ * arg - An argument that will accompany the block messages (This is arg2 * in the blocked callback). * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_closetoolbar.c b/libnx/nxtk/nxtk_closetoolbar.c index 7be217d18de8a2e192c46e253eb03226adab4f10..ed4cbb190a210864e8395fe1d7c066c2eb868e82 100644 --- a/libnx/nxtk/nxtk_closetoolbar.c +++ b/libnx/nxtk/nxtk_closetoolbar.c @@ -81,7 +81,7 @@ * Input Parameters: * hfwnd - The handle returned by nxtk_openwindow * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_closewindow.c b/libnx/nxtk/nxtk_closewindow.c index 54857521305de246af323063ee5aa35f2e43be9e..cf2e6ad90b7891f2d5f7d78bd94b7cde7f615863 100644 --- a/libnx/nxtk/nxtk_closewindow.c +++ b/libnx/nxtk/nxtk_closewindow.c @@ -82,7 +82,7 @@ * Input Parameters: * hfwnd - The handle returned by nxtk_openwindow * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_containerclip.c b/libnx/nxtk/nxtk_containerclip.c index 67ed6cb17b18ae198e6f1b2ab7d41a1e1ec0967c..42951f470ba2e2dfab9b41528e3d6643cc17a494 100644 --- a/libnx/nxtk/nxtk_containerclip.c +++ b/libnx/nxtk/nxtk_containerclip.c @@ -83,13 +83,13 @@ * relative to the sub-window (i.e., (0,0) is the top left corner of the * sub-window). * - * Input parameters: + * Input Parameters: * fwnd - The framed window to be used * dest - The locaton to put the result * src - The src rectangle in relative container-window coordinates * bounds - The subwindow bounds in absolute screen coordinates. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_drawcircletoolbar.c b/libnx/nxtk/nxtk_drawcircletoolbar.c index 37998b70f84e69ddd5bf4e68d12b0380ef103b2f..69ea9a67ca1335493f30080a779411b614fbde59 100644 --- a/libnx/nxtk/nxtk_drawcircletoolbar.c +++ b/libnx/nxtk/nxtk_drawcircletoolbar.c @@ -102,7 +102,7 @@ * width - The width of the line * color - The color to use to fill the line * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_drawcirclewindow.c b/libnx/nxtk/nxtk_drawcirclewindow.c index 3f6cdd28827112aea102564ba30e11e62c9fdde4..1ba7717085912cce6ee9c62aefb064359d33902e 100644 --- a/libnx/nxtk/nxtk_drawcirclewindow.c +++ b/libnx/nxtk/nxtk_drawcirclewindow.c @@ -102,7 +102,7 @@ * width - The width of the line * color - The color to use to fill the line * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_drawframe.c b/libnx/nxtk/nxtk_drawframe.c index adafccc574468d0282dd2d4a0ea7b7dfbc5a041b..2e1ea68b17f421438b6f6fc0607da410eb4cce22 100644 --- a/libnx/nxtk/nxtk_drawframe.c +++ b/libnx/nxtk/nxtk_drawframe.c @@ -98,13 +98,13 @@ static void nxtk_drawframeside(FAR struct nxtk_framedwindow_s *fwnd, * Description: * Redraw the window frame. * - * Input parameters: + * Input Parameters: * fwnd - the framed window whose frame needs to be re-drawn. This must * have been previously created by nxtk_openwindow(). * bounds - Only draw the ports of the frame within this bounding box. * (window relative coordinates). * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_drawlinetoolbar.c b/libnx/nxtk/nxtk_drawlinetoolbar.c index 84d25ad83caf307c6b7049f9a40b0a973c393569..51820a47f8fdc844e92cf240b2ce05b31fcea2d6 100644 --- a/libnx/nxtk/nxtk_drawlinetoolbar.c +++ b/libnx/nxtk/nxtk_drawlinetoolbar.c @@ -88,7 +88,7 @@ * caps - Draw a circular cap on the ends of the line to support better * line joins * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_drawlinewindow.c b/libnx/nxtk/nxtk_drawlinewindow.c index 231842b8828a83cfe48ca8c457da0d4b4629ff60..970ce40e60f529aeec3cf12765af737b96042b3d 100644 --- a/libnx/nxtk/nxtk_drawlinewindow.c +++ b/libnx/nxtk/nxtk_drawlinewindow.c @@ -87,7 +87,7 @@ * caps - Draw a circular cap on the ends of the line to support better * line joins * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_fillcircletoolbar.c b/libnx/nxtk/nxtk_fillcircletoolbar.c index af502c766070404a9cb7bf1c42f7ce979c8ae856..0772d8c75e9e813389c20c742aaee82aa04d1fe1 100644 --- a/libnx/nxtk/nxtk_fillcircletoolbar.c +++ b/libnx/nxtk/nxtk_fillcircletoolbar.c @@ -84,7 +84,7 @@ * radius - The radius of the circle in pixels. * color - The color to use to fill the circle. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_fillcirclewindow.c b/libnx/nxtk/nxtk_fillcirclewindow.c index b155e85ff92b50235f93e7fd7b71b2905f652b6d..20273be3a55cc083554556e19c6ea90d50c61a21 100644 --- a/libnx/nxtk/nxtk_fillcirclewindow.c +++ b/libnx/nxtk/nxtk_fillcirclewindow.c @@ -84,7 +84,7 @@ * radius - The radius of the circle in pixels. * color - The color to use to fill the circle. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_filltoolbar.c b/libnx/nxtk/nxtk_filltoolbar.c index 25eb6a8e8e833a733ba7a10139db1034bb268de8..146fc59ad22ca64ce65cdea293c70ef242bd626a 100644 --- a/libnx/nxtk/nxtk_filltoolbar.c +++ b/libnx/nxtk/nxtk_filltoolbar.c @@ -83,7 +83,7 @@ * rect - The location within the toolbar window to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_filltraptoolbar.c b/libnx/nxtk/nxtk_filltraptoolbar.c index 3ca0b38ad2361eb159c445f83d6079adeaa98530..afbc11be3e6abad497d2ab63a950e206cefafdb6 100644 --- a/libnx/nxtk/nxtk_filltraptoolbar.c +++ b/libnx/nxtk/nxtk_filltraptoolbar.c @@ -83,7 +83,7 @@ * trap - The trapezoidal region to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_filltrapwindow.c b/libnx/nxtk/nxtk_filltrapwindow.c index 88c3077223f2ea20ba85374f2c1c196e96e00b09..886ab81b8ba3bcbf1d0cbc4b5eee1c3c4e85a7d1 100644 --- a/libnx/nxtk/nxtk_filltrapwindow.c +++ b/libnx/nxtk/nxtk_filltrapwindow.c @@ -83,7 +83,7 @@ * trap - The trapezoidal region to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_fillwindow.c b/libnx/nxtk/nxtk_fillwindow.c index 9ff1caca57eb4bba494eccd8ae5ef22c606a1ed4..103fdc2795d94f5d0efbc8684e5f27060f8b22b8 100644 --- a/libnx/nxtk/nxtk_fillwindow.c +++ b/libnx/nxtk/nxtk_fillwindow.c @@ -83,7 +83,7 @@ * rect - The location within the client window to be filled * color - The color to use in the fill * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_getposition.c b/libnx/nxtk/nxtk_getposition.c index 1f0bdceeef7d08b3bb2fce23d19aa9e865ab545c..dafbe0113939ee8c0581cb68dd479cb5de4d5926 100644 --- a/libnx/nxtk/nxtk_getposition.c +++ b/libnx/nxtk/nxtk_getposition.c @@ -83,7 +83,7 @@ * Input Parameters: * hfwnd - The window handle returned by nxtk_openwindow. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_gettoolbar.c b/libnx/nxtk/nxtk_gettoolbar.c index bc05cbce94261939029d686f700c33033161a10f..ab404d12319a790a5f94ade423faffa6dedd9d8b 100644 --- a/libnx/nxtk/nxtk_gettoolbar.c +++ b/libnx/nxtk/nxtk_gettoolbar.c @@ -88,7 +88,7 @@ * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_getwindow.c b/libnx/nxtk/nxtk_getwindow.c index 4106267fb0cb311ba93d3a0119b3eeb9ecb5ab91..6f7e15e13125bd07d947b66b6ed676f5a71b6117 100644 --- a/libnx/nxtk/nxtk_getwindow.c +++ b/libnx/nxtk/nxtk_getwindow.c @@ -88,7 +88,7 @@ * dest - The location to copy the memory region * deststride - The width, in bytes, of the dest memory * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_lower.c b/libnx/nxtk/nxtk_lower.c index 08a588897d9833fa62ad5583772b93bc02e60a23..fee5fd075d9c71556da6bdff0a0cb1861239412d 100644 --- a/libnx/nxtk/nxtk_lower.c +++ b/libnx/nxtk/nxtk_lower.c @@ -79,11 +79,11 @@ * Lower the window containing the specified client sub-window to the * bottom of the display. * - * Input parameters: + * Input Parameters: * hfwnd - the window to be lowered. This must have been previously * created by nxtk_openwindow(). * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_movetoolbar.c b/libnx/nxtk/nxtk_movetoolbar.c index 913142a0d4ae37dc5d1f4c9859db01f5143a3e88..08a1e3beb332e3649083849d60ad9e761a5013f2 100644 --- a/libnx/nxtk/nxtk_movetoolbar.c +++ b/libnx/nxtk/nxtk_movetoolbar.c @@ -87,7 +87,7 @@ * sub-window to move * offset - The offset to move the region * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_movewindow.c b/libnx/nxtk/nxtk_movewindow.c index 302cff98d1d0bc23328c16f5c1f008b1bf8efd7b..e0064ba795f069e6a4507f3390c4ad5256862390 100644 --- a/libnx/nxtk/nxtk_movewindow.c +++ b/libnx/nxtk/nxtk_movewindow.c @@ -86,7 +86,7 @@ * sub-window to move * offset - The offset to move the region * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_opentoolbar.c b/libnx/nxtk/nxtk_opentoolbar.c index f5d58979eaaaede926b9217b769208fccc7687fa..2bf68b69c1f6d4faba95838a30f8b421b0582647 100644 --- a/libnx/nxtk/nxtk_opentoolbar.c +++ b/libnx/nxtk/nxtk_opentoolbar.c @@ -85,7 +85,7 @@ * arg - User provided value that will be returned with toolbar * callbacks. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_openwindow.c b/libnx/nxtk/nxtk_openwindow.c index ebefaec892060f1eb069f92fc2a4cc9a77f3f42a..f333ea79c7f75bbc197b3c48ff23e8494b4d14fc 100644 --- a/libnx/nxtk/nxtk_openwindow.c +++ b/libnx/nxtk/nxtk_openwindow.c @@ -107,7 +107,7 @@ nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES] = * cb - Callbacks used to process window events * arg - User provided value that will be returned with NXTK callbacks. * - * Return: + * Returned Value: * Success: A non-NULL handle used with subsequent NXTK window accesses * Failure: NULL is returned and errno is set appropriately * diff --git a/libnx/nxtk/nxtk_raise.c b/libnx/nxtk/nxtk_raise.c index d0273fe704845cb1e9951040a9f43abde41b3455..2fa954a6ea61afb9b5ece31409f5f1c42a6c3742 100644 --- a/libnx/nxtk/nxtk_raise.c +++ b/libnx/nxtk/nxtk_raise.c @@ -79,11 +79,11 @@ * Bring the window containing the specified client sub-window to the top * of the display. * - * Input parameters: + * Input Parameters: * hfwnd - the window to be raised. This must have been previously * created by nxtk_openwindow(). * - * Returned value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_setposition.c b/libnx/nxtk/nxtk_setposition.c index ed856252720a4484fc19f35e34a266b988c6c23b..642db0fb54094706f63448342a161de879618b5c 100644 --- a/libnx/nxtk/nxtk_setposition.c +++ b/libnx/nxtk/nxtk_setposition.c @@ -84,7 +84,7 @@ * hfwnd - The window handle returned by nxtk_openwindow * pos - The new position of the client sub-window * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_setsize.c b/libnx/nxtk/nxtk_setsize.c index 7e9079696647c847f2551fc6a00ef0cdc0a476ae..d9ccfe46c8ed1bc1331f4adb87e745e67da88577 100644 --- a/libnx/nxtk/nxtk_setsize.c +++ b/libnx/nxtk/nxtk_setsize.c @@ -84,7 +84,7 @@ * hfwnd - The window handle returned by nxtk_openwindow * size - The new size of the client sub-window. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_subwindowclip.c b/libnx/nxtk/nxtk_subwindowclip.c index b1b4024ee7e813ccb3155da86a9e9727bcf33c0d..3aa0a5dc2895e9a19ed2ae267a8151ce224f85b1 100644 --- a/libnx/nxtk/nxtk_subwindowclip.c +++ b/libnx/nxtk/nxtk_subwindowclip.c @@ -83,13 +83,13 @@ * containing window (i.e., (0,0) is the top left corner of the containing * window). * - * Input parameters: + * Input Parameters: * fwnd - The framed window to be used * dest - The locaton to put the result * src - The src rectangle in relative sub-window coordinates * bounds - The subwindow bounds in absolute screen coordinates. * - * Returned value: + * Returned Value: * None * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_subwindowmove.c b/libnx/nxtk/nxtk_subwindowmove.c index 6b80609d3da5bef106e858f4b95c5c6ddbb642fc..2c14d010ce679509c76385d4ac16cded0e26e5e7 100644 --- a/libnx/nxtk/nxtk_subwindowmove.c +++ b/libnx/nxtk/nxtk_subwindowmove.c @@ -89,7 +89,7 @@ * srcoffset - The offset to move the region * bounds - The subwindow bounds in absolute screen coordinates. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/libnx/nxtk/nxtk_toolbarbounds.c b/libnx/nxtk/nxtk_toolbarbounds.c index eacaf9057311c1c280e763302334e15d32b3f86b..0657d6027602d1f518aa35e64b8b6ad763064db2 100644 --- a/libnx/nxtk/nxtk_toolbarbounds.c +++ b/libnx/nxtk/nxtk_toolbarbounds.c @@ -87,7 +87,7 @@ * hfwnd - The handle returned by nxtk_openwindow * bounds - User provided location in which to return the bounding box. * - * Return: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ diff --git a/mm/iob/Kconfig b/mm/iob/Kconfig index b64f90e3ce865432bb01f7ef03a4fff6b1ec5707..62893db094016e8752e5e9dcdd46627bd3d45b98 100644 --- a/mm/iob/Kconfig +++ b/mm/iob/Kconfig @@ -16,9 +16,9 @@ if MM_IOB config IOB_NBUFFERS int "Number of pre-allocated I/O buffers" - default 24 if (NET_TCP_WRITE_BUFFERS && !NET_TCP_READAHEAD) || (!NET_TCP_WRITE_BUFFERS && NET_TCP_READAHEAD) - default 36 if NET_TCP_WRITE_BUFFERS && NET_TCP_READAHEAD - default 8 if !NET_TCP_WRITE_BUFFERS && !NET_TCP_READAHEAD + default 24 if (NET_WRITE_BUFFERS && !NET_READAHEAD) || (!NET_WRITE_BUFFERS && NET_READAHEAD) + default 36 if NET_WRITE_BUFFERS && NET_READAHEAD + default 8 if !NET_WRITE_BUFFERS && !NET_READAHEAD ---help--- Each packet is represented by a series of small I/O buffers in a chain. This setting determines the number of preallocated I/O @@ -34,8 +34,8 @@ config IOB_BUFSIZE config IOB_NCHAINS int "Number of pre-allocated I/O buffer chain heads" - default 0 if !NET_TCP_READAHEAD && !NET_UDP_READAHEAD - default 8 if NET_TCP_READAHEAD || NET_UDP_READAHEAD + default 0 if !NET_READAHEAD && !NET_UDP_READAHEAD + default 8 if NET_READAHEAD || NET_UDP_READAHEAD ---help--- These tiny nodes are used as "containers" to support queueing of I/O buffer chains. This will limit the number of I/O transactions @@ -49,8 +49,8 @@ config IOB_NCHAINS config IOB_THROTTLE int "I/O buffer throttle value" - default 0 if !NET_TCP_WRITE_BUFFERS || !NET_TCP_READAHEAD - default 8 if NET_TCP_WRITE_BUFFERS && NET_TCP_READAHEAD + default 0 if !NET_WRITE_BUFFERS || !NET_READAHEAD + default 8 if NET_WRITE_BUFFERS && NET_READAHEAD ---help--- TCP write buffering and read-ahead buffer use the same pool of free I/O buffers. In order to prevent uncontrolled incoming TCP packets diff --git a/mm/kmm_heap/kmm_addregion.c b/mm/kmm_heap/kmm_addregion.c index 41884fa7c35f98b1d13309031c2775c550438c8c..96bf448eec99bb817411ba60aca41cf145945520 100644 --- a/mm/kmm_heap/kmm_addregion.c +++ b/mm/kmm_heap/kmm_addregion.c @@ -57,7 +57,7 @@ * heap_start - Address of the beginning of the memory region * heap_size - The size (in bytes) if the memory region. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_free.c b/mm/kmm_heap/kmm_free.c index c9016788188a24bc775222abd836726bb7c90b34..466b268b7eafd04cbc401688ad31c3eb8a66772f 100644 --- a/mm/kmm_heap/kmm_free.c +++ b/mm/kmm_heap/kmm_free.c @@ -60,7 +60,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_heapmember.c b/mm/kmm_heap/kmm_heapmember.c index 53fa7027b7d00dbe16eb84064664f0d81741e819..dc1c916ef7ef75f754272be6119b78b2998d8373 100644 --- a/mm/kmm_heap/kmm_heapmember.c +++ b/mm/kmm_heap/kmm_heapmember.c @@ -58,7 +58,7 @@ * Parameters: * mem - The address to check * - * Return Value: + * Returned Value: * true if the address is a member of the kernel heap. false if not * not. If the address is not a member of the kernel heap, then it * must be a member of the user-space heap (unchecked) diff --git a/mm/kmm_heap/kmm_initialize.c b/mm/kmm_heap/kmm_initialize.c index 03baba81203434cd5da82417ae3135bb2659af34..4bf8d990274ce70043354715519106b6c0f696b7 100644 --- a/mm/kmm_heap/kmm_initialize.c +++ b/mm/kmm_heap/kmm_initialize.c @@ -66,7 +66,7 @@ struct mm_heap_s g_kmmheap; * heap_start - Address of the beginning of the (initial) memory region * heap_size - The size (in bytes) if the (initial) memory region. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_kernel.c b/mm/kmm_heap/kmm_kernel.c index e2fc9232b818b0e30438568bac6a2d722c9376c5..0faf6944abe09e5dd9b9f8a49a91c357e4aebdb3 100644 --- a/mm/kmm_heap/kmm_kernel.c +++ b/mm/kmm_heap/kmm_kernel.c @@ -59,7 +59,7 @@ * Parameters: * mem - The address to check * - * Return Value: + * Returned Value: * true if the address is a member of the kernel heap. false if not * not. If the address is not a member of the kernel heap, then it * must be a member of the user-space heap (unchecked) diff --git a/mm/kmm_heap/kmm_malloc.c b/mm/kmm_heap/kmm_malloc.c index 06bed81c50110f49ab096aacc03fd93ac5c63bcc..9f0e6e7949fff6070fadbbd509df1be25242dd95 100644 --- a/mm/kmm_heap/kmm_malloc.c +++ b/mm/kmm_heap/kmm_malloc.c @@ -56,7 +56,7 @@ * Parameters: * size - Size (in bytes) of the memory region to be allocated. * - * Return Value: + * Returned Value: * The address of the allocated memory (NULL on failure to allocate) * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_memalign.c b/mm/kmm_heap/kmm_memalign.c index 2ca1465bf02a3e2c8415db3718b917dee976aaa4..9c0ba608ecae1d604f52e4d6b56f4f980ad7e26d 100644 --- a/mm/kmm_heap/kmm_memalign.c +++ b/mm/kmm_heap/kmm_memalign.c @@ -59,7 +59,7 @@ * alignment - Log2 byte alignment * size - Size (in bytes) of the new memory region to be allocated. * - * Return Value: + * Returned Value: * The address of the re-allocated memory (NULL on failure to allocate) * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_realloc.c b/mm/kmm_heap/kmm_realloc.c index 477e2b70b1864930e2e0ad145bc1569f98a793ac..f06d6fa161770ef45458e57c27564f0be67c9c22 100644 --- a/mm/kmm_heap/kmm_realloc.c +++ b/mm/kmm_heap/kmm_realloc.c @@ -57,7 +57,7 @@ * oldmem - The old memory allocated * newsize - Size (in bytes) of the new memory region to be re-allocated. * - * Return Value: + * Returned Value: * The address of the re-allocated memory (NULL on failure to re-allocate) * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_sem.c b/mm/kmm_heap/kmm_sem.c index 2ba019f6732468d6d9ba9b7bdac8d7a349f06e85..dc05bf78ed7390bd97cf647da354039ed410b39b 100644 --- a/mm/kmm_heap/kmm_sem.c +++ b/mm/kmm_heap/kmm_sem.c @@ -56,7 +56,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * OK on success; a negated errno on failure * ****************************************************************************/ @@ -75,7 +75,7 @@ int kmm_trysemaphore(void) * Parameters: * None * - * Return Value: + * Returned Value: * OK on success; a negated errno on failure * ****************************************************************************/ diff --git a/mm/kmm_heap/kmm_zalloc.c b/mm/kmm_heap/kmm_zalloc.c index 19bea29f15983320443ceaa0a5d68ba7a16a176c..525ee8cb8d9e2f0326f36df5c11b14236c214d97 100644 --- a/mm/kmm_heap/kmm_zalloc.c +++ b/mm/kmm_heap/kmm_zalloc.c @@ -56,7 +56,7 @@ * Parameters: * size - Size (in bytes) of the memory region to be allocated. * - * Return Value: + * Returned Value: * The address of the allocated memory (NULL on failure to allocate) * ****************************************************************************/ diff --git a/mm/mm_heap/mm_initialize.c b/mm/mm_heap/mm_initialize.c index 7696676fde3ba26556df17df80443b27f0788b07..becafc88a64fc86f6ed9682aa1635f343221dafe 100644 --- a/mm/mm_heap/mm_initialize.c +++ b/mm/mm_heap/mm_initialize.c @@ -60,7 +60,7 @@ * heapstart - Start of the heap region * heapsize - Size of the heap region * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -145,7 +145,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart, * heapstart - Start of the initial heap region * heapsize - Size of the initial heap region * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/mm/mm_heap/mm_sem.c b/mm/mm_heap/mm_sem.c index fae3b2786781bdfe222576f85cf39ccd56f7826b..51eda272a595fed706ce9d9c86f60e1299abdd72 100644 --- a/mm/mm_heap/mm_sem.c +++ b/mm/mm_heap/mm_sem.c @@ -200,7 +200,7 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap) #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) DEBUGASSERT(ret == -EINTR); #else - int errcode = errno; + int errcode = get_errno(); DEBUGASSERT(errcode == EINTR); ret = -errcode; #endif diff --git a/mm/shm/shmget.c b/mm/shm/shmget.c index 682b4707edeadabc27ef9fd245dacc181f05cd53..c7701cbfc822b24b23feebbbd32a615c2e659096 100644 --- a/mm/shm/shmget.c +++ b/mm/shm/shmget.c @@ -63,10 +63,10 @@ * Description: * Find the shared memory region with matching key * - * Input parameters: + * Input Parameters: * key - The value that uniquely identifies a shared memory region. * - * Returned value: + * Returned Value: * On success, an index in the range of 0 to CONFIG_ARCH_SHM_MAXREGIONS-1 * is returned to identify the matching region; -ENOENT is returned on * failure. @@ -94,10 +94,10 @@ static int shm_find(key_t key) * Description: * Allocate an unused shared memory region. That is one with a key of -1 * - * Input parameters: + * Input Parameters: * None * - * Returned value: + * Returned Value: * On success, an index in the range of 0 to CONFIG_ARCH_SHM_MAXREGIONS-1 * is returned to identify the matching region; -ENOSPC is returned on * failure. @@ -154,12 +154,12 @@ static int shm_reserve(key_t key, int shmflg) * Extend the size of a memory regions by allocating physical pages as * necessary * - * Input parameters: + * Input Parameters: * shmid - The index of the region of interest in the shared memory region * table. * size - The new size of the region. * - * Returned value: + * Returned Value: * Zero is returned on success; -ENOMEM is returned on failure. * (Should a different error be returned if the region is just too big?) * @@ -224,7 +224,7 @@ static int shm_extend(int shmid, size_t size) * Description: * Create the shared memory region. * - * Input parameters: + * Input Parameters: * key - The key that is used to access the unique shared memory * identifier. * size - The shared memory region that is created will be at least @@ -232,7 +232,7 @@ static int shm_extend(int shmid, size_t size) * shmflgs - See IPC_* definitions in sys/ipc.h. Only the values * IPC_PRIVATE or IPC_CREAT are supported. * - * Returned value: + * Returned Value: * Zero is returned on success; A negated errno value is returned on * failure. * diff --git a/mm/umm_heap/umm_addregion.c b/mm/umm_heap/umm_addregion.c index 00e5372ee8bce1b7b8db613f9048261885ce8f91..9197cf3f334e2374e7be84abe84799536b40f6f8 100644 --- a/mm/umm_heap/umm_addregion.c +++ b/mm/umm_heap/umm_addregion.c @@ -59,7 +59,7 @@ * heap_start - Address of the beginning of the memory region * heap_size - The size (in bytes) if the memory region. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/mm/umm_heap/umm_initialize.c b/mm/umm_heap/umm_initialize.c index 04e045e0730499ca60d2bf990697765dc1ff94f9..55fc430fc19a25da0a52f253debc650fcf612ee5 100644 --- a/mm/umm_heap/umm_initialize.c +++ b/mm/umm_heap/umm_initialize.c @@ -89,7 +89,7 @@ * heap_start - Address of the beginning of the (initial) memory region * heap_size - The size (in bytes) if the (initial) memory region. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/mm/umm_heap/umm_malloc.c b/mm/umm_heap/umm_malloc.c index 7832af4e2938f962905554da18a744bccef4d4bc..ddbb03a2c6bdd9d7028d61649ae43b3393fd9283 100644 --- a/mm/umm_heap/umm_malloc.c +++ b/mm/umm_heap/umm_malloc.c @@ -59,7 +59,7 @@ * Parameters: * size - Size (in bytes) of the memory region to be allocated. * - * Return Value: + * Returned Value: * The address of the allocated memory (NULL on failure to allocate) * ****************************************************************************/ diff --git a/mm/umm_heap/umm_realloc.c b/mm/umm_heap/umm_realloc.c index a517aa200a9dfacb17f4b3c77a67d8d586a66caf..394a4e2cd2c644334d37bd80c03e2e03989ea51e 100644 --- a/mm/umm_heap/umm_realloc.c +++ b/mm/umm_heap/umm_realloc.c @@ -59,7 +59,7 @@ * oldmem - The old memory allocated * newsize - Size (in bytes) of the new memory region to be re-allocated. * - * Return Value: + * Returned Value: * The address of the re-allocated memory (NULL on failure to re-allocate) * ****************************************************************************/ diff --git a/mm/umm_heap/umm_sem.c b/mm/umm_heap/umm_sem.c index a9012e542c2bfbc6d2f106eff20685fd35356a48..37b0fb42cdd7b819d0dd5b72327ee3737dbad6d0 100644 --- a/mm/umm_heap/umm_sem.c +++ b/mm/umm_heap/umm_sem.c @@ -58,7 +58,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * OK on success; a negated errno on failure * ****************************************************************************/ @@ -79,7 +79,7 @@ int umm_trysemaphore(void) * Parameters: * None * - * Return Value: + * Returned Value: * OK on success; a negated errno on failure * ****************************************************************************/ diff --git a/mm/umm_heap/umm_zalloc.c b/mm/umm_heap/umm_zalloc.c index 7103e3233b66b3811bf25c51329663f98732546a..6ce7fe14fbc74da6e071b614066dbfaa503ae2cf 100644 --- a/mm/umm_heap/umm_zalloc.c +++ b/mm/umm_heap/umm_zalloc.c @@ -59,7 +59,7 @@ * Parameters: * size - Size (in bytes) of the memory region to be allocated. * - * Return Value: + * Returned Value: * The address of the allocated memory (NULL on failure to allocate) * ****************************************************************************/ diff --git a/net/Kconfig b/net/Kconfig index 48163d26bfa49026fa541e238857367055181013..3c4f969486b1a15b503c11be5da6723e083d7a34 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -11,6 +11,14 @@ config ARCH_HAVE_PHY bool default n +config NET_WRITE_BUFFERS + bool + default n + +config NET_READAHEAD + bool + default n + config NET bool "Networking support" default n diff --git a/net/arp/arp.h b/net/arp/arp.h index 0fbea68c510a38b58bf765c1110fe29e7e8cf4ec..643c5a609341feef21df23a59aefb1911c2d54fe 100644 --- a/net/arp/arp.h +++ b/net/arp/arp.h @@ -374,7 +374,7 @@ void arp_notify(in_addr_t ipaddr); * Description: * Find the ARP entry corresponding to this IP address. * - * Input parameters: + * Input Parameters: * ipaddr - Refers to an IP address in network order * * Assumptions @@ -391,7 +391,7 @@ FAR struct arp_entry *arp_find(in_addr_t ipaddr); * Description: * Remove an IP association from the ARP table * - * Input parameters: + * Input Parameters: * ipaddr - Refers to an IP address in network order * * Assumptions @@ -416,7 +416,7 @@ FAR struct arp_entry *arp_find(in_addr_t ipaddr); * Add the IP/HW address mapping to the ARP table -OR- change the IP * address of an existing association. * - * Input parameters: + * Input Parameters: * ipaddr - The IP address as an inaddr_t * ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN] * @@ -438,7 +438,7 @@ int arp_update(in_addr_t ipaddr, FAR uint8_t *ethaddr); * Add the IP/HW address mapping to the ARP table -OR- change the IP * address of an existing association. * - * Input parameters: + * Input Parameters: * pipaddr - Refers to an IP address uint16_t[2] in network order * ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN] * diff --git a/net/arp/arp_table.c b/net/arp/arp_table.c index 928ed5901939adf879e55ce8f8f8bd0c742894a6..d8818ddf39653684e20d6c99a82507f9aa3759ff 100644 --- a/net/arp/arp_table.c +++ b/net/arp/arp_table.c @@ -129,7 +129,7 @@ void arp_timer(void) * Add the IP/HW address mapping to the ARP table -OR- change the IP * address of an existing association. * - * Input parameters: + * Input Parameters: * ipaddr - The IP address as an inaddr_t * ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN] * @@ -227,7 +227,7 @@ int arp_update(in_addr_t ipaddr, FAR uint8_t *ethaddr) * Add the IP/HW address mapping to the ARP table -OR- change the IP * address of an existing association. * - * Input parameters: + * Input Parameters: * pipaddr - Refers to an IP address uint16_t[2] in network order * ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN] * @@ -255,7 +255,7 @@ void arp_hdr_update(FAR uint16_t *pipaddr, FAR uint8_t *ethaddr) * Description: * Find the ARP entry corresponding to this IP address. * - * Input parameters: + * Input Parameters: * ipaddr - Refers to an IP address in network order * * Assumptions diff --git a/net/devif/devif.h b/net/devif/devif.h index 438e275f46e6ad255a6ebfde58148e4ed791b601..2eeb97f7f0449a8f019bebed17bb58a54311a9ff 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -309,7 +309,7 @@ EXTERN systime_t g_polltime; * Parameters: * None * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -400,7 +400,7 @@ void devif_dev_callback_free(FAR struct net_driver_s *dev, * Description: * Execute a list of callbacks. * - * Input parameters: + * Input Parameters: * dev - The network device state structure associated with the network * device that initiated the callback event. * pvconn - Holds a reference to the TCP connection structure or the UDP @@ -409,7 +409,7 @@ void devif_dev_callback_free(FAR struct net_driver_s *dev, * flags - The bit set of events to be notified. * list - The list to traverse in performing the notifications * - * Returned value: + * Returned Value: * The updated flags as modified by the callback functions. * * Assumptions: @@ -426,7 +426,7 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, FAR void *pvconn, * Description: * Execute a list of callbacks using the device event chain. * - * Input parameters: + * Input Parameters: * dev - The network device state structure associated with the network * device that initiated the callback event. * pvconn - Holds a reference to the TCP connection structure or the UDP @@ -434,7 +434,7 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, FAR void *pvconn, * connection or UDP port. * flags - The bit set of events to be notified. * - * Returned value: + * Returned Value: * The updated flags as modified by the callback functions. * * Assumptions: diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c index 92718b9798f78c9434775833c1f302856217349d..e2261b750fe408b7fefc78e426ed8ee7f0914805 100644 --- a/net/devif/devif_callback.c +++ b/net/devif/devif_callback.c @@ -170,7 +170,7 @@ static void devif_callback_free(FAR struct net_driver_s *dev, * Return true if the current set of events should trigger a callback to * occur. * - * Input paramters: + * Input Parameters: * events - The set of events that has occurred. * triggers - The set of events that will trigger a callback. * @@ -402,7 +402,7 @@ void devif_dev_callback_free(FAR struct net_driver_s *dev, * Description: * Execute a list of callbacks using the packet event chain. * - * Input parameters: + * Input Parameters: * dev - The network device state structure associated with the network * device that initiated the callback event. * pvconn - Holds a reference to the TCP connection structure or the UDP @@ -411,7 +411,7 @@ void devif_dev_callback_free(FAR struct net_driver_s *dev, * flags - The bit set of events to be notified. * list - The list to traverse in performing the notifications * - * Returned value: + * Returned Value: * The updated flags as modified by the callback functions. * * Assumptions: @@ -465,7 +465,7 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, void *pvconn, * Description: * Execute a list of callbacks using the device event chain. * - * Input parameters: + * Input Parameters: * dev - The network device state structure associated with the network * device that initiated the callback event. * pvconn - Holds a reference to the TCP connection structure or the UDP @@ -473,7 +473,7 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, void *pvconn, * connection or UDP port. * flags - The bit set of events to be notified. * - * Returned value: + * Returned Value: * The updated flags as modified by the callback functions. * * Assumptions: diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index 244d7a1b6c5a01b3cca96be51677613e324889cf..ecbe15479e7d98229e99ee3fe73b11ce9b38ade6 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -85,7 +85,7 @@ uint8_t g_reassembly_timer; * Parameters: * None * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/net/icmp/icmp.h b/net/icmp/icmp.h index 77aa832f8f4c4135723371d38811918f91229e72..d17f5d1fbd67d295ab6648df03e162649b7b6e7f 100644 --- a/net/icmp/icmp.h +++ b/net/icmp/icmp.h @@ -129,7 +129,7 @@ struct pollfd; /* Forward reference */ * dev - The device driver structure containing the received ICMP * packet * - * Return: + * Returned Value: * None * * Assumptions: @@ -235,7 +235,7 @@ FAR struct icmp_conn_s *icmp_findconn(FAR struct net_driver_s *dev, uint8_t id); * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmp/icmp_input.c b/net/icmp/icmp_input.c index 38937dad6427c5a5230cf4fd488ea2eaebf9500f..973b0326c159709c63ef7313d1ef2bf044284666 100644 --- a/net/icmp/icmp_input.c +++ b/net/icmp/icmp_input.c @@ -89,7 +89,7 @@ * buffers * buflen - The number of bytes to copy to the read-ahead buffer. * - * Returned value: + * Returned Value: * The number of bytes actually buffered is returned. This will be either * zero or equal to buflen; partial packets are not buffered. * @@ -214,7 +214,7 @@ drop: * dev - The device driver structure containing the received ICMP * packet * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmp/icmp_poll.c b/net/icmp/icmp_poll.c index f86e3a6e1461c031e4c9e02c0b0a4bbcc955989f..190bc067444774836d30424192772115086586f5 100644 --- a/net/icmp/icmp_poll.c +++ b/net/icmp/icmp_poll.c @@ -62,7 +62,7 @@ * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmp/icmp_sendto.c b/net/icmp/icmp_sendto.c index 9ee74e000e1e137a78ae4f6b3533ac646b4214d5..7c20668273f3f57636f1f17884d618d7369c8f73 100644 --- a/net/icmp/icmp_sendto.c +++ b/net/icmp/icmp_sendto.c @@ -150,7 +150,7 @@ static inline int sendto_timeout(FAR struct icmp_sendto_s *pstate) * dev - The device driver structure to use in the send operation * pstate - Reference to an instance of the ICMP sendto state structure * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index 582712c5e532c3e7eab307eef036264fc8b79a7d..f5bee4251e47e402e3b1d92b16774e09042680f6 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -158,7 +158,7 @@ struct pollfd; /* Forward reference */ * dev - The device driver structure containing the received ICMPv6 * packet * - * Return: + * Returned Value: * None * * Assumptions: @@ -214,7 +214,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr); * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: @@ -236,7 +236,7 @@ void icmpv6_poll(FAR struct net_driver_s *dev); * dev - Reference to an Ethernet device driver structure * ipaddr - IP address of Neighbor to be solicited * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -261,7 +261,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, * Parameters: * dev - Reference to an Ethernet device driver structure * - * Return: + * Returned Value: * None * ****************************************************************************/ @@ -280,7 +280,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev); * dev - The device driver structure containing the outgoing ICMPv6 packet * buffer * - * Return: + * Returned Value: * None. * * Assumptions: @@ -301,7 +301,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, * dev - The device driver structure containing the outgoing ICMPv6 packet * buffer * - * Return: + * Returned Value: * None * * Assumptions: @@ -406,7 +406,7 @@ void icmpv6_notify(net_ipv6addr_t ipaddr); * Parameters: * dev - The device driver structure to assign the address to * - * Return: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned on * any failure. * diff --git a/net/icmpv6/icmpv6_advertise.c b/net/icmpv6/icmpv6_advertise.c index 37c8c8ebb967120ff53015852934fafe6ec3c22a..e0a7d8a770a9bf22ac65c933890419e5f8824adf 100644 --- a/net/icmpv6/icmpv6_advertise.c +++ b/net/icmpv6/icmpv6_advertise.c @@ -85,7 +85,7 @@ * dev - The device driver structure containing the outgoing ICMPv6 packet * buffer * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmpv6/icmpv6_autoconfig.c b/net/icmpv6/icmpv6_autoconfig.c index bb481224e2de64172f8f18a123754e19dee6e810..3f1ea9d2a65c63a36feadf9f1116fbaf24677809 100644 --- a/net/icmpv6/icmpv6_autoconfig.c +++ b/net/icmpv6/icmpv6_autoconfig.c @@ -331,7 +331,7 @@ static int icmpv6_wait_radvertise(FAR struct net_driver_s *dev, * Parameters: * dev - The device driver structure to assign the address to * - * Return: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned on * any failure. * diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index 66030ad90106270b491a782d28170a6a5fda3698..42c2e8c55dce23ce543734a886caa282fda0013c 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -99,7 +99,7 @@ * buffers * buflen - The number of bytes to copy to the read-ahead buffer. * - * Returned value: + * Returned Value: * The number of bytes actually buffered is returned. This will be either * zero or equal to buflen; partial packets are not buffered. * @@ -221,7 +221,7 @@ drop: * dev - The device driver structure containing the received ICMPv6 * packet * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmpv6/icmpv6_poll.c b/net/icmpv6/icmpv6_poll.c index 145dd62e69995cf825e129accdbec307f377237d..d6853ff4a645b5a8b5fcfea221cab97df5c41171 100644 --- a/net/icmpv6/icmpv6_poll.c +++ b/net/icmpv6/icmpv6_poll.c @@ -63,7 +63,7 @@ * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmpv6/icmpv6_rsolicit.c b/net/icmpv6/icmpv6_rsolicit.c index 1ff49d712c6f895a0f60674052857ac14b8a5cd1..ba24bbeef1964b6d488fa4e548918b8cb8c6560d 100644 --- a/net/icmpv6/icmpv6_rsolicit.c +++ b/net/icmpv6/icmpv6_rsolicit.c @@ -84,7 +84,7 @@ * Parameters: * dev - Reference to an Ethernet device driver structure * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/net/icmpv6/icmpv6_sendto.c b/net/icmpv6/icmpv6_sendto.c index cbff44a3ea70f4d83b1b22c670af8651a729513a..8db6d370e7fd2643cd425add06d4dfcdc5fcb192 100644 --- a/net/icmpv6/icmpv6_sendto.c +++ b/net/icmpv6/icmpv6_sendto.c @@ -150,7 +150,7 @@ static inline int sendto_timeout(FAR struct icmpv6_sendto_s *pstate) * dev - The device driver structure to use in the send operation * pstate - Reference to an instance of the ICMPv6 sendto state structure * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/icmpv6/icmpv6_solicit.c b/net/icmpv6/icmpv6_solicit.c index 7fa1a55d19f20a646cfe8fc7d1f9b726cd1cbe66..30fe57b26634e05f3cda0b5178709f30be9b6dda 100644 --- a/net/icmpv6/icmpv6_solicit.c +++ b/net/icmpv6/icmpv6_solicit.c @@ -94,7 +94,7 @@ static const uint16_t g_icmpv_mcastaddr[6] = * dev - Reference to an Ethernet device driver structure * ipaddr - IP address of Neighbor to be solicited * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/net/ieee802154/ieee802154.h b/net/ieee802154/ieee802154.h index bf60db0530e89fa30708455d821174ace75fc315..3dc16735070d855ec09f2e196b6efa546263a856 100644 --- a/net/ieee802154/ieee802154.h +++ b/net/ieee802154/ieee802154.h @@ -268,7 +268,7 @@ FAR struct ieee802154_conn_s * * If there are multilple frames in the list, this metadata * must apply to all of the frames in the list. * - * Return: + * Returned Value: * OK The IEEE 802.15.4 has been processed and can be deleted * ERROR Hold the IEEE 802.15.4 and try again later. There is a listening * socket but no recv in place to catch the IEEE 802.15.4 yet. @@ -364,7 +364,7 @@ FAR struct radio_driver_s * * dev - The device driver structure to use in the send operation * conn - The IEEE 802.15.4 "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: @@ -413,10 +413,10 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, * be called early in the initialization sequence before any socket * activity. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -437,10 +437,10 @@ void ieee802154_container_initialize(void); * list. If that the list is empty, then the meta-data structure will be * allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * A reference to the allocated container structure. All user fields in this * structure have been zeroed. On a failure to allocate, NULL is * returned. @@ -461,10 +461,10 @@ FAR struct ieee802154_container_s *ieee802154_container_allocate(void); * structure. If the container structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * container - container structure to free * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/net/ieee802154/ieee802154_container.c b/net/ieee802154/ieee802154_container.c index af70fe645d12853bd355b4985a63855815b1d0da..88f01755dec44b86a8817996ff2b6cf41bc202fe 100644 --- a/net/ieee802154/ieee802154_container.c +++ b/net/ieee802154/ieee802154_container.c @@ -82,10 +82,10 @@ static struct ieee802154_container_s * be called early in the initialization sequence before any socket * activity. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -127,10 +127,10 @@ void ieee802154_container_initialize(void) * list. If that the list is empty, then the meta-data structure will be * allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * A reference to the allocated container structure. All user fields in this * structure have been zeroed. On a failure to allocate, NULL is * returned. @@ -185,10 +185,10 @@ FAR struct ieee802154_container_s *ieee802154_container_allocate(void) * structure. If the container structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * container - container structure to free * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/net/ieee802154/ieee802154_input.c b/net/ieee802154/ieee802154_input.c index 1d50451cc3055ce5e1ad26e24221c3a6710b6eff..57f32eaf700558bae6148f2ec8b26e181eb699d0 100644 --- a/net/ieee802154/ieee802154_input.c +++ b/net/ieee802154/ieee802154_input.c @@ -64,7 +64,7 @@ * Parameters: * conn - The socket connection structure. * - * Return: + * Returned Value: * The number of frames in the queue. * ****************************************************************************/ @@ -96,7 +96,7 @@ static int ieee802154_count_frames(FAR struct ieee802154_conn_s *conn) * framel - A single frame to add to the RX queue. * meta - Meta data characterizing the received frane. * - * Return: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned on * any failure. * @@ -227,7 +227,7 @@ static int ieee802154_queue_frame(FAR struct ieee802154_conn_s *conn, * If there are multilple frames in the list, this metadata * must apply to all of the frames in the list. * - * Return: + * Returned Value: * OK The IEEE 802.15.4 has been processed and can be deleted * ERROR Hold the IEEE 802.15.4 and try again later. There is a listening * socket but no recv in place to catch the IEEE 802.15.4 yet. diff --git a/net/ieee802154/ieee802154_poll.c b/net/ieee802154/ieee802154_poll.c index 0d313e0e4b62c62eb3b8209e7e543f5ff37c99f0..fb33ea1bbb62bb1c38b0874a0d6c4c0a362e695b 100644 --- a/net/ieee802154/ieee802154_poll.c +++ b/net/ieee802154/ieee802154_poll.c @@ -64,7 +64,7 @@ * dev - The device driver structure to use in the send operation * conn - The packet "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/ieee802154/ieee802154_recvfrom.c b/net/ieee802154/ieee802154_recvfrom.c index 2e47f18fb72f4c115b8629e8a86a40711dcc3e0b..7ee3c7d04134caf19c43335bbfb59199f8a248de 100644 --- a/net/ieee802154/ieee802154_recvfrom.c +++ b/net/ieee802154/ieee802154_recvfrom.c @@ -91,7 +91,7 @@ struct ieee802154_recvfrom_s * Parameters: * conn - The socket connection structure. * - * Return: + * Returned Value: * The number of frames in the queue. * ****************************************************************************/ @@ -121,7 +121,7 @@ static int ieee802154_count_frames(FAR struct ieee802154_conn_s *conn) * * Parameters: * - * Returned Values: + * Returned Value: * * Assumptions: * The network is lockec @@ -209,7 +209,7 @@ static ssize_t ieee802154_recvfrom_rxqueue(FAR struct radio_driver_s *radio, * * Parameters: * - * Returned Values: + * Returned Value: * * Assumptions: * The network is locked. diff --git a/net/ieee802154/ieee802154_sendto.c b/net/ieee802154/ieee802154_sendto.c index 2c2c79e5b1b5746ce97c0029a2479903c374c764..47657ac1f95d473573fc0c33ea022d303b9d02e9 100644 --- a/net/ieee802154/ieee802154_sendto.c +++ b/net/ieee802154/ieee802154_sendto.c @@ -96,7 +96,7 @@ struct ieee802154_sendto_s * If the destination address is all zero in the MAC header buf, then it is * broadcast on the 802.15.4 network. * - * Input parameters: + * Input Parameters: * addr - The address to check * addrlen - The length of the address in bytes * @@ -125,7 +125,7 @@ static bool ieee802154_anyaddrnull(FAR const uint8_t *addr, uint8_t addrlen) * If the destination address is all zero in the MAC header buf, then it is * broadcast on the 802.15.4 network. * - * Input parameters: + * Input Parameters: * eaddr - The short address to check * * Returned Value: @@ -145,7 +145,7 @@ static inline bool ieee802154_saddrnull(FAR const uint8_t *saddr) * If the destination address is all zero in the MAC header buf, then it is * broadcast on the 802.15.4 network. * - * Input parameters: + * Input Parameters: * eaddr - The extended address to check * * Returned Value: diff --git a/net/igmp/igmp.h b/net/igmp/igmp.h index 4850bd511ed6f0a600d18bdf16f6018a8af052fc..eef6cad00b4a5fd4eaa723428c914595d9899c22 100644 --- a/net/igmp/igmp.h +++ b/net/igmp/igmp.h @@ -247,7 +247,7 @@ void igmp_poll(FAR struct net_driver_s *dev); * message to be sent. * destipaddr - The IP address of the recipient of the message * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/igmp/igmp_send.c b/net/igmp/igmp_send.c index 3a28cccc8c6c05bfbb4f178692de2438fdc5023a..e6941d7f2b645dce45d2238627900ea04271647b 100644 --- a/net/igmp/igmp_send.c +++ b/net/igmp/igmp_send.c @@ -106,7 +106,7 @@ static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen) * message to be sent. * destipaddr - The IP address of the recipient of the message * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/inet/inet_close.c b/net/inet/inet_close.c index a36089e541716eec081452cbc9a07094174439e7..14c463c628b04d572dca4de3dff1794995b39d34 100644 --- a/net/inet/inet_close.c +++ b/net/inet/inet_close.c @@ -345,7 +345,7 @@ static inline int tcp_close_disconnect(FAR struct socket *psock) #ifdef CONFIG_NET_TCP_WRITE_BUFFERS /* If we have a semi-permanent write buffer callback in place, then - * is needs to be be nullifed. + * is needs to be be nullified. * * Commit f1ef2c6cdeb032eaa1833cc534a63b50c5058270: * "When a socket is closed, it should make sure that any pending write @@ -357,6 +357,9 @@ static inline int tcp_close_disconnect(FAR struct socket *psock) * data. However, to be able to actually send any new data, the send * callback must be left. The callback should be freed later when the * socket is actually destroyed." + * + * REVISIT: Where and how exactly is s_sndcb ever freed? Is there a + * memory leak here? */ psock->s_sndcb = NULL; @@ -548,7 +551,18 @@ int inet_close(FAR struct socket *psock) if (conn->crefs <= 1) { - /* Yes... free the connection structure */ + /* Yes... */ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS + /* Free any semi-permanent write buffer callback in place. */ + + if (psock->s_sndcb != NULL) + { + udp_callback_free(conn->dev, conn, psock->s_sndcb); + psock->s_sndcb = NULL; + } +#endif + /* And free the connection structure */ conn->crefs = 0; udp_free(psock->s_conn); diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c index 761a65bb1ba82c2334829a8e9bfa24a15ebca2e9..d9c56ad76d86fedd9d0eaf9b94ab520f0db99f80 100644 --- a/net/inet/inet_sockif.c +++ b/net/inet/inet_sockif.c @@ -286,6 +286,10 @@ static sockcaps_t inet_sockcaps(FAR struct socket *psock) { #ifdef NET_TCP_HAVE_STACK case SOCK_STREAM: + /* REVISIT: Non-blocking recv() depends on CONFIG_NET_TCP_READAHEAD, + * but non-blocking send() depends on CONFIG_NET_TCP_WRITE_BUFFERS. + */ + #ifdef CONFIG_NET_TCP_READAHEAD return SOCKCAP_NONBLOCKING; #else @@ -295,6 +299,10 @@ static sockcaps_t inet_sockcaps(FAR struct socket *psock) #ifdef NET_UDP_HAVE_STACK case SOCK_DGRAM: + /* REVISIT: Non-blocking recvfrom() depends on CONFIG_NET_UDP_READAHEAD, + * but non-blocking sendto() depends on CONFIG_NET_UDP_WRITE_BUFFERS. + */ + #ifdef CONFIG_NET_UDP_READAHEAD return SOCKCAP_NONBLOCKING; #else @@ -1146,7 +1154,7 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf, #if defined(CONFIG_NET_6LOWPAN) /* Try 6LoWPAN UDP packet sendto() */ - nsent = psock_6lowpan_udp_sendto(psock, buf, len, flags, to, tolen); + nsent = psock_6lowpan_udp_sendto(psock, buf, len, flags, to, minlen); #ifdef NET_UDP_HAVE_STACK if (nsent < 0) diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c index b2fea28f4ac6303834e8ae956d7841b3ee43e632..4250692d893388ad82a8c28ac0932184ea5c8fac 100644 --- a/net/ipforward/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -187,7 +187,7 @@ static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) * but this is a point where support for other conversions may be * provided. * - * Returned value: + * Returned Value: * PACKET_FORWARDED - Packet was forwarded * PACKET_NOT_FORWARDED - Packet was not forwarded * < 0 - And error occurred (and packet not fowarded). diff --git a/net/local/local.h b/net/local/local.h index b4ccfd9a8a038a2d373eda987e6197d71acfda55..f49d399bf513a2b46f65530c649f353dadb6e1c5 100644 --- a/net/local/local.h +++ b/net/local/local.h @@ -375,7 +375,7 @@ int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr, * len Length of data to send * flags Send flags (ignored for now) * - * Return: + * Returned Value: * On success, returns the number of characters sent. On error, * -1 is returned, and errno is set appropriately (see send() for the * list of errno numbers). @@ -429,7 +429,7 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, * buf Data to send * len Length of data to send * - * Return: + * Returned Value: * Zero is returned on success; a negated errno value is returned on any * failure. * @@ -482,7 +482,7 @@ ssize_t local_recvfrom(FAR struct socket *psock, FAR void *buf, * len - Length of data to receive [in] * Length of data actually received [out] * - * Return: + * Returned Value: * Zero is returned on success; a negated errno value is returned on any * failure. If -ECONNRESET is received, then the sending side has closed * the FIFO. In this case, the returned data may still be valid (if the @@ -504,7 +504,7 @@ int local_fifo_read(FAR struct file *filep, FAR uint8_t *buf, size_t *len); * addrlen - The size of the memory allocat by the caller to receive the * address. * - * Return: + * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ @@ -521,7 +521,7 @@ int local_getaddr(FAR struct local_conn_s *conn, FAR struct sockaddr *addr, * Parameters: * filep - File structure of write-only FIFO. * - * Return: + * Returned Value: * The non-zero size of the following packet is returned on success; a * negated errno value is returned on any failure. * diff --git a/net/local/local_connect.c b/net/local/local_connect.c index 9a875b314b7e8425bdb6ff57bffe70a82186e039..28215e67f6c8855f7f537969830607d270477bbe 100644 --- a/net/local/local_connect.c +++ b/net/local/local_connect.c @@ -117,7 +117,7 @@ static inline void _local_semtake(sem_t *sem) * Find a local connection structure that is the appropriate "server" * connection to be used with the provided "client" connection. * - * Returned Values: + * Returned Value: * Zero (OK) returned on success; A negated errno value is returned on a * failure. Possible failures include: * @@ -250,7 +250,7 @@ errout_with_fifos: * Find a local connection structure that is the appropriate "server" * connection to be used with the provided "client" connection. * - * Returned Values: + * Returned Value: * Zero (OK) returned on success; A negated errno value is returned on a * failure. Possible failures include: * diff --git a/net/local/local_recvutils.c b/net/local/local_recvutils.c index 91e185754f410bae2971b96aa87a3eea515951af..798107e534f82cf536b6a03d5eebc269a19083d1 100644 --- a/net/local/local_recvutils.c +++ b/net/local/local_recvutils.c @@ -69,7 +69,7 @@ * len - Length of data to receive [in] * Length of data actually received [out] * - * Return: + * Returned Value: * Zero is returned on success; a negated errno value is returned on any * failure. If -ECONNRESET is received, then the sending side has closed * the FIFO. In this case, the returned data may still be valid (if the @@ -133,7 +133,7 @@ errout: * Parameters: * filep - File structure of write-only FIFO. * - * Return: + * Returned Value: * The non-zero size of the following packet is returned on success; a * negated errno value is returned on any failure. * @@ -201,7 +201,7 @@ int local_sync(FAR struct file *filep) * addrlen - The size of the memory allocated by the caller to receive the * address. * - * Return: + * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ diff --git a/net/local/local_send.c b/net/local/local_send.c index a305dac44116798e2d7ec316350d0187f42f32d5..6f170ba0a22e532c367e7fcc7a60fc7710cb340c 100644 --- a/net/local/local_send.c +++ b/net/local/local_send.c @@ -66,7 +66,7 @@ * len Length of data to send * flags Send flags (ignored for now) * - * Return: + * Returned Value: * On success, returns the number of characters sent. On error, * -1 is returned, and errno is set appropriately (see send() for the * list of errno numbers). diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c index fad305fd0b47b8d5a3bc00fcf9f7ed2d854cd307..8a4fcae61cd2bf5835efa9913f26b210ad90a853 100644 --- a/net/local/local_sendpacket.c +++ b/net/local/local_sendpacket.c @@ -83,7 +83,7 @@ static const uint8_t g_preamble[LOCAL_PREAMBLE_SIZE] = * buf Data to send * len Length of data to send * - * Return: + * Returned Value: * Zero is returned on success; a negated errno value is returned on any * failure. * @@ -133,7 +133,7 @@ static int local_fifo_write(FAR struct file *filep, FAR const uint8_t *buf, * buf Data to send * len Length of data to send * - * Return: + * Returned Value: * Zero is returned on success; a negated errno value is returned on any * failure. * diff --git a/net/local/local_sockif.c b/net/local/local_sockif.c index 60d0b6cb9b7be95365741bf3259329cfdac82e83..9413244bc5b6cee182a1658c07229757783c07bc 100644 --- a/net/local/local_sockif.c +++ b/net/local/local_sockif.c @@ -530,7 +530,7 @@ static int local_connect(FAR struct socket *psock, } /**************************************************************************** - * Name: pkt_accept + * Name: local_accept * * Description: * The pkt_accept function is used with connection-based socket types @@ -799,17 +799,4 @@ static int local_close(FAR struct socket *psock) * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: - * - * Description: - * - * Parameters: - * - * Returned Value: - * - * Assumptions: - * - ****************************************************************************/ - #endif /* CONFIG_NET_LOCAL */ diff --git a/net/net_initialize.c b/net/net_initialize.c index 4d0105acf7f4e6991c1e68b60591ca6390b18e2c..0447f88dfcfb8ac16ffe37921f560547e350db47 100644 --- a/net/net_initialize.c +++ b/net/net_initialize.c @@ -172,6 +172,10 @@ void net_setup(void) /* Initialize the UDP connection structures */ udp_initialize(); + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS + udp_wrbuffer_initialize(); +#endif #endif #ifdef CONFIG_NET_IGMP diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c index e4b1e13a46314a7e6ad2aa54c54164011a6d036a..9fdb2f1e8c6aedcf13929abb34075143fe99a55f 100644 --- a/net/netdev/netdev_ioctl.c +++ b/net/netdev/netdev_ioctl.c @@ -382,7 +382,7 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr, * cmd The ioctl command * req The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -444,7 +444,7 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd, * cmd The ioctl command * req The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -507,7 +507,7 @@ static int netdev_pktradio_ioctl(FAR struct socket *psock, int cmd, * cmd The ioctl command * req The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -548,7 +548,7 @@ static int netdev_wifr_ioctl(FAR struct socket *psock, int cmd, * Parameters: * req - The argument of the ioctl cmd * - * Return: + * Returned Value: * A pointer to the driver structure on success; NULL on failure. * ****************************************************************************/ @@ -578,7 +578,7 @@ static FAR struct net_driver_s *netdev_ifr_dev(FAR struct ifreq *req) * cmd The ioctl command * req The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -1030,7 +1030,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd, * Parameters: * req - The argument of the ioctl cmd * - * Return: + * Returned Value: * A pointer to the driver structure on success; NULL on failure. * ****************************************************************************/ @@ -1063,7 +1063,7 @@ static FAR struct net_driver_s *netdev_imsfdev(FAR struct ip_msfilter *imsf) * cmd The ioctl command * imsf The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -1122,7 +1122,7 @@ static int netdev_imsf_ioctl(FAR struct socket *psock, int cmd, * cmd The ioctl command * req The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -1245,7 +1245,7 @@ static int netdev_arp_ioctl(FAR struct socket *psock, int cmd, * cmd The ioctl command * rtentry The argument of the ioctl cmd * - * Return: + * Returned Value: * >=0 on success (positive non-zero values are cmd-specific) * Negated errno returned on failure. * @@ -1359,7 +1359,7 @@ static int netdev_rt_ioctl(FAR struct socket *psock, int cmd, * cmd The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * A non-negative value is returned on success; a negated errno value is * returned on any failure to indicate the nature of the failure: * @@ -1469,7 +1469,7 @@ int psock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg) * cmd The ioctl command * arg The argument of the ioctl cmd * - * Return: + * Returned Value: * A non-negative value is returned on success; a negated errno value is * returned on any failure to indicate the nature of the failure: * diff --git a/net/pkt/pkt.h b/net/pkt/pkt.h index 2351e911922545b24538312c9096b640c8601f5d..f4bcfca1e6170494122cd628f857e932dc8723f9 100644 --- a/net/pkt/pkt.h +++ b/net/pkt/pkt.h @@ -193,7 +193,7 @@ uint16_t pkt_callback(FAR struct net_driver_s *dev, * Parameters: * dev - The device driver structure containing the received packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR There is a matching connection, but could not dispatch the packet * yet. Useful when a packet arrives before a recv call is in @@ -267,7 +267,7 @@ FAR struct net_driver_s *pkt_find_device(FAR struct pkt_conn_s *conn); * dev - The device driver structure to use in the send operation * conn - The packet "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/pkt/pkt_input.c b/net/pkt/pkt_input.c index e4ba86c2d140d11f32df5af05dac12adea67d456..4676426f12e9a57e140b353b6279a53eecc704e1 100644 --- a/net/pkt/pkt_input.c +++ b/net/pkt/pkt_input.c @@ -73,7 +73,7 @@ * Parameters: * dev - The device driver structure containing the received packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR There is a matching connection, but could not dispatch the packet * yet. Useful when a packet arrives before a recv call is in diff --git a/net/pkt/pkt_poll.c b/net/pkt/pkt_poll.c index 272de209f3660405f6f0ae44a7102e0debd22d79..7fdb76d036c69622e02d1dfe0359783aa470b82f 100644 --- a/net/pkt/pkt_poll.c +++ b/net/pkt/pkt_poll.c @@ -68,7 +68,7 @@ * dev - The device driver structure to use in the send operation * conn - The packet "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/pkt/pkt_recvfrom.c b/net/pkt/pkt_recvfrom.c index ae801d07bb559cd9c175a730dcd20bb5fa0245cd..137fd5f647763e2517b8bc432e8158c185acc7d7 100644 --- a/net/pkt/pkt_recvfrom.c +++ b/net/pkt/pkt_recvfrom.c @@ -159,7 +159,7 @@ static void pkt_recvfrom_newdata(FAR struct net_driver_s *dev, * * Parameters: * - * Returned Values: + * Returned Value: * * Assumptions: * @@ -177,7 +177,7 @@ static inline void pkt_recvfrom_sender(FAR struct net_driver_s *dev, * * Parameters: * - * Returned Values: + * Returned Value: * * Assumptions: * diff --git a/net/route/net_fileroute.c b/net/route/net_fileroute.c index 32074efd85b93f92b4be8b56d0f8380c62d27a7a..8cbdd517ced9ed318c235c7d9f49dc582d5d3bf9 100644 --- a/net/route/net_fileroute.c +++ b/net/route/net_fileroute.c @@ -170,7 +170,7 @@ int net_routesize(FAR const char *path, size_t entrysize) * created yet? */ - errcode = errno; + errcode = get_errno(); if (errcode == ENOENT) { /* The routing table file has not been created. Return size zero. */ diff --git a/net/sixlowpan/sixlowpan.h b/net/sixlowpan/sixlowpan.h index 4d0ba44685ad7f7332aefe56b728adfd39378e9a..7760e47e58f715e291059808a4a2cecbb6586c89 100644 --- a/net/sixlowpan/sixlowpan.h +++ b/net/sixlowpan/sixlowpan.h @@ -86,7 +86,7 @@ void sixlowpan_initialize(void); * psock_6lowpan_tcp_send() call may be used only when the TCP socket is in a * connected state (so that the intended recipient is known). * - * Input Parmeters + * Input Parameters: * psock - An instance of the internal socket structure. * buf - Data to send * len - Length of data to send @@ -126,7 +126,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf, * driver. Under those conditions, this function will be called to create * the IEEE80215.4 frames. * - * Input Parmeters + * Input Parameters: * dev - The network device containing the packet to be sent. * fwddev - The network device used to send the data. This will be the * same device except for the IP forwarding case where packets @@ -159,7 +159,7 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev, * * Both cases are handled here. * - * Input Parmeters + * Input Parameters: * dev - The network device containing the packet to be sent. * fwddev - The network device used to send the data. This will be the * same device except for the IP forwarding case where packets @@ -189,7 +189,7 @@ void sixlowpan_icmpv6_send(FAR struct net_driver_s *dev, * psock_6lowpan_udp_send() call may be used with connectionlesss UDP * sockets. * - * Input Parmeters + * Input Parameters: * psock - An instance of the internal socket structure. * buf - Data to send * len - Length of data to send @@ -219,7 +219,7 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf, * may be returned when they are not NULL and 0), and the error ENOTCONN is * returned when the socket was not actually connected. * - * Input Parmeters + * Input Parameters: * psock A pointer to a NuttX-specific, internal socket structure * buf Data to send * len Length of data to send @@ -251,7 +251,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock, * Handles forwarding a UDP packet via 6LoWPAN. This is currently only * used by the IPv6 forwarding logic. * - * Input Parmeters + * Input Parameters: * dev - An instance of nework device state structure * fwddev - The network device used to send the data. This will be the * same device except for the IP forwarding case where packets diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index 545bea004a44eac2afe50e7902c21e0ae256f621..d69e007a1f5ce3be2c3863c04458b5a65c03cc98 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -199,7 +199,7 @@ static uint16_t sixlowpan_protosize(FAR const struct ipv6_hdr_s *ipv6hdr, * destmac - The IEEE802.15.4 MAC address of the destination * meta - Location to return the final metadata. * - * Returned value + * Returned Value: * OK is returned on success; Othewise a negated errno value is returned. * ****************************************************************************/ @@ -298,7 +298,7 @@ static int sixlowpan_ieee802154_metadata(FAR struct radio_driver_s *radio, * destmac - The radio-specific MAC address of the destination * meta - Location to return the final metadata. * - * Returned value + * Returned Value: * OK is returned on success; Othewise a negated errno value is returned. * ****************************************************************************/ diff --git a/net/sixlowpan/sixlowpan_framer.c b/net/sixlowpan/sixlowpan_framer.c index 666c6a3adf19209c679659033898bcfff0882b6a..023d59f83fc108e6fcb67b41de4dab15b674fa12 100644 --- a/net/sixlowpan/sixlowpan_framer.c +++ b/net/sixlowpan/sixlowpan_framer.c @@ -64,7 +64,7 @@ * If the destination address is all zero in the MAC header buf, then it is * broadcast on the 802.15.4 network. * - * Input parameters: + * Input Parameters: * addr - The address to check * addrlen - The length of the address in bytes * @@ -93,7 +93,7 @@ static bool sixlowpan_anyaddrnull(FAR const uint8_t *addr, uint8_t addrlen) * If the destination address is all zero in the MAC header buf, then it is * broadcast on the 802.15.4 network. * - * Input parameters: + * Input Parameters: * eaddr - The short address to check * * Returned Value: @@ -113,7 +113,7 @@ static inline bool sixlowpan_saddrnull(FAR const uint8_t *saddr) * If the destination address is all zero in the MAC header buf, then it is * broadcast on the 802.15.4 network. * - * Input parameters: + * Input Parameters: * eaddr - The extended address to check * * Returned Value: @@ -247,7 +247,7 @@ int sixlowpan_meta_data(FAR struct radio_driver_s *radio, * determine what the size of the IEEE802.15.4 header will be. No frame * buffer is required to make this determination. * - * Input parameters: + * Input Parameters: * radio - A reference IEEE802.15.4 MAC network device structure. * meta - Meta data that describes the MAC header * @@ -272,7 +272,7 @@ int sixlowpan_frame_hdrlen(FAR struct radio_driver_s *radio, * new incoming frame and the network responds with an outgoing packet. It * submits any new outgoing frame to the MAC. * - * Input parameters: + * Input Parameters: * radio - A reference to a radio network device instance. * meta - Meta data that describes the MAC header * frame - The IOB containing the frame to be submitted. diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index c9e05410e1cd502d42d770b4f3b55de78ba9a135..204cf69cbcdc312da874a11ef66ed66c0f4a07da 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -1078,7 +1078,7 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio, * decompression, g_frame_hdrlen and g_uncompressed_hdrlen are set to the * appropriate values * - * Input Parmeters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * metadata - Obfuscated MAC metadata including node addressing * information. diff --git a/net/sixlowpan/sixlowpan_hc1.c b/net/sixlowpan/sixlowpan_hc1.c index 977c268caba0442293e80165aaafeb22bebf5232..ffbc479edfbd5d3517ade57c5b97a02186002d37 100644 --- a/net/sixlowpan/sixlowpan_hc1.c +++ b/net/sixlowpan/sixlowpan_hc1.c @@ -108,7 +108,7 @@ * | src p.| dst p.| UDP checksum | L4 data... * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * - * Input Parmeters: + * Input Parameters: * radio - A reference to a radio network device instance * ipv6 - The IPv6 header followd by TCP, UDP, or ICMPv6 header to be * compressed diff --git a/net/sixlowpan/sixlowpan_icmpv6send.c b/net/sixlowpan/sixlowpan_icmpv6send.c index e62c617ed1ea27ba3c1fe133217ddc2b95ab3943..a4ef1dc79a0591c11f9c0db06dcca3211f127ed9 100644 --- a/net/sixlowpan/sixlowpan_icmpv6send.c +++ b/net/sixlowpan/sixlowpan_icmpv6send.c @@ -63,7 +63,7 @@ * Handles forwarding a ICMPv6 packet via 6LoWPAN. This is currently only * used by the IPv6 forwarding logic. * - * Input Parmeters + * Input Parameters: * dev - An instance of nework device state structure * fwddev - The network device used to send the data. This will be the * same device except for the IP forwarding case where packets diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c index e64becd9c1b355e3bc7408a5993ece845799f50c..50a757a60489cd774de362a7b5cb932597ac51f7 100644 --- a/net/sixlowpan/sixlowpan_input.c +++ b/net/sixlowpan/sixlowpan_input.c @@ -597,7 +597,7 @@ errout_with_reass: * Description: * Inject the packet in d_buf into the network for normal packet processing. * - * Input Parmeters + * Input Parameters: * radio - The IEEE802.15.4 MAC network driver interface. * * Returned Value: diff --git a/net/sixlowpan/sixlowpan_internal.h b/net/sixlowpan/sixlowpan_internal.h index 7e527dae0df054269703e336a12a5941998a2609..e07e40154900f3d65a83b2a570131c338eadb609 100644 --- a/net/sixlowpan/sixlowpan_internal.h +++ b/net/sixlowpan/sixlowpan_internal.h @@ -319,7 +319,7 @@ int sixlowpan_meta_data(FAR struct radio_driver_s *radio, * determine what the size of the IEEE802.15.4 header will be. No frame * buffer is required to make this determination. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * meta - obfuscated meta data that describes the MAC header * @@ -341,7 +341,7 @@ int sixlowpan_frame_hdrlen(FAR struct radio_driver_s *radio, * new incoming frame and the network responds with an outgoing packet. It * submits any new outgoing frame to the MAC. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * meta - Obfuscated metadata that describes the MAC header * frame - The IOB containing the frame to be submitted. @@ -471,7 +471,7 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio, * decompression, g_frame_hdrlen and g_uncompressed_hdrlen are set to the * appropriate values * - * Input Parmeters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * metadata - Obfuscated MAC metadata including node addressing * information. @@ -506,7 +506,7 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio, * 6lowpan packet in the packetbuf buffer from a full IPv6 packet in the * uip_buf buffer. * - * Input Parmeters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * ipv6 - The IPv6 header to be compressed * destmac - L2 destination address, needed to compress the IP @@ -629,7 +629,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr, * Description: * Get the maximum frame length supported by radio network drvier. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * * Returned Value: @@ -646,7 +646,7 @@ int sixlowpan_radio_framelen(FAR struct radio_driver_s *radio); * Description: * Get the source PAN ID from the IEEE802.15.4 radio. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * panid - The location in which to return the PAN ID. 0xfff may be * returned if the device is not associated. @@ -668,7 +668,7 @@ int sixlowpan_src_panid(FAR struct radio_driver_s *radio, * Extract the source MAC address from the radio-specific RX metadata, and * return the source address in a radio-agnostic form. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * metadata - Opaque reference to the radio-specific RX metadata. * srcaddr - The location in which to return the source MAC address. @@ -689,7 +689,7 @@ int sixlowpan_extract_srcaddr(FAR struct radio_driver_s *radio, * Extract the destination MAC address from the radio-specific RX metadata, * and return the destination address in a radio-agnostic form. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * metadata - Opaque reference to the radio-specific RX metadata. * destaddr - The location in which to return the destination MAC address. @@ -713,10 +713,10 @@ int sixlowpan_extract_destaddr(FAR struct radio_driver_s *radio, * * Called only once during network initialization. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -734,11 +734,11 @@ void sixlowpan_reass_initialize(void); * list. If that the list is empty, then the reassembly buffer structure * will be allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * reasstag - The reassembly tag for subsequent lookup. * fragsrc - The source address of the fragment. * - * Return Value: + * Returned Value: * A reference to the allocated reass structure. All fields used by the * reasembly logic have been zeroed. On a failure to allocate, NULL is * returned. @@ -759,11 +759,11 @@ FAR struct sixlowpan_reassbuf_s * * Find a previously allocated, active reassembly buffer with the specified * reassembly tag. * - * Inputs: + * Input Parameters: * reasstag - The reassembly tag to match. * fragsrc - The source address of the fragment. * - * Return Value: + * Returned Value: * A reference to the matching reass structure. * * Assumptions: @@ -784,10 +784,10 @@ FAR struct sixlowpan_reassbuf_s * * structure. If the reass structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * reass - reass structure to free * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/net/sixlowpan/sixlowpan_reassbuf.c b/net/sixlowpan/sixlowpan_reassbuf.c index c3ae7eeb8044152b84f3abf30a6bf1037a1f0a71..13b57fa0b9ec06a0c0886a3148f807d0abb706f4 100644 --- a/net/sixlowpan/sixlowpan_reassbuf.c +++ b/net/sixlowpan/sixlowpan_reassbuf.c @@ -121,10 +121,10 @@ static bool sixlowpan_compare_fragsrc(FAR struct sixlowpan_reassbuf_s *reass, * Description: * Free all expired or inactive reassembly buffers. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -177,10 +177,10 @@ static void sixlowpan_reass_expire(void) * Description: * Remove a reassembly buffer from the active reassembly buffer list. * - * Inputs: + * Input Parameters: * reass - The reassembly buffer to be removed. * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -234,10 +234,10 @@ static void sixlowpan_remove_active(FAR struct sixlowpan_reassbuf_s *reass) * * Called only once during network initialization. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -276,11 +276,11 @@ void sixlowpan_reass_initialize(void) * list. If that the list is empty, then the reassembly buffer structure * will be allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * reasstag - The reassembly tag for subsequent lookup. * fragsrc - The source address of the fragment. * - * Return Value: + * Returned Value: * A reference to the allocated reass structure. All fields used by the * reasembly logic have been zeroed. On a failure to allocate, NULL is * returned. @@ -355,11 +355,11 @@ FAR struct sixlowpan_reassbuf_s * * Find a previously allocated, active reassembly buffer with the specified * reassembly tag. * - * Inputs: + * Input Parameters: * reasstag - The reassembly tag to match. * fragsrc - The source address of the fragment. * - * Return Value: + * Returned Value: * A reference to the matching reass structure. * * Assumptions: @@ -411,10 +411,10 @@ FAR struct sixlowpan_reassbuf_s * * structure. If the reass structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * reass - reass structure to free * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/net/sixlowpan/sixlowpan_send.c b/net/sixlowpan/sixlowpan_send.c index b8fceb8958d66f52c47925586ad6e83e81223572..3deb9d5b1cd9e3b05b1d3073f0e8776352c1aff0 100644 --- a/net/sixlowpan/sixlowpan_send.c +++ b/net/sixlowpan/sixlowpan_send.c @@ -141,7 +141,7 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo) * This function is called from the interrupt level to perform the actual * send operation when polled by the lower, device interfacing layer. * - * Input Parmeters + * Input Parameters: * dev - The structure of the network driver that caused the interrupt * conn - The connection structure associated with the socket * flags - Set of events describing why the callback was invoked diff --git a/net/sixlowpan/sixlowpan_tcpsend.c b/net/sixlowpan/sixlowpan_tcpsend.c index df7eab7971c16b08170db0ed016dc1b466eccf04..bc2085c498eeac1731549602913bd81a69b9d8cd 100644 --- a/net/sixlowpan/sixlowpan_tcpsend.c +++ b/net/sixlowpan/sixlowpan_tcpsend.c @@ -178,7 +178,7 @@ static uint16_t sixlowpan_tcp_chksum(FAR const struct ipv6tcp_hdr_s *ipv6tcp, * Description: * sixlowpan_tcp_header() will construct the IPv6 and TCP headers * - * Input Parmeters + * Input Parameters: * conn - An instance of the TCP connection structure. * dev - The network device that will route the packet * buf - Data to send @@ -328,7 +328,7 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo) * This function is called from the interrupt level to perform the actual * TCP send operation when polled by the lower, device interfacing layer. * - * Input Parmeters + * Input Parameters: * dev - The structure of the network driver that caused the interrupt * pvconn - The connection structure associated with the socket * pvpriv - The interrupt handler's private data argument @@ -745,7 +745,7 @@ static int sixlowpan_send_packet(FAR struct socket *psock, * psock_6lowpan_tcp_send() call may be used only when the TCP socket is in a * connected state (so that the intended recipient is known). * - * Input Parmeters + * Input Parameters: * psock - An instance of the internal socket structure. * buf - Data to send * bulen - Length of data to send @@ -898,7 +898,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf, * driver. Under those conditions, this function will be called to create * the IEEE80215.4 frames. * - * Input Parmeters + * Input Parameters: * dev - The network device containing the packet to be sent. * fwddev - The network device used to send the data. This will be the * same device except for the IP forwarding case where packets diff --git a/net/sixlowpan/sixlowpan_udpsend.c b/net/sixlowpan/sixlowpan_udpsend.c index e2f115eb09064843baf85fdbf38d02d5b41f65b4..6f99f31b7c696ad24a1b338eb2e9a4ccd584c8ff 100644 --- a/net/sixlowpan/sixlowpan_udpsend.c +++ b/net/sixlowpan/sixlowpan_udpsend.c @@ -136,7 +136,7 @@ static uint16_t sixlowpan_udp_chksum(FAR const struct ipv6udp_hdr_s *ipv6udp, * may be returned when they are not NULL and 0), and the error ENOTCONN is * returned when the socket was not actually connected. * - * Input Parmeters + * Input Parameters: * psock A pointer to a NuttX-specific, internal socket structure * buf Data to send * buflen Length of data to send @@ -337,7 +337,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock, * psock_6lowpan_udp_send() call may be used with connectionlesss UDP * sockets. * - * Input Parmeters + * Input Parameters: * psock - An instance of the internal socket structure. * buf - Data to send * buflen - Length of data to send @@ -413,7 +413,7 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf, * Handles forwarding a UDP packet via 6LoWPAN. This is currently only * used by the IPv6 forwarding logic. * - * Input Parmeters + * Input Parameters: * dev - An instance of nework device state structure * fwddev - The network device used to send the data. This will be the * same device except for the IP forwarding case where packets diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index 696503b5a9398d168ff30c68fefe6de9011df66b..644ad1484e136ae1e0badc406047204435983e80 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -573,7 +573,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr, * Description: * Get the maximum frame length supported by radio network drvier. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * * Returned Value: @@ -607,7 +607,7 @@ int sixlowpan_radio_framelen(FAR struct radio_driver_s *radio) * Description: * Get the source PAN ID from the IEEE802.15.4 MAC layer. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * panid - The location in which to return the PAN ID. 0xfff may be * returned if the device is not associated. @@ -647,7 +647,7 @@ int sixlowpan_src_panid(FAR struct radio_driver_s *radio, * Extract the source MAC address from the radio-specific RX metadata, and * return the source address in a radio-agnostic form. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * metadata - Opaque reference to the radio-specific RX metadata. * srcaddr - The location in which to return the source MAC address. @@ -714,7 +714,7 @@ int sixlowpan_extract_srcaddr(FAR struct radio_driver_s *radio, * Extract the destination MAC address from the radio-specific RX metadata, * and return the destination address in a radio-agnostic form. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * metadata - Opaque reference to the radio-specific RX metadata. * destaddr - The location in which to return the destination MAC address. diff --git a/net/socket/socket.c b/net/socket/socket.c index 539ef0b2160f4166dd747772da1f866505b81589..caaed28320b8d13a6d43cc811ad0c2cd14c82b36 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -105,7 +105,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) psock->s_domain = domain; psock->s_type = type; psock->s_conn = NULL; -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS +#if defined(CONFIG_NET_TCP_WRITE_BUFFERS) || defined(CONFIG_NET_UDP_WRITE_BUFFERS) psock->s_sndcb = NULL; #endif diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig index 77cebe81fbedc6e373a1578b58c12bf5460f83ff..c3647ae2898824ff4c92f42e4edf26d4a44b4b0f 100644 --- a/net/tcp/Kconfig +++ b/net/tcp/Kconfig @@ -70,6 +70,7 @@ config NET_MAX_LISTENPORTS config NET_TCP_READAHEAD bool "Enable TCP/IP read-ahead buffering" default y + select NET_READAHEAD select MM_IOB ---help--- Read-ahead buffers allows buffering of TCP/IP packets when there is no @@ -91,6 +92,7 @@ endif # NET_TCP_READAHEAD config NET_TCP_WRITE_BUFFERS bool "Enable TCP/IP write buffering" default n + select NET_WRITE_BUFFERS select MM_IOB ---help--- Write buffers allows buffering of ongoing TCP/IP packets, providing @@ -105,7 +107,7 @@ config NET_TCP_NWRBCHAINS int "Number of pre-allocated I/O buffer chain heads" default 8 ---help--- - These tiny nodes are used as "containers" to support queueing of + These tiny nodes are used as "containers" to support queuing of TCP write buffers. This setting will limit the number of TCP write operations that can be "in-flight" at any give time. So a good choice for this value would be the same as the maximum number of diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 91e13ffe7ba7a24ec1e90b7b4b5f5f6f3896e735..13ab0d803d8a2c70def5cc65c52fde573919f917 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -1,7 +1,7 @@ /**************************************************************************** * net/tcp/tcp.h * - * Copyright (C) 2014-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -77,23 +77,26 @@ #ifdef CONFIG_NET_TCP_WRITE_BUFFERS /* TCP write buffer access macros */ -# define WRB_SEQNO(wrb) ((wrb)->wb_seqno) -# define WRB_PKTLEN(wrb) ((wrb)->wb_iob->io_pktlen) -# define WRB_SENT(wrb) ((wrb)->wb_sent) -# define WRB_NRTX(wrb) ((wrb)->wb_nrtx) -# define WRB_IOB(wrb) ((wrb)->wb_iob) -# define WRB_COPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0)) -# define WRB_COPYIN(wrb,src,n) (iob_copyin((wrb)->wb_iob,src,(n),0,false)) +# define TCP_WBSEQNO(wrb) ((wrb)->wb_seqno) +# define TCP_WBPKTLEN(wrb) ((wrb)->wb_iob->io_pktlen) +# define TCP_WBSENT(wrb) ((wrb)->wb_sent) +# define TCP_WBNRTX(wrb) ((wrb)->wb_nrtx) +# define TCP_WBIOB(wrb) ((wrb)->wb_iob) +# define TCP_WBCOPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0)) +# define TCP_WBCOPYIN(wrb,src,n) \ + (iob_copyin((wrb)->wb_iob,src,(n),0,false)) +# define TCP_WBTRYCOPYIN(wrb,src,n) \ + (iob_trycopyin((wrb)->wb_iob,src,(n),0,false)) -# define WRB_TRIM(wrb,n) \ - do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0) +# define TCP_WBTRIM(wrb,n) \ + do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0) #ifdef CONFIG_DEBUG_FEATURES -# define WRB_DUMP(msg,wrb,len,offset) \ +# define TCP_WBDUMP(msg,wrb,len,offset) \ tcp_wrbuffer_dump(msg,wrb,len,offset) -#else -# define WRB_DUMP(msg,wrb,len,offset) -#endif +# else +# define TCP_WBDUMP(msg,wrb,len,offset) +# endif #endif /**************************************************************************** @@ -438,7 +441,7 @@ int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn); * * Description: * Select the network driver to use with the IPv6 TCP transaction based - * on the remotely conected IPv6 address + * on the remotely connected IPv6 address * * Input Parameters: * conn - TCP connection structure. The remotely connected address, raddr, @@ -477,7 +480,7 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev, * This function implements the lower level parts of the standard TCP * bind() operation. * - * Return: + * Returned Value: * 0 on success or -EADDRINUSE on failure * * Assumptions: @@ -558,7 +561,7 @@ int tcp_start_monitor(FAR struct socket *psock); * * Description: * Stop monitoring TCP connection changes for a sockets associated with - * a given TCP connection stucture. + * a given TCP connection structure. * * Input Parameters: * conn - The TCP connection of interest @@ -724,7 +727,7 @@ void tcp_nextsequence(void); * dev - The device driver structure to use in the send operation * conn - The TCP "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: @@ -745,7 +748,7 @@ void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn); * conn - The TCP "connection" to poll for TX data * hsec - The polling interval in halves of a second * - * Return: + * Returned Value: * None * * Assumptions: @@ -856,7 +859,7 @@ int tcp_accept_connection(FAR struct net_driver_s *dev, * flags - flags to apply to the TCP header * len - length of the message * - * Return: + * Returned Value: * None * * Assumptions: @@ -901,7 +904,7 @@ ssize_t tcp_sendfile(FAR struct socket *psock, FAR struct file *infile, * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: @@ -922,7 +925,7 @@ void tcp_reset(FAR struct net_driver_s *dev); * conn - The TCP connection structure holding connection information * ack - The ACK response to send * - * Return: + * Returned Value: * None * * Assumptions: @@ -946,7 +949,7 @@ void tcp_ack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * conn - The TCP connection structure holding connection information * result - App result event sent * - * Return: + * Returned Value: * None * * Assumptions: @@ -968,7 +971,7 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * conn - The TCP connection structure holding connection information * result - App result event sent * - * Return: + * Returned Value: * None * * Assumptions: @@ -988,7 +991,7 @@ void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * Parameters: * dev - The device driver structure containing the received TCP packet. * - * Return: + * Returned Value: * None * * Assumptions: @@ -1009,7 +1012,7 @@ void tcp_ipv4_input(FAR struct net_driver_s *dev); * Parameters: * dev - The device driver structure containing the received TCP packet. * - * Return: + * Returned Value: * None * * Assumptions: @@ -1050,7 +1053,7 @@ uint16_t tcp_callback(FAR struct net_driver_s *dev, * buffers * buflen - The number of bytes to copy to the read-ahead buffer. * - * Returned value: + * Returned Value: * The number of bytes actually buffered is returned. This will be either * zero or equal to buflen; partial packets are not buffered. * @@ -1282,7 +1285,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, * * Returned Value: * OK - * At least one byte of data could be succesfully written. + * At least one byte of data could be successfully written. * -EWOULDBLOCK * There is no room in the output buffer. * -EBADF @@ -1317,7 +1320,7 @@ void tcp_wrbuffer_initialize(void); * the free list. This function is called from TCP logic when a buffer * of TCP data is about to sent * - * Input parameters: + * Input Parameters: * None * * Assumptions: diff --git a/net/tcp/tcp_appsend.c b/net/tcp/tcp_appsend.c index 7ee1f06779a980dc054717767ffbbfea430c4d7d..b87c679b6e6e94a4564c75939f24ec465abc71b5 100644 --- a/net/tcp/tcp_appsend.c +++ b/net/tcp/tcp_appsend.c @@ -72,7 +72,7 @@ * conn - The TCP connection structure holding connection information * result - App result event sent * - * Return: + * Returned Value: * None * * Assumptions: @@ -197,7 +197,7 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * conn - The TCP connection structure holding connection information * result - App result event sent * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/tcp/tcp_callback.c b/net/tcp/tcp_callback.c index dcc16927b9d20f9bc80ad9c782b0edb542d1528c..a43af2fb90165e8713f98f38e2d9b2a8d3795a53 100644 --- a/net/tcp/tcp_callback.c +++ b/net/tcp/tcp_callback.c @@ -218,7 +218,7 @@ uint16_t tcp_callback(FAR struct net_driver_s *dev, * buffers * buflen - The number of bytes to copy to the read-ahead buffer. * - * Returned value: + * Returned Value: * The number of bytes actually buffered is returned. This will be either * zero or equal to buflen; partial packets are not buffered. * diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index 43282501ea2f8a63ffd4036ccaddd161d31ff4f2..0c125d47178e66db3bdc2c94be1abbcc5df176a2 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -243,7 +243,7 @@ static FAR struct tcp_conn_s * * portno -- the selected port number in host order. Zero means no port * selected. * - * Return: + * Returned Value: * Selected or verified port number in host order on success, a negated * errno on failure: * @@ -445,7 +445,7 @@ static inline FAR struct tcp_conn_s * * This function implements the lower level parts of the standard TCP * bind() operation. * - * Return: + * Returned Value: * 0 on success or -EADDRINUSE on failure * * Assumptions: @@ -510,7 +510,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, * This function implements the lower level parts of the standard TCP * bind() operation. * - * Return: + * Returned Value: * 0 on success or -EADDRINUSE on failure * * Assumptions: @@ -1039,7 +1039,7 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev, * This function implements the lower level parts of the standard TCP * bind() operation. * - * Return: + * Returned Value: * 0 on success or -EADDRINUSE on failure * * Assumptions: diff --git a/net/tcp/tcp_devpoll.c b/net/tcp/tcp_devpoll.c index ee00d7f7d13807a28707c9e095ad3c9ce196f3d9..8097f442f4014956509279da448d533a0b54c5e6 100644 --- a/net/tcp/tcp_devpoll.c +++ b/net/tcp/tcp_devpoll.c @@ -70,7 +70,7 @@ * dev - The device driver structure to use in the send operation * conn - The TCP "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index b78a819fc03142277849c8495ed52dd38f9367ad..015374aa2c715a2b98ea06d9eb35c8c6ef84bc36 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -76,7 +76,7 @@ * domain - IP domain (PF_INET or PF_INET6) * iplen - Lngth of the IP header (IPv4_HDRLEN or IPv6_HDRLEN). * - * Return: + * Returned Value: * None * * Assumptions: @@ -947,7 +947,7 @@ drop: * Parameters: * dev - The device driver structure containing the received TCP packet. * - * Return: + * Returned Value: * None * * Assumptions: @@ -977,7 +977,7 @@ void tcp_ipv4_input(FAR struct net_driver_s *dev) * Parameters: * dev - The device driver structure containing the received TCP packet. * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/tcp/tcp_netpoll.c b/net/tcp/tcp_netpoll.c index 615fb84b565eac9b117c27da346b6e1b7c87007d..3979cf7c8ddc94c3004e2cd98ce4e9d4e7356dba 100644 --- a/net/tcp/tcp_netpoll.c +++ b/net/tcp/tcp_netpoll.c @@ -112,7 +112,11 @@ static uint16_t tcp_poll_eventhandler(FAR struct net_driver_s *dev, eventset |= POLLIN & info->fds->events; } - /* A poll is a sign that we are free to send data. */ + /* A poll is a sign that we are free to send data. + * REVISIT: This is bogus: If CONFIG_TCP_WRITE_BUFFERS=y then + * we never have to wait to send; otherwise, we always have to + * wait to send. Receiving a poll is irrelevant. + */ if ((flags & TCP_POLL) != 0) { diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c index b4e833aa9b023dc4e432079d3d6375d44fd902bb..def99b137fb0954c5c506956d2ae78d64e129062 100644 --- a/net/tcp/tcp_send.c +++ b/net/tcp/tcp_send.c @@ -86,7 +86,7 @@ * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * The length of the IP header (IPv4_HDRLEN or IPv6_HDRLEN) * ****************************************************************************/ @@ -122,7 +122,7 @@ static inline FAR struct tcp_hdr_s *tcp_header(FAR struct net_driver_s *dev) * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: @@ -190,7 +190,7 @@ static inline void tcp_ipv4_sendcomplete(FAR struct net_driver_s *dev, * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: @@ -253,7 +253,7 @@ static inline void tcp_ipv6_sendcomplete(FAR struct net_driver_s *dev, * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: @@ -301,7 +301,7 @@ static void tcp_sendcomplete(FAR struct net_driver_s *dev, * dev - The device driver structure to use in the send operation * conn - The TCP connection structure holding connection information * - * Return: + * Returned Value: * None * * Assumptions: @@ -403,7 +403,7 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev, * len - length of the message (includes the length of the IP and TCP * headers) * - * Return: + * Returned Value: * None * * Assumptions: @@ -431,7 +431,7 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * Parameters: * dev - The device driver structure to use in the send operation * - * Return: + * Returned Value: * None * * Assumptions: @@ -548,7 +548,7 @@ void tcp_reset(FAR struct net_driver_s *dev) * conn - The TCP connection structure holding connection information * ack - The ACK response to send * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index df54f338c3750915f461056d2adc8cd8a24ff455..bfb9bd2baf29c05bf7cd1925be4e593d7f9f92f9 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/tcp/tcp_send_buffered.c * - * Copyright (C) 2007-2014, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2014, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Jason Jiang * @@ -98,8 +98,8 @@ # define BUF_DUMP(msg,buf,len) lib_dumpbuffer(msg,buf,len) #else # define BUF_DUMP(msg,buf,len) -# undef WRB_DUMP -# define WRB_DUMP(msg,wrb,len,offset) +# undef TCP_WBDUMP +# define TCP_WBDUMP(msg,wrb,len,offset) #endif /**************************************************************************** @@ -135,7 +135,7 @@ static void psock_insert_segment(FAR struct tcp_wrbuffer_s *wrb, for (itr = sq_peek(q); itr; itr = sq_next(itr)) { FAR struct tcp_wrbuffer_s *wrb0 = (FAR struct tcp_wrbuffer_s *)itr; - if (WRB_SEQNO(wrb0) < WRB_SEQNO(wrb)) + if (TCP_WBSEQNO(wrb0) < TCP_WBSEQNO(wrb)) { insert = itr; } @@ -417,13 +417,14 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, * the write buffer has been ACKed. */ - if (ackno > WRB_SEQNO(wrb)) + if (ackno > TCP_WBSEQNO(wrb)) { /* Get the sequence number at the end of the data */ - lastseq = WRB_SEQNO(wrb) + WRB_PKTLEN(wrb); + lastseq = TCP_WBSEQNO(wrb) + TCP_WBPKTLEN(wrb); ninfo("ACK: wrb=%p seqno=%u lastseq=%u pktlen=%u ackno=%u\n", - wrb, WRB_SEQNO(wrb), lastseq, WRB_PKTLEN(wrb), ackno); + wrb, TCP_WBSEQNO(wrb), lastseq, TCP_WBPKTLEN(wrb), + ackno); /* Has the entire buffer been ACKed? */ @@ -449,24 +450,24 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, * buffers in the chain. */ - trimlen = ackno - WRB_SEQNO(wrb); - if (trimlen > WRB_SENT(wrb)) + trimlen = ackno - TCP_WBSEQNO(wrb); + if (trimlen > TCP_WBSENT(wrb)) { /* More data has been ACKed then we have sent? */ - trimlen = WRB_SENT(wrb); + trimlen = TCP_WBSENT(wrb); } ninfo("ACK: wrb=%p trim %u bytes\n", wrb, trimlen); - WRB_TRIM(wrb, trimlen); - WRB_SEQNO(wrb) = ackno; - WRB_SENT(wrb) -= trimlen; + TCP_WBTRIM(wrb, trimlen); + TCP_WBSEQNO(wrb) = ackno; + TCP_WBSENT(wrb) -= trimlen; /* Set the new sequence number for what remains */ ninfo("ACK: wrb=%p seqno=%u pktlen=%u\n", - wrb, WRB_SEQNO(wrb), WRB_PKTLEN(wrb)); + wrb, TCP_WBSEQNO(wrb), TCP_WBPKTLEN(wrb)); } } } @@ -477,31 +478,31 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, */ wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q); - if (wrb && WRB_SENT(wrb) > 0 && ackno > WRB_SEQNO(wrb)) + if (wrb && TCP_WBSENT(wrb) > 0 && ackno > TCP_WBSEQNO(wrb)) { uint32_t nacked; /* Number of bytes that were ACKed */ - nacked = ackno - WRB_SEQNO(wrb); - if (nacked > WRB_SENT(wrb)) + nacked = ackno - TCP_WBSEQNO(wrb); + if (nacked > TCP_WBSENT(wrb)) { /* More data has been ACKed then we have sent? ASSERT? */ - nacked = WRB_SENT(wrb); + nacked = TCP_WBSENT(wrb); } ninfo("ACK: wrb=%p seqno=%u nacked=%u sent=%u ackno=%u\n", - wrb, WRB_SEQNO(wrb), nacked, WRB_SENT(wrb), ackno); + wrb, TCP_WBSEQNO(wrb), nacked, TCP_WBSENT(wrb), ackno); /* Trim the ACKed bytes from the beginning of the write buffer. */ - WRB_TRIM(wrb, nacked); - WRB_SEQNO(wrb) = ackno; - WRB_SENT(wrb) -= nacked; + TCP_WBTRIM(wrb, nacked); + TCP_WBSEQNO(wrb) = ackno; + TCP_WBSENT(wrb) -= nacked; ninfo("ACK: wrb=%p seqno=%u pktlen=%u sent=%u\n", - wrb, WRB_SEQNO(wrb), WRB_PKTLEN(wrb), WRB_SENT(wrb)); + wrb, TCP_WBSEQNO(wrb), TCP_WBPKTLEN(wrb), TCP_WBSENT(wrb)); } } @@ -543,16 +544,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, */ wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q); - ninfo("REXMIT: wrb=%p sent=%u\n", wrb, wrb ? WRB_SENT(wrb) : 0); + ninfo("REXMIT: wrb=%p sent=%u\n", wrb, wrb ? TCP_WBSENT(wrb) : 0); - if (wrb != NULL && WRB_SENT(wrb) > 0) + if (wrb != NULL && TCP_WBSENT(wrb) > 0) { FAR struct tcp_wrbuffer_s *tmp; uint16_t sent; /* Yes.. Reset the number of bytes sent sent from the write buffer */ - sent = WRB_SENT(wrb); + sent = TCP_WBSENT(wrb); if (conn->unacked > sent) { conn->unacked -= sent; @@ -571,16 +572,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, conn->sent = 0; } - WRB_SENT(wrb) = 0; + TCP_WBSENT(wrb) = 0; ninfo("REXMIT: wrb=%p sent=%u, conn unacked=%d sent=%d\n", - wrb, WRB_SENT(wrb), conn->unacked, conn->sent); + wrb, TCP_WBSENT(wrb), conn->unacked, conn->sent); /* Increment the retransmit count on this write buffer. */ - if (++WRB_NRTX(wrb) >= TCP_MAXRTX) + if (++TCP_WBNRTX(wrb) >= TCP_MAXRTX) { nwarn("WARNING: Expiring wrb=%p nrtx=%u\n", - wrb, WRB_NRTX(wrb)); + wrb, TCP_WBNRTX(wrb)); /* The maximum retry count as been exhausted. Remove the write * buffer at the head of the queue. @@ -618,7 +619,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, /* Reset the number of bytes sent sent from the write buffer */ - sent = WRB_SENT(wrb); + sent = TCP_WBSENT(wrb); if (conn->unacked > sent) { conn->unacked -= sent; @@ -637,16 +638,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, conn->sent = 0; } - WRB_SENT(wrb) = 0; + TCP_WBSENT(wrb) = 0; ninfo("REXMIT: wrb=%p sent=%u, conn unacked=%d sent=%d\n", - wrb, WRB_SENT(wrb), conn->unacked, conn->sent); + wrb, TCP_WBSENT(wrb), conn->unacked, conn->sent); /* Free any write buffers that have exceed the retry count */ - if (++WRB_NRTX(wrb) >= TCP_MAXRTX) + if (++TCP_WBNRTX(wrb) >= TCP_MAXRTX) { nwarn("WARNING: Expiring wrb=%p nrtx=%u\n", - wrb, WRB_NRTX(wrb)); + wrb, TCP_WBNRTX(wrb)); /* Return the write buffer to the free list */ @@ -671,7 +672,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, * is pulled from the write_q again. */ - ninfo("REXMIT: Moving wrb=%p nrtx=%u\n", wrb, WRB_NRTX(wrb)); + ninfo("REXMIT: Moving wrb=%p nrtx=%u\n", wrb, TCP_WBNRTX(wrb)); psock_insert_segment(wrb, &conn->write_q); } @@ -726,7 +727,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, * window size. */ - sndlen = WRB_PKTLEN(wrb) - WRB_SENT(wrb); + sndlen = TCP_WBPKTLEN(wrb) - TCP_WBSENT(wrb); if (sndlen > conn->mss) { sndlen = conn->mss; @@ -738,16 +739,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, } ninfo("SEND: wrb=%p pktlen=%u sent=%u sndlen=%u\n", - wrb, WRB_PKTLEN(wrb), WRB_SENT(wrb), sndlen); + wrb, TCP_WBPKTLEN(wrb), TCP_WBSENT(wrb), sndlen); /* Set the sequence number for this segment. If we are * retransmitting, then the sequence number will already * be set for this write buffer. */ - if (WRB_SEQNO(wrb) == (unsigned)-1) + if (TCP_WBSEQNO(wrb) == (unsigned)-1) { - WRB_SEQNO(wrb) = conn->isn + conn->sent; + TCP_WBSEQNO(wrb) = conn->isn + conn->sent; } /* The TCP stack updates sndseq on receipt of ACK *before* @@ -757,7 +758,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, * before the packet is sent. */ - tcp_setsequence(conn->sndseq, WRB_SEQNO(wrb) + WRB_SENT(wrb)); + tcp_setsequence(conn->sndseq, TCP_WBSEQNO(wrb) + TCP_WBSENT(wrb)); #ifdef NEED_IPDOMAIN_SUPPORT /* If both IPv4 and IPv6 support are enabled, then we will need to @@ -773,7 +774,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, * won't actually happen until the polling cycle completes). */ - devif_iob_send(dev, WRB_IOB(wrb), sndlen, WRB_SENT(wrb)); + devif_iob_send(dev, TCP_WBIOB(wrb), sndlen, TCP_WBSENT(wrb)); /* Remember how much data we send out now so that we know * when everything has been acknowledged. Just increment @@ -795,21 +796,21 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, } ninfo("SEND: wrb=%p nrtx=%u unacked=%u sent=%u\n", - wrb, WRB_NRTX(wrb), conn->unacked, conn->sent); + wrb, TCP_WBNRTX(wrb), conn->unacked, conn->sent); /* Increment the count of bytes sent from this write buffer */ - WRB_SENT(wrb) += sndlen; + TCP_WBSENT(wrb) += sndlen; ninfo("SEND: wrb=%p sent=%u pktlen=%u\n", - wrb, WRB_SENT(wrb), WRB_PKTLEN(wrb)); + wrb, TCP_WBSENT(wrb), TCP_WBPKTLEN(wrb)); /* Remove the write buffer from the write queue if the * last of the data has been sent from the buffer. */ - DEBUGASSERT(WRB_SENT(wrb) <= WRB_PKTLEN(wrb)); - if (WRB_SENT(wrb) >= WRB_PKTLEN(wrb)) + DEBUGASSERT(TCP_WBSENT(wrb) <= TCP_WBPKTLEN(wrb)); + if (TCP_WBSENT(wrb) >= TCP_WBPKTLEN(wrb)) { FAR struct tcp_wrbuffer_s *tmp; @@ -943,8 +944,6 @@ static inline void send_txnotify(FAR struct socket *psock, * In this case the process will also receive a SIGPIPE unless * MSG_NOSIGNAL is set. * - * Assumptions: - * ****************************************************************************/ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, @@ -953,20 +952,19 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, FAR struct tcp_conn_s *conn; FAR struct tcp_wrbuffer_s *wrb; ssize_t result = 0; - int errcode; int ret = OK; if (psock == NULL || psock->s_crefs <= 0) { nerr("ERROR: Invalid socket\n"); - errcode = EBADF; + ret = -EBADF; goto errout; } if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags)) { nerr("ERROR: Not connected\n"); - errcode = ENOTCONN; + ret = -ENOTCONN; goto errout; } @@ -1003,7 +1001,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, if (ret < 0) { nerr("ERROR: Not reachable\n"); - errcode = ENETUNREACH; + ret = -ENETUNREACH; goto errout; } #endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ @@ -1029,7 +1027,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, /* A buffer allocation error occurred */ nerr("ERROR: Failed to allocate write buffer\n"); - errcode = ENOMEM; + ret = -ENOMEM; goto errout_with_lock; } @@ -1047,7 +1045,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, /* A buffer allocation error occurred */ nerr("ERROR: Failed to allocate callback\n"); - errcode = ENOMEM; + ret = -ENOMEM; goto errout_with_wrb; } @@ -1060,13 +1058,25 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, /* Initialize the write buffer */ - WRB_SEQNO(wrb) = (unsigned)-1; - WRB_NRTX(wrb) = 0; - result = WRB_COPYIN(wrb, (FAR uint8_t *)buf, len); + TCP_WBSEQNO(wrb) = (unsigned)-1; + TCP_WBNRTX(wrb) = 0; + + /* Copy the user data into the write buffer. We cannot wait for + * buffer space if the socket was opened non-blocking. + */ + + if (_SS_ISNONBLOCK(psock->s_flags)) + { + result = TCP_WBTRYCOPYIN(wrb, (FAR uint8_t *)buf, len); + } + else + { + result = TCP_WBCOPYIN(wrb, (FAR uint8_t *)buf, len); + } /* Dump I/O buffer chain */ - WRB_DUMP("I/O buffer chain", wrb, WRB_PKTLEN(wrb), 0); + TCP_WBDUMP("I/O buffer chain", wrb, TCP_WBPKTLEN(wrb), 0); /* psock_send_eventhandler() will send data in FIFO order from the * conn->write_q @@ -1074,7 +1084,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, sq_addlast(&wrb->wb_node, &conn->write_q); ninfo("Queued WRB=%p pktlen=%u write_q(%p,%p)\n", - wrb, WRB_PKTLEN(wrb), + wrb, TCP_WBPKTLEN(wrb), conn->write_q.head, conn->write_q.tail); /* Notify the device driver of the availability of TX data */ @@ -1087,13 +1097,13 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE); - /* Check for errors. Errors are signalled by negative errno values + /* Check for errors. Errors are signaled by negative errno values * for the send length */ if (result < 0) { - errcode = result; + ret = result; goto errout; } @@ -1104,7 +1114,6 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, if (ret < 0) { - errcode = -ret; goto errout; } @@ -1119,8 +1128,7 @@ errout_with_lock: net_unlock(); errout: - set_errno(errcode); - return ERROR; + return ret; } /**************************************************************************** @@ -1161,7 +1169,7 @@ int psock_tcp_cansend(FAR struct socket *psock) return -ENOTCONN; } - if (tcp_wrbuffer_test()) + if (tcp_wrbuffer_test() < 0) { return -EWOULDBLOCK; } diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index a431f312f3dc05560914aec835b67c3e333acfcb..a92a9fda40709641f6052104208e91608ccdfd2d 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -680,7 +680,7 @@ static inline void send_txnotify(FAR struct socket *psock, * * Returned Value: * On success, returns the number of characters sent. On error, - * -1 is returned, and errno is set appropriately: + * a negated errno value is returned. * * EAGAIN or EWOULDBLOCK * The socket is marked non-blocking and the requested operation @@ -726,7 +726,6 @@ ssize_t psock_tcp_send(FAR struct socket *psock, { FAR struct tcp_conn_s *conn; struct send_s state; - int errcode; int ret = OK; /* Verify that the sockfd corresponds to valid, allocated socket */ @@ -734,7 +733,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (psock == NULL || psock->s_crefs <= 0) { nerr("ERROR: Invalid socket\n"); - errcode = EBADF; + ret = -EBADF; goto errout; } @@ -743,7 +742,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (psock->s_type != SOCK_STREAM || !_SS_ISCONNECTED(psock->s_flags)) { nerr("ERROR: Not connected\n"); - errcode = ENOTCONN; + ret = -ENOTCONN; goto errout; } @@ -781,7 +780,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (ret < 0) { nerr("ERROR: Not reachable\n"); - errcode = ENETUNREACH; + ret = -ENETUNREACH; goto errout; } #endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ @@ -869,7 +868,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (state.snd_sent < 0) { - errcode = state.snd_sent; + ret = state.snd_sent; goto errout; } @@ -879,17 +878,15 @@ ssize_t psock_tcp_send(FAR struct socket *psock, if (ret < 0) { - errcode = -ret; goto errout; } /* Return the number of bytes actually sent */ - return state.snd_sent; + ret = state.snd_sent; errout: - set_errno(errcode); - return ERROR; + return ret; } /**************************************************************************** diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index b5f5ffb5abb6c1b24d42c2a252146fc504fed733..a5812140f3d62750bb3d03851bcb401a1efc91b2 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -72,7 +72,7 @@ * conn - The TCP "connection" to poll for TX data * hsed - The polling interval in halves of a second * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/tcp/tcp_wrbuffer.c b/net/tcp/tcp_wrbuffer.c index 6553d34f20a132c29865f6cde782eac2193f3c0b..c203285ce768b6f53f448135a08690d221d09bdd 100644 --- a/net/tcp/tcp_wrbuffer.c +++ b/net/tcp/tcp_wrbuffer.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -125,7 +126,7 @@ void tcp_wrbuffer_initialize(void) * the free list. This function is called from TCP logic when a buffer * of TCP data is about to sent * - * Input parameters: + * Input Parameters: * None * * Assumptions: @@ -211,8 +212,15 @@ void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb) int tcp_wrbuffer_test(void) { int val = 0; - nxsem_getvalue(&g_wrbuffer.sem, &val); - return val > 0 ? OK : ERROR; + int ret; + + ret = nxsem_getvalue(&g_wrbuffer.sem, &val); + if (ret >= 0) + { + ret = val > 0 ? OK : -ENOSPC; + } + + return ret; } #endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_TCP_WRITE_BUFFERS */ diff --git a/net/tcp/tcp_wrbuffer_dump.c b/net/tcp/tcp_wrbuffer_dump.c index ad92bfb904fb7b2576e646e1b36d7ce24e748e97..1af765739523be4c89d88f4f453af1e6fd00e00a 100644 --- a/net/tcp/tcp_wrbuffer_dump.c +++ b/net/tcp/tcp_wrbuffer_dump.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/tcp/tcp_wrbuffer_dump.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -64,8 +64,8 @@ void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb, unsigned int len, unsigned int offset) { syslog(LOG_DEBUG, "%s: wrb=%p segno=%d sent=%d nrtx=%d\n", - msg, wrb, WRB_SEQNO(wrb), WRB_SENT(wrb), WRB_NRTX(wrb)); - iob_dump("I/O Buffer Chain", WRB_IOB(wrb), len, offset); + msg, wrb, TCP_WBSEQNO(wrb), TCP_WBSENT(wrb), TCP_WBNRTX(wrb)); + iob_dump("I/O Buffer Chain", TCP_WBIOB(wrb), len, offset); } #endif /* CONFIG_DEBUG_FEATURES */ diff --git a/net/udp/Kconfig b/net/udp/Kconfig index ba710b8629e77327421b538f275ebae562b7ac8f..7deccfc4caabd89148ec9df2d4f74753881727e8 100644 --- a/net/udp/Kconfig +++ b/net/udp/Kconfig @@ -44,7 +44,56 @@ config NET_BROADCAST config NET_UDP_READAHEAD bool "Enable UDP/IP read-ahead buffering" default y + select NET_READAHEAD select MM_IOB +config NET_UDP_WRITE_BUFFERS + bool "Enable UDP/IP write buffering" + default n + select NET_WRITE_BUFFERS + select MM_IOB + ---help--- + Write buffers allows buffering of ongoing UDP/IP packets, providing + for higher performance, streamed output. + + You might want to disable UDP/IP write buffering on a highly memory + memory constrained system where there are no performance issues. + +if NET_UDP_WRITE_BUFFERS + +config NET_UDP_NWRBCHAINS + int "Number of pre-allocated I/O buffer chain heads" + default 8 + ---help--- + These tiny nodes are used as "containers" to support queuing of + UDP write buffers. This setting will limit the number of UDP write + operations that can be "in-flight" at any give time. So a good + choice for this value would be the same as the maximum number of + UDP connections. + +config NET_UDP_WRBUFFER_DEBUG + bool "Force write buffer debug" + default n + depends on DEBUG_FEATURES + select IOB_DEBUG + ---help--- + This option will force debug output from UDP write buffer logic, + even without network debug output. This is not normally something + that would want to do but is convenient if you are debugging the + write buffer logic and do not want to get overloaded with other + network-related debug output. + +config NET_UDP_WRBUFFER_DUMP + bool "Force write buffer dump" + default n + depends on DEBUG_NET || NET_UDP_WRBUFFER_DEBUG + select IOB_DEBUG + ---help--- + Dump the contents of the write buffers. You do not want to do this + unless you really want to analyze the write buffer transfers in + detail. + +endif # NET_UDP_WRITE_BUFFERS + endif # NET_UDP && !NET_UDP_NO_STACK endmenu # UDP Networking diff --git a/net/udp/Make.defs b/net/udp/Make.defs index 4b3992911df980e2a1284e1fd452b242cb34e253..5c8918ea9a314239c2dbc2557197c203e1313777 100644 --- a/net/udp/Make.defs +++ b/net/udp/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # net/udp/Make.defs # -# Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2014-2015, 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -40,7 +40,13 @@ ifneq ($(CONFIG_NET_UDP_NO_STACK),y) # Socket layer -NET_CSRCS += udp_psock_send.c udp_psock_sendto.c +NET_CSRCS += udp_psock_send.c + +ifeq ($(CONFIG_NET_UDP_WRITE_BUFFERS),y) +SOCK_CSRCS += udp_psock_sendto_buffered.c +else +SOCK_CSRCS += udp_psock_sendto_unbuffered.c +endif ifneq ($(CONFIG_DISABLE_POLL),y) ifeq ($(CONFIG_NET_UDP_READAHEAD),y) @@ -53,6 +59,15 @@ endif NET_CSRCS += udp_conn.c udp_devpoll.c udp_send.c udp_input.c udp_finddev.c NET_CSRCS += udp_callback.c udp_ipselect.c +# UDP write buffering + +ifeq ($(CONFIG_NET_UDP_WRITE_BUFFERS),y) +NET_CSRCS += udp_wrbuffer.c +ifeq ($(CONFIG_DEBUG_FEATURES),y) +NET_CSRCS += udp_wrbuffer_dump.c +endif +endif + # Include UDP build support DEPPATH += --dep-path udp diff --git a/net/udp/udp.h b/net/udp/udp.h index cb6ca378f5cf6a2a75bab98c961f92d523fd70e7..315c0bfed0aedf4d2d816405eb20ec60b18d8b39 100644 --- a/net/udp/udp.h +++ b/net/udp/udp.h @@ -1,7 +1,7 @@ /**************************************************************************** * net/udp/udp.h * - * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,8 +43,10 @@ #include #include +#include #include +#include #include #ifdef CONFIG_NET_UDP_READAHEAD @@ -66,6 +68,17 @@ # define HAVE_UDP_POLL #endif +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +/* UDP write buffer dump macros */ + +# ifdef CONFIG_DEBUG_FEATURES +# define UDP_WBDUMP(msg,wrb,len,offset) \ + udp_wrbuffer_dump(msg,wrb,len,offset) +# else +# define UDP_WBDUMP(msg,wrb,len,offset) +# endif +#endif + /* Allocate a new UDP data callback */ #define udp_callback_alloc(dev,conn) \ @@ -102,11 +115,38 @@ struct udp_conn_s struct iob_queue_s readahead; /* Read-ahead buffering */ #endif +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + /* Write buffering + * + * write_q - The queue of unsent I/O buffers. The head of this + * list may be partially sent. FIFO ordering. + */ + + sq_queue_t write_q; /* Write buffering for UDP packets */ + FAR struct net_driver_s *dev; /* Last device */ +#endif + /* Defines the list of UDP callbacks */ FAR struct devif_callback_s *list; }; +/* This structure supports UDP write buffering. It is simply a container + * for a IOB list and associated destination address. + */ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +struct udp_wrbuffer_s +{ + sq_entry_t wb_node; /* Supports a singly linked list */ + struct sockaddr_storage wb_dest; /* Destination address */ +#ifdef CONFIG_NET_SOCKOPTS + systime_t wb_start; /* Start time for timeout calculation */ +#endif + struct iob_s *wb_iob; /* Head of the I/O buffer chain */ +}; +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -261,7 +301,7 @@ void udp_ipv6_select(FAR struct net_driver_s *dev); * dev - The device driver structure to use in the send operation * conn - The UDP "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: @@ -281,7 +321,7 @@ void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn); * dev - The device driver structure to use in the send operation * conn - The UDP "connection" structure holding port information * - * Return: + * Returned Value: * None * * Assumptions: @@ -291,6 +331,92 @@ void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn); void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn); +/**************************************************************************** + * Name: udp_wrbuffer_initialize + * + * Description: + * Initialize the list of free write buffers + * + * Assumptions: + * Called once early initialization. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +void udp_wrbuffer_initialize(void); +#endif /* CONFIG_NET_UDP_WRITE_BUFFERS */ + +/**************************************************************************** + * Name: udp_wrbuffer_alloc + * + * Description: + * Allocate a UDP write buffer by taking a pre-allocated buffer from + * the free list. This function is called from UDP logic when a buffer + * of UDP data is about to sent + * + * Input Parameters: + * None + * + * Assumptions: + * Called from user logic with the network locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +struct udp_wrbuffer_s; + +FAR struct udp_wrbuffer_s *udp_wrbuffer_alloc(void); +#endif /* CONFIG_NET_UDP_WRITE_BUFFERS */ + +/**************************************************************************** + * Name: udp_wrbuffer_release + * + * Description: + * Release a UDP write buffer by returning the buffer to the free list. + * This function is called from user logic after it is consumed the + * buffered data. + * + * Assumptions: + * Called from network stack logic with the network stack locked + * + ****************************************************************************/ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +void udp_wrbuffer_release(FAR struct udp_wrbuffer_s *wrb); +#endif /* CONFIG_NET_UDP_WRITE_BUFFERS */ + +/**************************************************************************** + * Name: udp_wrbuffer_test + * + * Description: + * Check if there is room in the write buffer. Does not reserve any space. + * + * Assumptions: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +int udp_wrbuffer_test(void); +#endif /* CONFIG_NET_UDP_WRITE_BUFFERS */ + +/**************************************************************************** + * Name: udp_wrbuffer_dump + * + * Description: + * Dump the contents of a write buffer. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +#ifdef CONFIG_DEBUG_FEATURES +void udp_wrbuffer_dump(FAR const char *msg, FAR struct udp_wrbuffer_s *wrb, + unsigned int len, unsigned int offset); +#else +# define udp_wrbuffer_dump(msg,wrb) +#endif +#endif /* CONFIG_NET_UDP_WRITE_BUFFERS */ + /**************************************************************************** * Name: udp_ipv4_input * @@ -300,7 +426,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn); * Parameters: * dev - The device driver structure containing the received UDP packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR Hold the packet and try again later. There is a listening socket * but no receive in place to catch the packet yet. @@ -323,7 +449,7 @@ int udp_ipv4_input(FAR struct net_driver_s *dev); * Parameters: * dev - The device driver structure containing the received UDP packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR Hold the packet and try again later. There is a listening socket * but no receive in place to catch the packet yet. @@ -495,7 +621,7 @@ int udp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds); * Teardown monitoring of events on an UDP/IP socket * * Input Parameters: - * psock - The TCP/IP socket of interest + * psock - The UDP/IP socket of interest * fds - The structure describing the events to be monitored, OR NULL if * this is a request to stop monitoring events. * diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 97037c444f9c5dc5ac498992f94b8d9633a27f0b..d301b3654320379e4805d466709721b872d3be7a 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -1,7 +1,8 @@ /**************************************************************************** * net/udp/udp_conn.c * - * Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2012, 2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Large parts of this file were leveraged from uIP logic: @@ -202,7 +203,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain, * Input Parameters: * None * - * Return: + * Returned Value: * Next available port number * ****************************************************************************/ @@ -485,6 +486,11 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain) conn->lport = 0; conn->ttl = IP_TTL; +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + /* Initialize the write buffer lists */ + + sq_init(&conn->write_q); +#endif /* Enqueue the connection into the active list */ dq_addlast(&conn->node, &g_active_udp_connections); @@ -505,6 +511,10 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain) void udp_free(FAR struct udp_conn_s *conn) { +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS + FAR struct udp_wrbuffer_s *wrbuffer; +#endif + /* The free list is protected by a semaphore (that behaves like a mutex). */ DEBUGASSERT(conn->crefs == 0); @@ -522,6 +532,15 @@ void udp_free(FAR struct udp_conn_s *conn) iob_free_queue(&conn->readahead); #endif +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS + /* Release any write buffers attached to the connection */ + + while ((wrbuffer = (struct udp_wrbuffer_s *)sq_remfirst(&conn->write_q)) != NULL) + { + udp_wrbuffer_release(wrbuffer); + } +#endif + /* Free the connection */ dq_addlast(&conn->node, &g_free_udp_connections); diff --git a/net/udp/udp_devpoll.c b/net/udp/udp_devpoll.c index 9b6de1a0a0bd56b3ca568677a224321ba3b50015..e23dd6830166534a35c1eeeb7144d8234bf88b5b 100644 --- a/net/udp/udp_devpoll.c +++ b/net/udp/udp_devpoll.c @@ -68,7 +68,7 @@ * dev - The device driver structure to use in the send operation * conn - The UDP "connection" to poll for TX data * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/udp/udp_input.c b/net/udp/udp_input.c index 081dc26b06232ff146228da7014f43bf11cff08c..dffd3be129be0df79745b92cd0afc28407f93198 100644 --- a/net/udp/udp_input.c +++ b/net/udp/udp_input.c @@ -71,7 +71,7 @@ * udp - A pointer to the UDP header in the packet * iplen - Length of the IP and UDP headers * - * Return: + * Returned Value: * OK - The packet has been processed and can be deleted * ERROR - Hold the packet and try again later. There is a listening * socket but no receive in place to catch the packet yet. The @@ -241,7 +241,7 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen) * Parameters: * dev - The device driver structure containing the received UDP packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR Hold the packet and try again later. There is a listening socket * but no receive in place to catch the packet yet. @@ -273,7 +273,7 @@ int udp_ipv4_input(FAR struct net_driver_s *dev) * Parameters: * dev - The device driver structure containing the received UDP packet * - * Return: + * Returned Value: * OK The packet has been processed and can be deleted * ERROR Hold the packet and try again later. There is a listening socket * but no receive in place to catch the packet yet. diff --git a/net/udp/udp_netpoll.c b/net/udp/udp_netpoll.c index 0145c3303ea4a6307d489b5e0c3ab18458af3cd5..1479a00b96d4f17c4f34637666938a13a5c572fb 100644 --- a/net/udp/udp_netpoll.c +++ b/net/udp/udp_netpoll.c @@ -111,7 +111,11 @@ static uint16_t udp_poll_eventhandler(FAR struct net_driver_s *dev, eventset |= (POLLIN & info->fds->events); } - /* poll is a sign that we are free to send data. */ + /* A poll is a sign that we are free to send data. + * REVISIT: This is bogus: If CONFIG_UDP_WRITE_BUFFERS=y then + * we never have to wait to send; otherwise, we always have to + * wait to send. Receiving a poll is irrelevant. + */ if ((flags & UDP_POLL) != 0) { diff --git a/net/udp/udp_psock_sendto_buffered.c b/net/udp/udp_psock_sendto_buffered.c new file mode 100644 index 0000000000000000000000000000000000000000..9f8716d3552f81156dc7afa6f77e23d8f216c28e --- /dev/null +++ b/net/udp/udp_psock_sendto_buffered.c @@ -0,0 +1,758 @@ +/**************************************************************************** + * net/udp/udp_send_buffered.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#if defined(CONFIG_NET) && defined(CONFIG_NET_UDP) && \ + defined(CONFIG_NET_UDP_WRITE_BUFFERS) + +#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_NET_UDP_WRBUFFER_DEBUG) +/* Force debug output (from this file only) */ + +# undef CONFIG_DEBUG_NET +# define CONFIG_DEBUG_NET 1 +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "netdev/netdev.h" +#include "socket/socket.h" +#include "inet/inet.h" +#include "arp/arp.h" +#include "icmpv6/icmpv6.h" +#include "neighbor/neighbor.h" +#include "udp/udp.h" +#include "devif/devif.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* If both IPv4 and IPv6 support are both enabled, then we will need to build + * in some additional domain selection support. + */ + +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) +# define NEED_IPDOMAIN_SUPPORT 1 +#endif + +#define UDPIPv4BUF ((struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN]) +#define UDPIPv6BUF ((struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) + +/* Debug */ + +#ifdef CONFIG_NET_UDP_WRBUFFER_DUMP +# define BUF_DUMP(msg,buf,len) lib_dumpbuffer(msg,buf,len) +#else +# define BUF_DUMP(msg,buf,len) +# undef UDP_WBDUMP +# define UDP_WBDUMP(msg,wrb,len,offset) +#endif + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#ifdef NEED_IPDOMAIN_SUPPORT +static inline void sendto_ipselect(FAR struct net_driver_s *dev, + FAR struct udp_conn_s *conn); +#endif +#ifdef CONFIG_NET_ETHERNET +static inline bool sendto_addrcheck(FAR struct udp_conn_s *conn, + FAR struct net_driver_s *dev); +#else +# define sendto_addrcheck(c,d) (true) +#endif +#ifdef CONFIG_NET_SOCKOPTS +static inline int sendto_timeout(FAR struct socket *psock, + FAR struct udp_conn_s *conn); +#endif +static int sendto_next_transfer(FAR struct socket *psock, + FAR struct udp_conn_s *conn); +static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev, + FAR void *pvconn, FAR void *pvpriv, + uint16_t flags); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sendto_writebuffer_release + * + * Description: + * Release the write buffer at the head of the write buffer queue. + * + * Parameters: + * dev - The structure of the network driver that caused the event + * psock - Socket state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +static void sendto_writebuffer_release(FAR struct socket *psock, + FAR struct udp_conn_s *conn) +{ + FAR struct udp_wrbuffer_s *wrb; + int ret = OK; + + do + { + /* Check if the write queue became empty */ + + if (sq_empty(&conn->write_q)) + { + /* Yes.. stifle any further callbacks until more write data is + * enqueued. + */ + + psock->s_sndcb->flags = 0; + psock->s_sndcb->priv = NULL; + psock->s_sndcb->event = NULL; + wrb = NULL; + } + else + { + /* Remove the write buffer from the head of the write buffer queue + * and release it. + */ + + wrb = (FAR struct udp_wrbuffer_s *)sq_remfirst(&conn->write_q); + DEBUGASSERT(wrb != NULL); + + udp_wrbuffer_release(wrb); + + /* Set up for the next packet transfer by setting the connection + * address to the address of the next packet now at the header of + * the write buffer queue. + */ + + ret = sendto_next_transfer(psock, conn); + } + } + while (wrb != NULL && ret < 0); +} + +/**************************************************************************** + * Name: sendto_ipselect + * + * Description: + * If both IPv4 and IPv6 support are enabled, then we will need to select + * which one to use when generating the outgoing packet. If only one + * domain is selected, then the setup is already in place and we need do + * nothing. + * + * Parameters: + * dev - The structure of the network driver that caused the event + * psock - Socket state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +#ifdef NEED_IPDOMAIN_SUPPORT +static inline void sendto_ipselect(FAR struct net_driver_s *dev, + FAR struct udp_conn_s *conn) +{ + /* Which domain the socket support */ + + if (conn->domain == PF_INET) + { + /* Select the IPv4 domain */ + + udp_ipv4_select(dev); + } + else /* if (conn->domain == PF_INET6) */ + { + /* Select the IPv6 domain */ + + DEBUGASSERT(conn->domain == PF_INET6); + udp_ipv6_select(dev); + } +} +#endif + +/**************************************************************************** + * Name: sendto_addrcheck + * + * Description: + * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor + * tables. If not, then the send won't actually make it out... it will be + * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6). + * + * NOTE 1: This could be an expensive check if there are a lot of + * entries in the ARP or Neighbor tables. + * + * NOTE 2: If we are actually harvesting IP addresses on incoming IP + * packets, then this check should not be necessary; the MAC mapping + * should already be in the ARP table in many cases (IPv4 only). + * + * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP + * address mapping is already in the ARP table. + * + * Parameters: + * conn - The UDP connection structure + * dev - Polling network device + * + * Returned Value: + * true - The Ethernet MAC address is in the ARP or Neighbor table (OR + * the network device is not Ethernet). + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ETHERNET +static inline bool sendto_addrcheck(FAR struct udp_conn_s *conn, + FAR struct net_driver_s *dev) +{ + /* REVISIT: Could the MAC address not also be in a routing table? */ + + if (dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } + +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if (conn->domain == PF_INET) +#endif + { +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + return (arp_find(conn->u.ipv4.raddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { +#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) + return (neighbor_findentry(conn->u.ipv6.raddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} +#endif /* CONFIG_NET_ETHERNET */ + +/**************************************************************************** + * Name: sendto_timeout + * + * Description: + * Check for send timeout. + * + * Parameters: + * pstate - sendto state structure + * + * Returned Value: + * TRUE:timeout FALSE:no timeout + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +#ifdef CONFIG_NET_SOCKOPTS +static inline int sendto_timeout(FAR struct socket *psock, + FAR struct udp_conn_s *conn) +{ + FAR struct udp_wrbuffer_s *wrb; + + /* Peek at the head of the write queue (without altering the write queue). */ + + wrb = (FAR struct udp_wrbuffer_s *)sq_peek(&conn->write_q); + if (wrb != NULL) + { + /* Check for a timeout configured via setsockopts(SO_SNDTIMEO). + * If none... we well let the send wait forever. + */ + + if (psock->s_sndtimeo != 0) + { + /* Check if the configured timeout has elapsed */ + + return net_timeo(wrb->wb_start, psock->s_sndtimeo); + } + } + + /* No timeout */ + + return FALSE; +} +#endif /* CONFIG_NET_SOCKOPTS */ + +/**************************************************************************** + * Name: sendto_next_transfer + * + * Description: + * Setup for the next packet transfer + * + * Parameters: + * psock - Socket state structure + * conn - The UDP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static int sendto_next_transfer(FAR struct socket *psock, + FAR struct udp_conn_s *conn) +{ + FAR struct udp_wrbuffer_s *wrb; + FAR struct net_driver_s *dev; + int ret; + + /* Set the UDP "connection" to the destination address of the write buffer + * at the head of the queue. + */ + + wrb = (FAR struct udp_wrbuffer_s *)sq_peek(&conn->write_q); + if (wrb == NULL) + { + ninfo("Write buffer queue is empty\n"); + return -ENOENT; + } + + ret = udp_connect(conn, (FAR const struct sockaddr *)&wrb->wb_dest); + if (ret < 0) + { + nerr("ERROR: udp_connect failed: %d\n", ret); + return ret; + } + + /* Get the device that will handle the remote packet transfers. This + * should never be NULL. + */ + + dev = udp_find_raddr_device(conn); + if (dev == NULL) + { + nerr("ERROR: udp_find_raddr_device failed\n"); + return -ENETUNREACH; + } + + /* Make sure that the device is in the UP state */ + + if ((dev->d_flags & IFF_UP) == 0) + { + nwarn("WARNING: device is DOWN\n"); + return -EHOSTUNREACH; + } + + /* If this is not the same device that we used in the last call to + * udp_callback_alloc(), then we need to release and reallocate the old + * callback instance. + */ + + if (psock->s_sndcb != NULL && conn->dev != dev) + { + udp_callback_free(conn->dev, conn, psock->s_sndcb); + psock->s_sndcb = NULL; + } + + /* Allocate resources to receive a callback from this device if the + * callback is not already in place. + */ + + if (psock->s_sndcb == NULL) + { + psock->s_sndcb = udp_callback_alloc(dev, conn); + } + + /* Test if the callback has been allocated */ + + if (psock->s_sndcb == NULL) + { + /* A buffer allocation error occurred */ + + nerr("ERROR: Failed to allocate callback\n"); + return -ENOMEM; + } + + conn->dev = dev; + + /* Set up the callback in the connection */ + + psock->s_sndcb->flags = (UDP_POLL | NETDEV_DOWN); + psock->s_sndcb->priv = (FAR void *)psock; + psock->s_sndcb->event = sendto_eventhandler; + + /* Notify the device driver of the availability of TX data */ + + netdev_txnotify_dev(dev); + return OK; +} + +/**************************************************************************** + * Name: sendto_eventhandler + * + * Description: + * This function is called to perform the actual send operation when + * polled by the lower, device interfacing layer. + * + * Parameters: + * dev The structure of the network driver that caused the event + * conn The connection structure associated with the socket + * flags Set of events describing why the callback was invoked + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev, + FAR void *pvconn, FAR void *pvpriv, + uint16_t flags) +{ + FAR struct udp_conn_s *conn = (FAR struct udp_conn_s *)pvconn; + FAR struct socket *psock = (FAR struct socket *)pvpriv; + + ninfo("flags: %04x\n", flags); + + /* Check if the network device has gone down */ + + if ((flags & NETDEV_DOWN) != 0) + { + ninfo("Device down: %04x\n", flags); + + /* Free the write buffer at the head of the queue and attempt to setup + * the next transfer. + */ + + sendto_writebuffer_release(psock, conn); + return flags; + } + + /* Check for a normal polling cycle and if the outgoing packet is + * available. It would not be available if it has been claimed by a send + * event serving a different thread -OR- if the output buffer currently + * contains unprocessed incoming data. In these cases we will just have + * to wait for the next polling cycle. + * + * And, of course, we can do nothing if we have no data in the write + * buffers to send. + */ + + if (dev->d_sndlen <= 0 && (flags & UDP_NEWDATA) == 0 && + (flags & UDP_POLL) != 0 && !sq_empty(&conn->write_q)) + { + /* Check if the destination IP address is in the ARP or Neighbor + * table. If not, then the send won't actually make it out... it + * will be replaced with an ARP request or Neighbor Solicitation. + */ + + if (sendto_addrcheck(conn, dev)) + { + FAR struct udp_wrbuffer_s *wrb; + size_t sndlen; + + /* Peek at the head of the write queue (but don't remove anything + * from the write queue yet). We know from the above test that + * the write_q is not empty. + */ + + wrb = (FAR struct udp_wrbuffer_s *)sq_peek(&conn->write_q); + DEBUGASSERT(wrb != NULL); + + /* Get the amount of data that we can send in the next packet. + * We will send either the remaining data in the buffer I/O + * buffer chain, or as much as will fit given the MSS and current + * window size. + */ + + sndlen = wrb->wb_iob->io_pktlen; + ninfo("wrb=%p sndlen=%u\n", wrb, sndlen); + +#ifdef NEED_IPDOMAIN_SUPPORT + /* If both IPv4 and IPv6 support are enabled, then we will need to + * select which one to use when generating the outgoing packet. + * If only one domain is selected, then the setup is already in + * place and we need do nothing. + */ + + sendto_ipselect(dev, conn); +#endif + /* Then set-up to send that amount of data with the offset + * corresponding to the size of the IP-dependent address structure. + */ + + devif_iob_send(dev, wrb->wb_iob, sndlen, 0); + + /* Free the write buffer at the head of the queue and attempt to + * setup the next transfer. + */ + + sendto_writebuffer_release(psock, conn); + + /* Only one data can be sent by low level driver at once, + * tell the caller stop polling the other connections. + */ + + flags &= ~UDP_POLL; + } + } + +#ifdef CONFIG_NET_SOCKOPTS + /* We cannot send the data now. Check for a timeout. */ + + else if (sendto_timeout(psock, conn)) + { + /* Free the write buffer at the head of the queue and attempt to setup + * the next transfer. + */ + + sendto_writebuffer_release(psock, conn); + } +#endif /* CONFIG_NET_SOCKOPTS */ + + /* Continue waiting */ + + return flags; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: psock_udp_sendto + * + * Description: + * This function implements the UDP-specific logic of the standard + * sendto() socket operation. + * + * Input Parameters: + * psock A pointer to a NuttX-specific, internal socket structure + * buf Data to send + * len Length of data to send + * flags Send flags + * to Address of recipient + * tolen The length of the address structure + * + * NOTE: All input parameters were verified by sendto() before this + * function was called. + * + * Returned Value: + * On success, returns the number of characters sent. On error, + * a negated errno value is returned. See the description in + * net/socket/sendto.c for the list of appropriate return value. + * + ****************************************************************************/ + +ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, + size_t len, int flags, FAR const struct sockaddr *to, + socklen_t tolen) +{ + FAR struct udp_conn_s *conn; + FAR struct udp_wrbuffer_s *wrb; + int ret = OK; + + /* Make sure that we have the IP address mapping */ + + conn = (FAR struct udp_conn_s *)psock->s_conn; + DEBUGASSERT(conn); + +#if defined(CONFIG_NET_ARP_SEND) || defined(CONFIG_NET_ICMPv6_NEIGHBOR) +#ifdef CONFIG_NET_ARP_SEND +#ifdef CONFIG_NET_ICMPv6_NEIGHBOR + if (psock->s_domain == PF_INET) +#endif + { + /* Make sure that the IP address mapping is in the ARP table */ + + ret = arp_send(conn->u.ipv4.raddr); + } +#endif /* CONFIG_NET_ARP_SEND */ + +#ifdef CONFIG_NET_ICMPv6_NEIGHBOR +#ifdef CONFIG_NET_ARP_SEND + else +#endif + { + /* Make sure that the IP address mapping is in the Neighbor Table */ + + ret = icmpv6_neighbor(conn->u.ipv6.raddr); + } +#endif /* CONFIG_NET_ICMPv6_NEIGHBOR */ + + /* Did we successfully get the address mapping? */ + + if (ret < 0) + { + nerr("ERROR: Not reachable\n"); + return -ENETUNREACH; + } +#endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ + + /* Dump the incoming buffer */ + + BUF_DUMP("psock_udp_send", buf, len); + + /* Set the socket state to sending */ + + psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND); + + if (len > 0) + { + /* Allocate a write buffer. Careful, the network will be momentarily + * unlocked here. + */ + + net_lock(); + wrb = udp_wrbuffer_alloc(); + if (wrb == NULL) + { + /* A buffer allocation error occurred */ + + nerr("ERROR: Failed to allocate write buffer\n"); + ret = -ENOMEM; + goto errout_with_lock; + } + + /* Initialize the write buffer */ + + memcpy(&wrb->wb_dest, to, tolen); + wrb->wb_start = clock_systimer(); + + /* Copy the user data into the write buffer. We cannot wait for + * buffer space if the socket was opened non-blocking. + */ + + if (_SS_ISNONBLOCK(psock->s_flags)) + { + ret = iob_trycopyin(wrb->wb_iob, (FAR uint8_t *)buf, len, 0, false); + } + else + { + ret = iob_copyin(wrb->wb_iob, (FAR uint8_t *)buf, len, 0, false); + } + + if (ret < 0) + { + goto errout_with_wrb; + } + + /* Dump I/O buffer chain */ + + UDP_WBDUMP("I/O buffer chain", wrb, wrb->wb_iob->io_pktlen, 0); + + /* sendto_eventhandler() will send data in FIFO order from the + * conn->write_q. + * + * REVISIT: Why FIFO order? Because it is easy. In a real world + * environment where there are multiple network devices this might + * be inefficient because we could be sending data to different + * device out-of-queued-order to optimize performance. Sending + * data to different networks from a single UDP socket is probably + * not a very common use case, however. + */ + + sq_addlast(&wrb->wb_node, &conn->write_q); + ninfo("Queued WRB=%p pktlen=%u write_q(%p,%p)\n", + wrb, wrb->wb_iob->io_pktlen, + conn->write_q.head, conn->write_q.tail); + + /* Set up for the next packet transfer by setting the connection + * address to the address of the next packet now at the header of the + * write buffer queue. + */ + + ret = sendto_next_transfer(psock, conn); + if (ret < 0) + { + (void)sq_remlast(&conn->write_q); + goto errout_with_wrb; + } + + net_unlock(); + } + + /* Set the socket state to idle */ + + psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE); + + /* Return the number of bytes that will be sent */ + + return len; + +errout_with_wrb: + udp_wrbuffer_release(wrb); + +errout_with_lock: + net_unlock(); + return ret; +} + +#endif /* CONFIG_NET && CONFIG_NET_UDP && CONFIG_NET_UDP_WRITE_BUFFERS */ diff --git a/net/udp/udp_psock_sendto.c b/net/udp/udp_psock_sendto_unbuffered.c similarity index 91% rename from net/udp/udp_psock_sendto.c rename to net/udp/udp_psock_sendto_unbuffered.c index 4710fb36d68aa7583d7c133f42ad9d1aa6f24eff..7024d12baf0b12b472b89863bac25a293e115fc7 100644 --- a/net/udp/udp_psock_sendto.c +++ b/net/udp/udp_psock_sendto_unbuffered.c @@ -1,7 +1,8 @@ /**************************************************************************** - * net/udp/udp_psock_sendto.c + * net/udp/udp_psock_sendto_unbuffered.c * - * Copyright (C) 2007-2009, 2011-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -70,36 +71,16 @@ # define NEED_IPDOMAIN_SUPPORT 1 #endif -/* Timeouts on sendto() do not make sense. Each polling cycle from the - * driver is an opportunity to send a packet. If the driver is not polling, - * then the network is not up (and there are no polling cycles to drive - * the timeout). - * - * There is a remote possibility that if there is a lot of other network - * traffic that a UDP sendto could get delayed, but I would not expect this - * generate a timeout. - */ - -#undef CONFIG_NET_SENDTO_TIMEOUT - -/* If supported, the sendto timeout function would depend on socket options - * and a system clock. - */ - -#ifndef CONFIG_NET_SOCKOPTS -# undef CONFIG_NET_SENDTO_TIMEOUT -#endif - /**************************************************************************** * Private Types ****************************************************************************/ struct sendto_s { -#if defined(CONFIG_NET_SENDTO_TIMEOUT) || defined(NEED_IPDOMAIN_SUPPORT) +#if defined(CONFIG_NET_SOCKOPTS) || defined(NEED_IPDOMAIN_SUPPORT) FAR struct socket *st_sock; /* Points to the parent socket structure */ #endif -#ifdef CONFIG_NET_SENDTO_TIMEOUT +#ifdef CONFIG_NET_SOCKOPTS systime_t st_time; /* Last send time for determining timeout */ #endif FAR struct devif_callback_s *st_cb; /* Reference to callback instance */ @@ -114,7 +95,7 @@ struct sendto_s ****************************************************************************/ /**************************************************************************** - * Name: send_timeout + * Name: sendto_timeout * * Description: * Check for send timeout. @@ -130,8 +111,8 @@ struct sendto_s * ****************************************************************************/ -#ifdef CONFIG_NET_SENDTO_TIMEOUT -static inline int send_timeout(FAR struct sendto_s *pstate) +#ifdef CONFIG_NET_SOCKOPTS +static inline int sendto_timeout(FAR struct sendto_s *pstate) { FAR struct socket *psock; @@ -151,7 +132,7 @@ static inline int send_timeout(FAR struct sendto_s *pstate) return FALSE; } -#endif /* CONFIG_NET_SENDTO_TIMEOUT */ +#endif /* CONFIG_NET_SOCKOPTS */ /**************************************************************************** * Name: sendto_ipselect @@ -254,8 +235,8 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev, * polling cycle and check again. */ -#ifdef CONFIG_NET_SENDTO_TIMEOUT - if (send_timeout(pstate)) +#ifdef CONFIG_NET_SOCKOPTS + if (sendto_timeout(pstate)) { /* Yes.. report the timeout */ @@ -263,7 +244,7 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev, pstate->st_sndlen = -ETIMEDOUT; } else -#endif /* CONFIG_NET_SENDTO_TIMEOUT */ +#endif /* CONFIG_NET_SOCKOPTS */ { /* No timeout. Just wait for the next polling cycle */ @@ -403,7 +384,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, state.st_buflen = len; state.st_buffer = buf; -#if defined(CONFIG_NET_SENDTO_TIMEOUT) || defined(NEED_IPDOMAIN_SUPPORT) +#if defined(CONFIG_NET_SOCKOPTS) || defined(NEED_IPDOMAIN_SUPPORT) /* Save the reference to the socket structure if it will be needed for * asynchronous processing. */ @@ -411,7 +392,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, state.st_sock = psock; #endif -#ifdef CONFIG_NET_SENDTO_TIMEOUT +#ifdef CONFIG_NET_SOCKOPTS /* Set the initial time for calculating timeouts */ state.st_time = clock_systimer(); @@ -443,6 +424,15 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, goto errout_with_lock; } + /* Make sure that the device is in the UP state */ + + if ((dev->d_flags & IFF_UP) == 0) + { + nwarn("WARNING: device is DOWN\n"); + ret = -EHOSTUNREACH; + goto errout_with_lock; + } + /* Set up the callback in the connection */ state.st_cb = udp_callback_alloc(dev, conn); diff --git a/net/udp/udp_send.c b/net/udp/udp_send.c index 7779d038759ef89b2345d62be63ccef3febb008b..46a9b3e86d41d1aecf94f9035878d5f5c90d9e50 100644 --- a/net/udp/udp_send.c +++ b/net/udp/udp_send.c @@ -89,7 +89,7 @@ * dev - The device driver structure to use in the send operation * conn - The UDP "connection" structure holding port information * - * Return: + * Returned Value: * None * * Assumptions: diff --git a/net/udp/udp_wrbuffer.c b/net/udp/udp_wrbuffer.c new file mode 100644 index 0000000000000000000000000000000000000000..5e0eca867795d5b804aee1d30e6066f2a5b64c4b --- /dev/null +++ b/net/udp/udp_wrbuffer.c @@ -0,0 +1,217 @@ +/**************************************************************************** + * net/udp/udp_wrbuffer.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#if defined(CONFIG_NET) && defined(CONFIG_NET_UDP) && defined(CONFIG_NET_UDP_WRITE_BUFFERS) + +#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_NET_UDP_WRBUFFER_DEBUG) +/* Force debug output (from this file only) */ + +# undef CONFIG_DEBUG_NET +# define CONFIG_DEBUG_NET 1 +#endif + +#include +#include +#include +#include + +#include +#include +#include + +#include "udp/udp.h" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* Package all globals used by this logic into a structure */ + +struct wrbuffer_s +{ + /* The semaphore to protect the buffers */ + + sem_t sem; + + /* This is the list of available write buffers */ + + sq_queue_t freebuffers; + + /* These are the pre-allocated write buffers */ + + struct udp_wrbuffer_s buffers[CONFIG_NET_UDP_NWRBCHAINS]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* This is the state of the global write buffer resource */ + +static struct wrbuffer_s g_wrbuffer; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: udp_wrbuffer_initialize + * + * Description: + * Initialize the list of free write buffers + * + * Assumptions: + * Called once early initialization. + * + ****************************************************************************/ + +void udp_wrbuffer_initialize(void) +{ + int i; + + sq_init(&g_wrbuffer.freebuffers); + + for (i = 0; i < CONFIG_NET_UDP_NWRBCHAINS; i++) + { + sq_addfirst(&g_wrbuffer.buffers[i].wb_node, &g_wrbuffer.freebuffers); + } + + nxsem_init(&g_wrbuffer.sem, 0, CONFIG_NET_UDP_NWRBCHAINS); +} + +/**************************************************************************** + * Name: udp_wrbuffer_alloc + * + * Description: + * Allocate a UDP write buffer by taking a pre-allocated buffer from + * the free list. This function is called from UDP logic when a buffer + * of UDP data is about to sent + * + * Input Parameters: + * None + * + * Assumptions: + * Called from user logic with the network locked. + * + ****************************************************************************/ + +FAR struct udp_wrbuffer_s *udp_wrbuffer_alloc(void) +{ + FAR struct udp_wrbuffer_s *wrb; + + /* We need to allocate two things: (1) A write buffer structure and (2) + * at least one I/O buffer to start the chain. + * + * Allocate the write buffer structure first then the IOBG. In order to + * avoid deadlocks, we will need to free the IOB first, then the write + * buffer + */ + + DEBUGVERIFY(net_lockedwait(&g_wrbuffer.sem)); /* TODO: Handle EINTR. */ + + /* Now, we are guaranteed to have a write buffer structure reserved + * for us in the free list. + */ + + wrb = (FAR struct udp_wrbuffer_s *)sq_remfirst(&g_wrbuffer.freebuffers); + DEBUGASSERT(wrb); + memset(wrb, 0, sizeof(struct udp_wrbuffer_s)); + + /* Now get the first I/O buffer for the write buffer structure */ + + wrb->wb_iob = iob_alloc(false); + if (!wrb->wb_iob) + { + nerr("ERROR: Failed to allocate I/O buffer\n"); + udp_wrbuffer_release(wrb); + return NULL; + } + + return wrb; +} + +/**************************************************************************** + * Name: udp_wrbuffer_release + * + * Description: + * Release a UDP write buffer by returning the buffer to the free list. + * This function is called from user logic after it is consumed the + * buffered data. + * + * Assumptions: + * This function must be called with the network locked. + * + ****************************************************************************/ + +void udp_wrbuffer_release(FAR struct udp_wrbuffer_s *wrb) +{ + DEBUGASSERT(wrb && wrb->wb_iob); + + /* To avoid deadlocks, we must following this ordering: Release the I/O + * buffer chain first, then the write buffer structure. + */ + + iob_free_chain(wrb->wb_iob); + + /* Then free the write buffer structure */ + + sq_addlast(&wrb->wb_node, &g_wrbuffer.freebuffers); + nxsem_post(&g_wrbuffer.sem); +} + +/**************************************************************************** + * Name: udp_wrbuffer_test + * + * Description: + * Check if there is room in the write buffer. Does not reserve any space. + * + * Assumptions: + * None. + * + ****************************************************************************/ + +int udp_wrbuffer_test(void) +{ + int val = 0; + nxsem_getvalue(&g_wrbuffer.sem, &val); + return val > 0 ? OK : ERROR; +} + +#endif /* CONFIG_NET && CONFIG_NET_UDP && CONFIG_NET_UDP_WRITE_BUFFERS */ diff --git a/net/udp/udp_wrbuffer_dump.c b/net/udp/udp_wrbuffer_dump.c new file mode 100644 index 0000000000000000000000000000000000000000..e3e8df1f59d5d3311c84537d84c845c2b8e107d5 --- /dev/null +++ b/net/udp/udp_wrbuffer_dump.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * net/udp/udp_wrbuffer_dump.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include "udp/udp.h" + +#ifdef CONFIG_DEBUG_FEATURES + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: udp_wrbuffer_dump + * + * Description: + * Dump the contents of a write buffer + * + ****************************************************************************/ + +void udp_wrbuffer_dump(FAR const char *msg, FAR struct udp_wrbuffer_s *wrb, + unsigned int len, unsigned int offset) +{ + syslog(LOG_DEBUG, "%s: wrb=%p pktlen=%d\n", msg, wrb, wrb->wb_iob->io_pktlen); + iob_dump("I/O Buffer Chain", wrb->wb_iob, len, offset); +} + +#endif /* CONFIG_DEBUG_FEATURES */ diff --git a/net/utils/net_ipv6_mask2pref.c b/net/utils/net_ipv6_mask2pref.c index cc4fd245c85106d3d95a0d93b0930ebccf3a388f..95b1b2000a04a81e7a1767fec084e3299a2aa092 100644 --- a/net/utils/net_ipv6_mask2pref.c +++ b/net/utils/net_ipv6_mask2pref.c @@ -152,7 +152,7 @@ static inline uint8_t net_msbits16(uint16_t hword) * Parameters: * mask Points to an IPv6 netmask in the form of uint16_t[8] * - * Return: + * Returned Value: * The prefix length, range 0-128 on success; This function will not * fail. * diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c index fff004bd3fe7895a109d33d08e90625c7299a62d..3cfad414d694bda8ff3de3ba3e6a8d155c4a3d85 100644 --- a/net/utils/net_lock.c +++ b/net/utils/net_lock.c @@ -124,7 +124,7 @@ void net_lockinitialize(void) * Input Parameters: * None * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -163,7 +163,7 @@ void net_lock(void) * Input Parameters: * None * - * Returned value: + * Returned Value: * None * ****************************************************************************/ @@ -201,7 +201,7 @@ void net_unlock(void) * sem - A reference to the semaphore to be taken. * abstime - The absolute time to wait until a timeout is declared. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * @@ -265,7 +265,7 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime) * Input Parameters: * sem - A reference to the semaphore to be taken. * - * Returned value: + * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * diff --git a/net/utils/utils.h b/net/utils/utils.h index fc72447084e70d99a3e05323ce1219ae15614da5..81dac87c1547d51104eb2425b79a5bcd90c80d28 100644 --- a/net/utils/utils.h +++ b/net/utils/utils.h @@ -161,7 +161,7 @@ unsigned int net_timeval2dsec(FAR struct timeval *tv, * Parameters: * mask Points to an IPv6 netmask in the form of uint16_t[8] * - * Return: + * Returned Value: * The prefix length, range 0-128 on success; This function will not * fail. * diff --git a/sched/Kconfig b/sched/Kconfig index 6a50b93fe896d1f5165c8e18d654b6513936c431..f6ea30c099852141b0c3a21fdf3703c859b2138d 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -252,6 +252,7 @@ config SPINLOCK config SPINLOCK_IRQ bool "Support Spinlocks with IRQ control" default n + depends on ARCH_GLOBAL_IRQDISABLE ---help--- Enables suppport for spinlocks with IRQ control. This feature can be used to protect data in SMP mode. @@ -623,6 +624,15 @@ endmenu # Pthread Options menu "Performance Monitoring" +config SCHED_IRQMONITOR + bool "Enable IRQ monitoring" + default n + depends on FS_PROCFS + ---help--- + Enabling counting of interrupts from all interrupt sources. These + counts will be available in the mounted procfs file systems at the + top-level file, "irqs". + config SCHED_CPULOAD bool "Enable CPU load monitoring" default n diff --git a/sched/clock/clock_abstime2ticks.c b/sched/clock/clock_abstime2ticks.c index 25a4af540e0933094af7459ff1648287a9408f6d..4cfbea8b5b68b8988ee6870614b51be6191af16d 100644 --- a/sched/clock/clock_abstime2ticks.c +++ b/sched/clock/clock_abstime2ticks.c @@ -89,7 +89,7 @@ static long compare_timespec(FAR const struct timespec *a, * reltime - Convert this absolue time to system clock ticks. * ticks - Return the converted number of ticks here. * - * Return Value: + * Returned Value: * OK on success; A non-zero error number on failure; * * Assumptions: diff --git a/sched/clock/clock_dow.c b/sched/clock/clock_dow.c index c922e856bc2b4242f88e6aa121252065920c4722..41b7f8fafa36ac641f08f4525956f5062f4377c0 100644 --- a/sched/clock/clock_dow.c +++ b/sched/clock/clock_dow.c @@ -70,7 +70,7 @@ static const uint8_t g_lookup[12] = {2, 5, 7, 10, 12, 15, 17, 20, 23, 25, 28, 30 * month - 0 through 11 * day - 1 through 31 * - * Return Value: + * Returned Value: * The day of the week as days since Sunday: 0 = Sunday, 1 = Monday, etc. * * Assumptions: diff --git a/sched/clock/clock_gettime.c b/sched/clock/clock_gettime.c index 731c6a2ae3355c016dcc509e76cbc155643e1ec6..d3f1cd34a7e08e2fdb2dafe999c5feed0b3586bd 100644 --- a/sched/clock/clock_gettime.c +++ b/sched/clock/clock_gettime.c @@ -110,12 +110,12 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) * CLOCK_MONOTONIC be introduced additional increases to systime. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(); tp->tv_sec += (uint32_t)g_monotonic_basetime.tv_sec; tp->tv_nsec += (uint32_t)g_monotonic_basetime.tv_nsec; - leave_critical_section(flags); + spin_unlock_irqrestore(flags); /* Handle carry to seconds. */ @@ -163,12 +163,12 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) * was last set, this gives us the current time. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(); ts.tv_sec += (uint32_t)g_basetime.tv_sec; ts.tv_nsec += (uint32_t)g_basetime.tv_nsec; - leave_critical_section(flags); + spin_unlock_irqrestore(flags); /* Handle carry to seconds. */ diff --git a/sched/clock/clock_initialize.c b/sched/clock/clock_initialize.c index 6edf41d90de6f4e30414979350f02c3920623424..6cdf1b3a81a9a6a8226325ccfb4a51d26c5bcb2a 100644 --- a/sched/clock/clock_initialize.c +++ b/sched/clock/clock_initialize.c @@ -275,7 +275,7 @@ void clock_initialize(void) * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -314,7 +314,7 @@ void clock_synchronize(void) * Parameters: * rtc_diff: amount of time system-time is adjusted forward with RTC * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/clock/clock_systimer.c b/sched/clock/clock_systimer.c index 1b13451092214a281f03e377d25feb130b4583a4..6334c5232bca7bd2e8c00b5c0017eeb3f4e5725b 100644 --- a/sched/clock/clock_systimer.c +++ b/sched/clock/clock_systimer.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/clock/clock_systimer.c * - * Copyright (C) 2011, 2014-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2014-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -50,10 +50,15 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* See nuttx/clock.h */ #undef clock_systimer +/* 32-bit mask for 64-bit timer values */ + +#define TIMER_MASK32 0x00000000ffffffff + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -67,7 +72,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * The current value of the system timer counter * * Assumptions: @@ -109,20 +114,34 @@ systime_t clock_systimer(void) /* Convert to a 64- then a 32-bit value */ tmp = USEC2TICK(1000000 * (uint64_t)ts.tv_sec + (uint64_t)ts.tv_nsec / 1000); - return (systime_t)(tmp & 0x00000000ffffffff); + return (systime_t)(tmp & TIMER_MASK32); # endif /* CONFIG_SYSTEM_TIME64 */ #else /* CONFIG_SCHED_TICKLESS */ # ifdef CONFIG_SYSTEM_TIME64 - irqstate_t flags; systime_t sample; + systime_t verify; + + /* 64-bit accesses are not atomic on most architectures. The following + * loop samples the 64-bit timer twice and loops in the rare event that + * there was 32-bit rollover between samples. + * + * If there is no 32-bit rollover, then: + * + * - The MS 32-bits of each sample will be the same, and + * - The LS 32-bits of the second sample will be greater than or equal to + * the LS 32-bits for the first sample. + */ + + do + { + verify = g_system_timer; + sample = g_system_timer; + } + while ((sample & TIMER_MASK32) < (verify & TIMER_MASK32) || + (sample & ~TIMER_MASK32) != (verify & ~TIMER_MASK32)); - /* 64-bit accesses are not atomic on most architectures. */ - - flags = enter_critical_section(); - sample = g_system_timer; - leave_critical_section(flags); return sample; # else /* CONFIG_SYSTEM_TIME64 */ diff --git a/sched/clock/clock_systimespec.c b/sched/clock/clock_systimespec.c index 5d6009d0510fc1ab71da2d18f8a34db525ab7c19..bdab9b115b420b651aa648153d7786deae151116 100644 --- a/sched/clock/clock_systimespec.c +++ b/sched/clock/clock_systimespec.c @@ -62,7 +62,7 @@ * Parameters: * ts - Location to return the time * - * Return Value: + * Returned Value: * Current version always returns OK * * Assumptions: diff --git a/sched/clock/clock_ticks2time.c b/sched/clock/clock_ticks2time.c index 899ecd9818f6d7057c8eee218993384d96c59be2..0ea5295f57518f580036898639ccb896e62f2437 100644 --- a/sched/clock/clock_ticks2time.c +++ b/sched/clock/clock_ticks2time.c @@ -56,7 +56,7 @@ * ticks - The number of system time ticks to convert. * reltime - Return the converted system time here. * - * Return Value: + * Returned Value: * Always returns OK * * Assumptions: diff --git a/sched/clock/clock_time2ticks.c b/sched/clock/clock_time2ticks.c index 5f0bc28c40637a7ea95585cf6a5e8575efa7d82b..5f0cb36becfc1a5f3a90b14452bd0d654c581785 100644 --- a/sched/clock/clock_time2ticks.c +++ b/sched/clock/clock_time2ticks.c @@ -60,7 +60,7 @@ * reltime - Convert this relative time to system clock ticks. * ticks - Return the converted number of ticks here. * - * Return Value: + * Returned Value: * Always returns OK * * Assumptions: diff --git a/sched/clock/clock_timespec_add.c b/sched/clock/clock_timespec_add.c index 0e0fb931dbb8912473268393e0722d8e7a0780f5..08bf634d768da2a8b5657df1ee46437809759e39 100644 --- a/sched/clock/clock_timespec_add.c +++ b/sched/clock/clock_timespec_add.c @@ -54,11 +54,11 @@ * Description: * Add timespec ts1 to to2 and return the result in ts3 * - * Inputs: + * Input Parameters: * ts1 and ts2: The two timespecs to be added * t23: The location to return the result (may be ts1 or ts2) * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/clock/clock_timespec_subtract.c b/sched/clock/clock_timespec_subtract.c index 754c84d1cb57df1c4a0dbe75e11ca4dbca79a637..873dd75d7cc881db03d449531118171d1947317e 100644 --- a/sched/clock/clock_timespec_subtract.c +++ b/sched/clock/clock_timespec_subtract.c @@ -55,11 +55,11 @@ * Subtract timespec ts2 from to1 and return the result in ts3. * Zero is returned if the time difference is negative. * - * Inputs: + * Input Parameters: * ts1 and ts2: The two timespecs to be subtracted (ts1 - ts2) * t23: The location to return the result (may be ts1 or ts2) * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/environ/env_clearenv.c b/sched/environ/env_clearenv.c index ededbadbed13173995950b30cae79df3a5b0cc66..97aee7e230c619beda88fa264cbbc962ed13f9b6 100644 --- a/sched/environ/env_clearenv.c +++ b/sched/environ/env_clearenv.c @@ -60,7 +60,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/environ/env_dup.c b/sched/environ/env_dup.c index 08b0e1b6179e3758306d643e2672e3697a3b8043..5544c1faf687a12bbb4bb158f90820f735286c53 100644 --- a/sched/environ/env_dup.c +++ b/sched/environ/env_dup.c @@ -67,7 +67,7 @@ * group The child task group to receive the newly allocated copy of the * parent task groups environment structure. * - * Return Value: + * Returned Value: * zero on success * * Assumptions: diff --git a/sched/environ/env_findvar.c b/sched/environ/env_findvar.c index f6b44da5c497c26a63fcc2c9aabeb73b743f3d78..953aefebf3938fe96887f3b3e53b9f1f88945323 100644 --- a/sched/environ/env_findvar.c +++ b/sched/environ/env_findvar.c @@ -86,7 +86,7 @@ static bool env_cmpname(const char *pszname, const char *peqname) * group The task group containging environment array to be searched. * pname The variable name to find * - * Return Value: + * Returned Value: * A pointer to the name=value string in the environment * * Assumptions: diff --git a/sched/environ/env_getenv.c b/sched/environ/env_getenv.c index 6e92f90d3f14bc5d5cb42a26b400e7889caa715f..be20805204aa15b64fb75219c3b3023ebf84922f 100644 --- a/sched/environ/env_getenv.c +++ b/sched/environ/env_getenv.c @@ -63,7 +63,7 @@ * Parameters: * name - The name of the variable to find. * - * Return Value: + * Returned Value: * The value of the valiable (read-only) or NULL on failure * * Assumptions: diff --git a/sched/environ/env_getenvironptr.c b/sched/environ/env_getenvironptr.c index 11c4f5368e11328884ca5cf62d334bad70625520..43f7a2cfcf68302fd0a803e149dd990828306055 100644 --- a/sched/environ/env_getenvironptr.c +++ b/sched/environ/env_getenvironptr.c @@ -60,7 +60,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * A pointer to the per-thread environ variable. * * Assumptions: diff --git a/sched/environ/env_putenv.c b/sched/environ/env_putenv.c index ec683b298c000868fce894da2f76ee61cb5fe108..f54dea241f1e25e53bd78ec740ea95272df03b4d 100644 --- a/sched/environ/env_putenv.c +++ b/sched/environ/env_putenv.c @@ -65,7 +65,7 @@ * Parameters: * name=value string describing the environment setting to add/modify * - * Return Value: + * Returned Value: * Zero on sucess * * Assumptions: diff --git a/sched/environ/env_release.c b/sched/environ/env_release.c index d1ace0505b0ebb0ce338eb75e82840fc3d0f5129..fd9bdfd31208f7eda6b38d831342a8ccee04d2da 100644 --- a/sched/environ/env_release.c +++ b/sched/environ/env_release.c @@ -65,7 +65,7 @@ * group Identifies the task group containing the environment structure * to be released. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/environ/env_removevar.c b/sched/environ/env_removevar.c index b18ebbf899c7633f321c3ec59232b3b7f96f3ddb..197357ea08684fe6ab25c4ba512ecdf8326dfe18 100644 --- a/sched/environ/env_removevar.c +++ b/sched/environ/env_removevar.c @@ -60,7 +60,7 @@ * group The task group with the environment containing the name=value pair * pvar A pointer to the name=value pair in the restroom * - * Return Value: + * Returned Value: * Zero on success * * Assumptions: diff --git a/sched/environ/env_setenv.c b/sched/environ/env_setenv.c index 38faae839a8fb87e7706b9c507912833587c7cb0..96cd06ac4ce94137a1ccbe47c855bb4944f7ef6f 100644 --- a/sched/environ/env_setenv.c +++ b/sched/environ/env_setenv.c @@ -71,7 +71,7 @@ * value - The new value of the variable * overwrite - Replace any existing value if non-zero. * - * Return Value: + * Returned Value: * Zero on success * * Assumptions: diff --git a/sched/environ/env_unsetenv.c b/sched/environ/env_unsetenv.c index 2956cfe783c5f2be3c00b0e388f9cace351fdcab..fa85358abfdf5fff14cfadac5f4107d88f82e541 100644 --- a/sched/environ/env_unsetenv.c +++ b/sched/environ/env_unsetenv.c @@ -63,7 +63,7 @@ * Parameters: * name - The name of the variable to delete * - * Return Value: + * Returned Value: * Zero on success * * Assumptions: diff --git a/sched/errno/errno_get.c b/sched/errno/errno_get.c index 8982ac61e735f659f0e453f32c13e83bc1e8d4e5..3664a3e054cb0fc17f66eb3bdc44660d9deb9a78 100644 --- a/sched/errno/errno_get.c +++ b/sched/errno/errno_get.c @@ -65,7 +65,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * The current value of the thread specific errno. * * Assumptions: diff --git a/sched/errno/errno_getptr.c b/sched/errno/errno_getptr.c index 4e47895a0b4eda981427a7bfb3c2e917b01f5cc9..4d220db23d99d7471c4e243de561f5521a94d911 100644 --- a/sched/errno/errno_getptr.c +++ b/sched/errno/errno_getptr.c @@ -75,7 +75,7 @@ static int g_irqerrno; * Parameters: * None * - * Return Value: + * Returned Value: * A pointer to the per-thread errno variable. * * Assumptions: diff --git a/sched/errno/errno_set.c b/sched/errno/errno_set.c index 540bc8b7829f2249862198779c71b8e83c608ca3..a7a00af67ac8d4ce75b44f32a1f83cc11a5f4faf 100644 --- a/sched/errno/errno_set.c +++ b/sched/errno/errno_set.c @@ -64,7 +64,7 @@ * Parameters: * errcode - The thread specific errno will be set to this error code value. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/group/group_addrenv.c b/sched/group/group_addrenv.c index 52330c04cc7ae36c0d28b503e50a46531f281c1b..bc301c9b43443c63492de8f4c547dca2e0bf0f3d 100644 --- a/sched/group/group_addrenv.c +++ b/sched/group/group_addrenv.c @@ -82,7 +82,7 @@ gid_t g_gid_current; * be the TCB at the head of the ready-to-run list, but that is not * enough. * - * Return Value: + * Returned Value: * Zero (OK) is returned on success. A negated errno value is returned on * any failure. * diff --git a/sched/group/group_childstatus.c b/sched/group/group_childstatus.c index e4e994677d1faacfdc37597c3476595e0f6645f5..915c1c9a96dda69daff8a4ca7536e63806fd4547 100644 --- a/sched/group/group_childstatus.c +++ b/sched/group/group_childstatus.c @@ -100,7 +100,7 @@ static struct child_pool_s g_child_pool; * Parameters: * group - The task group containing the child status. * - * Return Value: + * Returned Value: * None. * * Assumptions: @@ -140,7 +140,7 @@ static void group_dumpchildren(FAR struct task_group_s *group, * Parameters: * None. * - * Return Value: + * Returned Value: * None. * * Assumptions: @@ -176,7 +176,7 @@ void task_initialize(void) * Parameters: * None. * - * Return Value: + * Returned Value: * On success, a non-NULL pointer to a child status structure. NULL is * returned if there are no remaining, pre-allocated child status structures. * @@ -211,7 +211,7 @@ FAR struct child_status_s *group_allocchild(void) * Parameters: * status - The child status structure to be freed. * - * Return Value: + * Returned Value: * None. * * Assumptions: @@ -241,7 +241,7 @@ void group_freechild(FAR struct child_status_s *child) * group - The task group for the child status. * child - The structure to be added * - * Return Value: + * Returned Value: * N * * Assumptions: @@ -273,7 +273,7 @@ void group_addchild(FAR struct task_group_s *group, * group - The ID of the parent task group to containing the child status. * pid - The ID of the child to find. * - * Return Value: + * Returned Value: * On success, a non-NULL pointer to a child status structure. NULL is * returned if there is child status structure for that pid in the TCB. * @@ -312,7 +312,7 @@ FAR struct child_status_s *group_findchild(FAR struct task_group_s *group, * Parameters: * tcb - The TCB of the parent task to containing the child status. * - * Return Value: + * Returned Value: * On success, a non-NULL pointer to a child status structure for the * exited child. NULL is returned if not child has exited. * @@ -351,7 +351,7 @@ FAR struct child_status_s *group_exitchild(FAR struct task_group_s *group) * group - The task group containing the child status. * pid - The ID of the child to find. * - * Return Value: + * Returned Value: * On success, a non-NULL pointer to a child status structure. NULL is * returned if there is child status structure for that pid in the TCB. * @@ -412,7 +412,7 @@ FAR struct child_status_s *group_removechild(FAR struct task_group_s *group, * Parameters: * group - The task group containing the child status. * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 0cb29b4e2e2b0a7203b11116d7516ebe28f0ee6b..29ca989ca6f46643c08b55480038b7a47c9b5394 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -92,7 +92,7 @@ FAR struct task_group_s *g_grouphead; * Parameters: * tcb - The tcb in need of the task group. * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -165,7 +165,7 @@ static void group_assigngid(FAR struct task_group_s *group) * tcb - The tcb in need of the task group. * ttype - Type of the thread that is the parent of the group * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * * Assumptions: @@ -274,7 +274,7 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) * Parameters: * tcb - The tcb in need of the task group. * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * * Assumptions: diff --git a/sched/group/group_find.c b/sched/group/group_find.c index 3db582fa25157337aa1fc76cb9063275d491f390..ade869dd013d6d1e659b51c27d96c633d6149044 100644 --- a/sched/group/group_find.c +++ b/sched/group/group_find.c @@ -68,7 +68,7 @@ * Parameters: * gid - The group ID to find. * - * Return Value: + * Returned Value: * On success, a pointer to the group task structure is returned. This * function can fail only if there is no group that corresponds to the * group ID. @@ -114,7 +114,7 @@ FAR struct task_group_s *group_findbygid(gid_t gid) * Parameters: * pid - The task ID of the main task thread. * - * Return Value: + * Returned Value: * On success, a pointer to the group task structure is returned. This * function can fail only if there is no group that corresponds to the * task ID. diff --git a/sched/group/group_foreachchild.c b/sched/group/group_foreachchild.c index 10fed5f90a5bb0d7209b34fc6e955ce59df4e6fc..5908d6a121be31f31bfe04ca9a7ead7ebc6d62de 100644 --- a/sched/group/group_foreachchild.c +++ b/sched/group/group_foreachchild.c @@ -60,7 +60,7 @@ * handler - The function to be called * arg - An additional argument to provide to the handler * - * Return Value: + * Returned Value: * Success (OK) is always returned unless the handler returns a non-zero * value (a negated errno on errors). In that case, the traversal * terminates and that non-zero value is returned. diff --git a/sched/group/group_join.c b/sched/group/group_join.c index 7fb2a817fa9f451ac018b893b557198f476638dd..1bb2fdfdeb1354ca6b432ebc652c3d7e9acf03f1 100644 --- a/sched/group/group_join.c +++ b/sched/group/group_join.c @@ -74,7 +74,7 @@ * group - The task group to add the new member * pid - The new member * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * * Assumptions: @@ -152,7 +152,7 @@ static inline int group_addmember(FAR struct task_group_s *group, pid_t pid) * Parameters: * tcb - The TCB of the new "child" task that need to join the group. * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * * Assumptions: @@ -189,7 +189,7 @@ int group_bind(FAR struct pthread_tcb_s *tcb) * Parameters: * tcb - The TCB of the new "child" task that need to join the group. * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * * Assumptions: diff --git a/sched/group/group_killchildren.c b/sched/group/group_killchildren.c index 3b719a495c762ca3c35884aa821226feff5c70fc..aa4ae077b7d06ff883a7dc9fb3e148c9dc63e574 100644 --- a/sched/group/group_killchildren.c +++ b/sched/group/group_killchildren.c @@ -59,7 +59,7 @@ * pid - The ID of the group member that may be signalled. * arg - The PID of the thread to be retained. * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * ****************************************************************************/ @@ -95,7 +95,7 @@ static int group_killchildren_handler(pid_t pid, FAR void *arg) * Parameters: * tcb - TCB of the task to be retained. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c index 79a1bde1a103dca5fc8c6dfa0a394a65c5cae659..e20bb3bdd7c5b89128eff2197e4f6c8178ce23fc 100644 --- a/sched/group/group_leave.c +++ b/sched/group/group_leave.c @@ -70,7 +70,7 @@ * Parameters: * group - The group to be removed. * - * Return Value: + * Returned Value: * None. * * Assumptions: @@ -129,7 +129,7 @@ static void group_remove(FAR struct task_group_s *group) * Parameters: * group - The group to be removed. * - * Return Value: + * Returned Value: * None. * * Assumptions: @@ -289,7 +289,7 @@ static inline void group_release(FAR struct task_group_s *group) * group - The group from which to remove the member. * pid - The member to be removed. * - * Return Value: + * Returned Value: * On success, returns the number of members remaining in the group (>=0). * Can fail only if the member is not found in the group. On failure, * returns -ENOENT @@ -346,7 +346,7 @@ static inline void group_removemember(FAR struct task_group_s *group, pid_t pid) * Parameters: * tcb - The TCB of the task that is exiting. * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/group/group_setupidlefiles.c b/sched/group/group_setupidlefiles.c index 0d4eb19ca29410a0e8ced572f04bf5cd502062d4..076017360d4feae83cf9952c9295243c6ec28e25 100644 --- a/sched/group/group_setupidlefiles.c +++ b/sched/group/group_setupidlefiles.c @@ -66,7 +66,7 @@ * Parameters: * tcb - tcb of the idle task. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/group/group_setuptaskfiles.c b/sched/group/group_setuptaskfiles.c index e1068712507d2ff90c89d531b8850ca901fae16c..1a1ec07963b09b36df7aeaa4c8926d5e78c5175f 100644 --- a/sched/group/group_setuptaskfiles.c +++ b/sched/group/group_setuptaskfiles.c @@ -79,7 +79,7 @@ * Input Parameters: * tcb - tcb of the new task. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -137,7 +137,7 @@ static inline void sched_dupfiles(FAR struct task_tcb_s *tcb) * Input Parameters: * tcb - tcb of the new task. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -198,7 +198,7 @@ static inline void sched_dupsockets(FAR struct task_tcb_s *tcb) * Parameters: * tcb - tcb of the new task. * - * Return Value: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned on * failure. * diff --git a/sched/group/group_signal.c b/sched/group/group_signal.c index f066fc7f5d71b58bc487ecf60ce50299d4ee0156..e0de4bcf648c83aca638d18a84c540b37e5d025d 100644 --- a/sched/group/group_signal.c +++ b/sched/group/group_signal.c @@ -80,7 +80,7 @@ struct group_signal_s * pid - The ID of the group member that may be signalled. * arg - A pointer to a struct group_signal_s instance. * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * ****************************************************************************/ @@ -195,7 +195,7 @@ static int group_signal_handler(pid_t pid, FAR void *arg) * Parameters: * group - The task group that needs to be signalled. * - * Return Value: + * Returned Value: * 0 (OK) on success; a negated errno value on failure. * * Assumptions: diff --git a/sched/init/init.h b/sched/init/init.h index 4724c83392f37335e1184574f7c9dd11b4ea558b..b602786bc4fc55da4f34d51dbe4f767e8ad45a4b 100644 --- a/sched/init/init.h +++ b/sched/init/init.h @@ -57,7 +57,7 @@ * Input Parameters: * None * - * Returned value: + * Returned Value: * Does not return. * ****************************************************************************/ diff --git a/sched/init/os_bringup.c b/sched/init/os_bringup.c index f2028fc45ff79e710bb8aca8a2dc883491093c8d..316809654c19e94a5bfb2aebd6648354629925b9 100644 --- a/sched/init/os_bringup.c +++ b/sched/init/os_bringup.c @@ -257,16 +257,17 @@ static inline void os_do_appstart(void) #ifdef CONFIG_BUILD_PROTECTED DEBUGASSERT(USERSPACE->us_entrypoint != NULL); - pid = task_create("init", SCHED_PRIORITY_DEFAULT, - CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint, - (FAR char * const *)NULL); + pid = nxtask_create("init", SCHED_PRIORITY_DEFAULT, + CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint, + (FAR char * const *)NULL); #else - pid = task_create("init", SCHED_PRIORITY_DEFAULT, - CONFIG_USERMAIN_STACKSIZE, - (main_t)CONFIG_USER_ENTRYPOINT, - (FAR char * const *)NULL); + pid = nxtask_create("init", SCHED_PRIORITY_DEFAULT, + CONFIG_USERMAIN_STACKSIZE, + (main_t)CONFIG_USER_ENTRYPOINT, + (FAR char * const *)NULL); #endif - ASSERT(pid > 0); + DEBUGASSERT(pid > 0); + UNUSED(pid); } #elif defined(CONFIG_INIT_FILEPATH) @@ -357,8 +358,8 @@ static inline void os_start_application(void) pid = kthread_create("AppBringUp", CONFIG_BOARD_INITTHREAD_PRIORITY, CONFIG_BOARD_INITTHREAD_STACKSIZE, (main_t)os_start_task, (FAR char * const *)NULL); - ASSERT(pid > 0); - + DEBUGASSERT(pid > 0); + UNUSED(pid); #else /* Do the board/application initialization on this thread of execution. */ diff --git a/sched/init/os_start.c b/sched/init/os_start.c index 80fc944956e2d2eb7f74f9dc10fa8b2a914e8605..0fcbd4ba48ce81d1e79e7771a57ea336ec68c23d 100644 --- a/sched/init/os_start.c +++ b/sched/init/os_start.c @@ -115,7 +115,7 @@ volatile dq_queue_t g_readytorun; * and * - Tasks/threads that have not been assigned to a CPU. * - * Otherwise, the TCB will be reatined in an assigned task list, + * Otherwise, the TCB will be retained in an assigned task list, * g_assignedtasks. As its name suggests, on 'g_assignedtasks queue for CPU * 'n' would contain only tasks/threads that are assigned to CPU 'n'. Tasks/ * threads would be assigned a particular CPU by one of two mechanisms: @@ -187,7 +187,7 @@ volatile dq_queue_t g_waitingforfill; volatile dq_queue_t g_inactivetasks; -/* These are lists of dayed memory deallocations that need to be handled +/* These are lists of delayed memory deallocations that need to be handled * within the IDLE loop or worker thread. These deallocations get queued * by sched_kufree and sched_kfree() if the OS needs to deallocate memory * while it is within an interrupt handler. @@ -229,7 +229,7 @@ struct pidhash_s g_pidhash[CONFIG_MAX_TASKS]; /* This is a table of task lists. This table is indexed by the task stat * enumeration type (tstate_t) and provides a pointer to the associated * static task list (if there is one) as well as a a set of attribute flags - * indicating properities of the list, for example, if the list is an + * indicating properties of the list, for example, if the list is an * ordered list or not. */ @@ -311,7 +311,7 @@ uint8_t g_os_initstate; /* See enum os_initstate_e */ /**************************************************************************** * Private Data ****************************************************************************/ -/* This is an arry of task control block (TCB) for the IDLE thread of each +/* This is an array of task control block (TCB) for the IDLE thread of each * CPU. For the non-SMP case, this is a a single TCB; For the SMP case, * there is one TCB per CPU. NOTE: The system boots on CPU0 into the IDLE * task. The IDLE task later starts the other CPUs and spawns the user @@ -361,7 +361,7 @@ static FAR char *g_idleargv[1][2]; * Input Parameters: * None * - * Returned value: + * Returned Value: * Does not return. * ****************************************************************************/ diff --git a/sched/irq/Make.defs b/sched/irq/Make.defs index 72636e3ea20aaeb547188fb54234d4742a65383e..a7223c9d29985bf2f45d75d77c3930eacd10140d 100644 --- a/sched/irq/Make.defs +++ b/sched/irq/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # sched/irq/Make.defs # -# Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. +# Copyright (C) 2014, 2016, 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -38,12 +38,21 @@ CSRCS += irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c ifeq ($(CONFIG_SMP),y) CSRCS += irq_csection.c ifeq ($(CONFIG_SPINLOCK_IRQ),y) +ifeq ($(CONFIG_ARCH_GLOBAL_IRQDISABLE),y) CSRCS += irq_spinlock.c endif +endif else ifeq ($(CONFIG_SCHED_INSTRUMENTATION_CSECTION),y) CSRCS += irq_csection.c endif +ifeq ($(CONFIG_SCHED_IRQMONITOR),y) +CSRCS += irq_foreach.c +ifeq ($(CONFIG_FS_PROCFS),y) +CSRCS += irq_procfs.c +endif +endif + # Include irq build support DEPPATH += --dep-path irq diff --git a/sched/irq/irq.h b/sched/irq/irq.h index ffb6e9859aa0b2ebe406d313220f78d7170f9559..a51455f17506f8cfb56b8793832a3ecd2befb5cf 100644 --- a/sched/irq/irq.h +++ b/sched/irq/irq.h @@ -1,7 +1,8 @@ /**************************************************************************** * sched/irq/irq.h * - * Copyright (C) 2007, 2008, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -71,10 +72,26 @@ struct irq_info_s { - xcpt_t handler; /* Address of the interrupt handler */ - FAR void *arg; /* The argument provided to the interrupt handler. */ + xcpt_t handler; /* Address of the interrupt handler */ + FAR void *arg; /* The argument provided to the interrupt handler. */ +#ifdef CONFIG_SCHED_IRQMONITOR + systime_t start; /* Time interrupt attached */ +#ifdef CONFIG_HAVE_LONG_LONG + uint64_t count; /* Number of interrupts on this IRQ */ +#else + uint32_t mscount; /* Number of interrupts on this IRQ (MS) */ + uint32_t lscount; /* Number of interrupts on this IRQ (LS) */ +#endif +#endif }; +#ifdef CONFIG_SCHED_IRQMONITOR +/* This is the type of the callback from irq_foreach(). */ + +typedef CODE int (*irq_foreach_t)(int irq, FAR struct irq_info_s *info, + FAR void *arg); +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -163,10 +180,10 @@ int irq_unexpected_isr(int irq, FAR void *context, FAR void *arg); * the IRQ lock is also set UNLESS the CPU starting the task is the * holder of the IRQ lock. * - * Inputs: + * Input Parameters: * rtcb - Points to the blocked TCB that is ready-to-run * - * Return Value: + * Returned Value: * true - IRQs are locked by a different CPU. * false - IRQs are unlocked OR if they are locked BUT this CPU * is the holder of the lock. @@ -180,6 +197,36 @@ int irq_unexpected_isr(int irq, FAR void *context, FAR void *arg); bool irq_cpu_locked(int cpu); #endif +/**************************************************************************** + * Name: irq_foreach + * + * Description: + * This function traverses the internal list of interrupts and provides + * information about each attached interrupt. + * + * Some caution may be necessary: If interrupts are disabled then the + * counts may change during the traversal. If pre-emption is enabled, then + * the traversed sequence may be widely separated in time. + * + * Input Parameters: + * callback - This function will be called for each attached interrupt + * along with the IRQ number, an instance of struct irq_info_s, + * and the caller provided argument + * args - This is an opaque argument provided with each call to the + * callback function. + * + * Returned Value: + * Zero (OK) is returned after callback has been invoked for all of + * the attached interrupts. The callback function may terminate the + * traversal at any time by returning a non-zero value. In that case, + * irq_foreach will return that non-zero value. + * + ****************************************************************************/ + +#ifdef CONFIG_SCHED_IRQMONITOR +int irq_foreach(irq_foreach_t callback, FAR void *arg); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/sched/irq/irq_attach.c b/sched/irq/irq_attach.c index a55ba758e6057789b322476ddba4987caa61db2c..da03f09427541e4789c3d4204bec38d726c9d209 100644 --- a/sched/irq/irq_attach.c +++ b/sched/irq/irq_attach.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/irq/irq_attach.c * - * Copyright (C) 2007-2008, 2010, 2012, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2008, 2010, 2012, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -115,6 +116,15 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg) g_irqvector[ndx].handler = isr; g_irqvector[ndx].arg = arg; +#ifdef CONFIG_SCHED_IRQMONITOR + g_irqvector[ndx].start = clock_systimer(); +#ifdef CONFIG_HAVE_LONG_LONG + g_irqvector[ndx].count = 0; +#else + g_irqvector[ndx].mscount = 0; + g_irqvector[ndx].lscount = 0; +#endif +#endif leave_critical_section(flags); ret = OK; diff --git a/sched/irq/irq_csection.c b/sched/irq/irq_csection.c index cfba38111e7df7ffd021694bdc82a706dcb05fa8..9d7943cbf670f77076e528c545d8ba5d53cb411d 100644 --- a/sched/irq/irq_csection.c +++ b/sched/irq/irq_csection.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/irq/irq_csection.c * - * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ volatile uint8_t g_cpu_nestcount[CONFIG_SMP_NCPUS]; * spinlock. * - Another task on CPUm attempts to enter the critical section but has * to wait, spinning to get g_cpu_irqlock with interrupts disabled. - * - The task on CPUn causes a new task to become ready-torun and the + * - The task on CPUn causes a new task to become ready-to-run and the * scheduler selects CPUm. CPUm is requested to pause via a pause * interrupt. * - But the task on CPUm is also attempting to enter the critical @@ -123,7 +123,7 @@ volatile uint8_t g_cpu_nestcount[CONFIG_SMP_NCPUS]; static inline bool irq_waitlock(int cpu) { #ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS - FAR struct tcb_s *tcb = this_task(); + FAR struct tcb_s *tcb = current_task(cpu); /* Notify that we are waiting for a spinlock */ @@ -309,11 +309,16 @@ try_again: else { /* Normal tasking environment. */ - /* Do we already have interrupts disabled? */ + /* Get the TCB of the currently executing task on this CPU (avoid + * using this_task() which can recurse. + */ - rtcb = this_task(); + cpu = this_cpu(); + rtcb = current_task(cpu); DEBUGASSERT(rtcb != NULL); + /* Do we already have interrupts disabled? */ + if (rtcb->irqcount > 0) { /* Yes... make sure that the spinlock is set and increment the @@ -337,7 +342,6 @@ try_again: * the spinlock. */ - cpu = this_cpu(); DEBUGASSERT((g_cpu_irqset & (1 << cpu)) == 0); if (!irq_waitlock(cpu)) @@ -463,7 +467,7 @@ void leave_critical_section(irqstate_t flags) DEBUGASSERT(spin_islocked(&g_cpu_irqlock) && g_cpu_nestcount[cpu] == 1); - FAR struct tcb_s *rtcb = this_task(); + FAR struct tcb_s *rtcb = current_task(cpu); DEBUGASSERT(rtcb != NULL); if (rtcb->irqcount <= 0) @@ -477,7 +481,14 @@ void leave_critical_section(irqstate_t flags) } else { - FAR struct tcb_s *rtcb = this_task(); + FAR struct tcb_s *rtcb; + + /* Get the TCB of the currently executing task on this CPU (avoid + * using this_task() which can recurse. + */ + + cpu = this_cpu(); + rtcb = current_task(cpu); DEBUGASSERT(rtcb != NULL && rtcb->irqcount > 0); /* Normal tasking context. We need to coordinate with other @@ -505,7 +516,6 @@ void leave_critical_section(irqstate_t flags) * released, then unlock the spinlock. */ - cpu = this_cpu(); DEBUGASSERT(spin_islocked(&g_cpu_irqlock) && (g_cpu_irqset & (1 << cpu)) != 0); @@ -521,8 +531,7 @@ void leave_critical_section(irqstate_t flags) * because we were within a critical section then. */ - if (g_pendingtasks.head != NULL && - !spin_islocked(&g_cpu_schedlock)) + if (g_pendingtasks.head != NULL && !sched_islocked_global()) { /* Release any ready-to-run tasks that have collected * in g_pendingtasks. NOTE: This operation has a very @@ -587,10 +596,10 @@ void leave_critical_section(irqstate_t flags) * the IRQ lock is also set UNLESS the CPU starting the task is the * holder of the IRQ lock. * - * Inputs: + * Input Parameters: * rtcb - Points to the blocked TCB that is ready-to-run * - * Return Value: + * Returned Value: * true - IRQs are locked by a different CPU. * false - IRQs are unlocked OR if they are locked BUT this CPU * is the holder of the lock. @@ -616,6 +625,15 @@ bool irq_cpu_locked(int cpu) return false; } +#if defined(CONFIG_ARCH_HAVE_FETCHADD) && !defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + /* If the global lockcount has been incremented then simply return true */ + + if (g_global_lockcount > 0) + { + return true; + } +#endif + /* Test if g_cpu_irqlock is locked. We don't really need to use check * g_cpu_irqlock to do this, we can use the g_cpu_set. * @@ -641,7 +659,7 @@ bool irq_cpu_locked(int cpu) { /* In this case g_cpu_irqlock should be unlocked. However, if * the lock was established in the interrupt handler AND there are - * no bits set in g_cpu_irqset, that probabaly means only that + * no bits set in g_cpu_irqset, that probably means only that * critical section was established from an interrupt handler. * Return false in either case. */ diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index b311e8a2c118236514d4127e3dc2ba924d0fef90..ef78824213fb766fe34b9fe3a4110bddac25ccb8 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/irq/irq_dispatch.c * - * Copyright (C) 2007, 2008, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,33 @@ #include "irq/irq.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_SCHED_IRQMONITOR +# ifdef CONFIG_HAVE_LONG_LONG +# define INCR_COUNT(ndx) \ + do \ + { \ + g_irqvector[ndx].count++; \ + } \ + while (0) +# else +# define INCR_COUNT(ndx) \ + do \ + { \ + if (++g_irqvector[ndx].lscount == 0) \ + { \ + g_irqvector[ndx].mscount++; \ + } \ + } \ + while (0) +# endif +#else +# define INCR_COUNT(ndx) +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -86,13 +113,14 @@ void irq_dispatch(int irq, FAR void *context) { vector = g_irqvector[ndx].handler; arg = g_irqvector[ndx].arg; + INCR_COUNT(ndx); } #else vector = g_irqvector[irq].handler; arg = g_irqvector[irq].arg; + INCR_COUNT(irq); #endif } - #else vector = irq_unexpected_isr; arg = NULL; diff --git a/sched/irq/irq_foreach.c b/sched/irq/irq_foreach.c new file mode 100644 index 0000000000000000000000000000000000000000..731fcf706f5e52317f3384987a8d0fc963a76dc1 --- /dev/null +++ b/sched/irq/irq_foreach.c @@ -0,0 +1,118 @@ +/**************************************************************************** + * sched/irq/irq_foreach.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include "irq/irq.h" + +#ifdef CONFIG_SCHED_IRQMONITOR + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* This is the number of entries in the interrupt vector table */ + +#ifdef CONFIG_ARCH_MINIMAL_VECTORTABLE +# define TAB_SIZE CONFIG_ARCH_NUSER_INTERRUPTS +#else +# define TAB_SIZE NR_IRQS +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: irq_foreach + * + * Description: + * This function traverses the internal list of interrupts and provides + * information about each attached interrupt. + * + * Some caution may be necessary: If interrupts are disabled then the + * counts may change during the traversal. If pre-emption is enabled, then + * the traversed sequence may be widely separated in time. + * + * Input Parameters: + * callback - This function will be called for each attached interrupt + * along with the IRQ number, an instance of struct irq_info_s, + * and the caller provided argument + * args - This is an opaque argument provided with each call to the + * callback function. + * + * Returned Value: + * Zero (OK) is returned after callback has been invoked for all of + * the attached interrupts. The callback function may terminate the + * traversal at any time by returning a non-zero value. In that case, + * irq_foreach will return that non-zero value. + * + ****************************************************************************/ + +int irq_foreach(irq_foreach_t callback, FAR void *arg) +{ + int irq; + int ret; + + DEBUGASSERT(callback != NULL); + + /* Visit each interrupt in the interrupt table */ + + for (irq = 0; irq < TAB_SIZE; irq++) + { + if (g_irqvector[irq].handler != NULL && + g_irqvector[irq].handler != irq_unexpected_isr) + { + ret = callback(irq, &g_irqvector[irq], arg); + if (ret != 0) + { + return ret; + } + } + } + + return OK; +} + +#endif /* CONFIG_SCHED_IRQMONITOR */ diff --git a/sched/irq/irq_initialize.c b/sched/irq/irq_initialize.c index 18bbafc4b37ad6a955e86d120b268245534a0eb4..b2355f9a90d1dd125ea2aa858d517c4e91548a8d 100644 --- a/sched/irq/irq_initialize.c +++ b/sched/irq/irq_initialize.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/irq/irq_initialize.c * - * Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2008, 2010, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -89,5 +89,14 @@ void irq_initialize(void) { g_irqvector[i].handler = irq_unexpected_isr; g_irqvector[i].arg = NULL; +#ifdef CONFIG_SCHED_IRQMONITOR + g_irqvector[i].start = 0; +#ifdef CONFIG_HAVE_LONG_LONG + g_irqvector[i].count = 0; +#else + g_irqvector[i].mscount = 0; + g_irqvector[i].lscount = 0; +#endif +#endif } } diff --git a/sched/irq/irq_procfs.c b/sched/irq/irq_procfs.c new file mode 100644 index 0000000000000000000000000000000000000000..1c20b0e4aa8834b784207cf811b1f9174373f0b9 --- /dev/null +++ b/sched/irq/irq_procfs.c @@ -0,0 +1,456 @@ +/**************************************************************************** + * sched/irq/irq_procfs.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "irq/irq.h" + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) +#ifdef CONFIG_SCHED_IRQMONITOR + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Output format: + * + * 11111111112222222222333333333344 + * 12345678901234567890123456789012345678901 + * + * IRQ HANDLER ARGUMENT COUNT RATE + * DDD XXXXXXXX XXXXXXXX DDDDDDDDDD DDDD.DDD + * + * NOTE: This assumes that an address can be represented in 32-bits. In + * the typical configuration where CONFIG_HAVE_LONG_LONG=y, the COUNT field + * may not be wide enough. + */ + +#define HDR_FMT "IRQ HANDLER ARGUMENT COUNT RATE\n" +#define IRQ_FMT "%3u %08lx %08lx %10lu %4lu.%03lu\n" + +/* Determines the size of an intermediate buffer that must be large enough + * to handle the longest line generated by this logic (plus a couple of + * bytes). + */ + +#define IRQ_LINELEN 44 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* This structure describes one open "file" */ + +struct irq_file_s +{ + struct procfs_file_s base; /* Base open file structure */ + FAR char *buffer; /* User provided buffer */ + size_t remaining; /* Number of available characters in buffer */ + size_t ncopied; /* Number of characters in buffer */ + off_t offset; /* Current file offset */ + char line[IRQ_LINELEN]; /* Pre-allocated buffer for formatted lines */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* irq_foreach() callback function */ + +static int irq_callback(int irq, FAR struct irq_info_s *info, + FAR void *arg); + +/* File system methods */ + +static int irq_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode); +static int irq_close(FAR struct file *filep); +static ssize_t irq_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static int irq_dup(FAR const struct file *oldp, + FAR struct file *newp); +static int irq_stat(FAR const char *relpath, FAR struct stat *buf); + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* See fs_mount.c -- this structure is explicitly extern'ed there. + * We use the old-fashioned kind of initializers so that this will compile + * with any compiler. + */ + +const struct procfs_operations irq_operations = +{ + irq_open, /* open */ + irq_close, /* close */ + irq_read, /* read */ + NULL, /* write */ + + irq_dup, /* dup */ + + NULL, /* opendir */ + NULL, /* closedir */ + NULL, /* readdir */ + NULL, /* rewinddir */ + + irq_stat /* stat */ +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: irq_callback + ****************************************************************************/ + +static int irq_callback(int irq, FAR struct irq_info_s *info, + FAR void *arg) +{ + FAR struct irq_file_s *irqfile = (FAR struct irq_file_s *)arg; + struct irq_info_s copy; + irqstate_t flags; + systime_t elapsed; + systime_t now; + size_t linesize; + size_t copysize; + unsigned long intpart; + unsigned long fracpart; + unsigned long count; + + DEBUGASSERT(irqfile != NULL); + + /* Take a snapshot and reset the counts */ + + flags = enter_critical_section(); + memcpy(©, info, sizeof(struct irq_info_s)); + now = clock_systimer(); + info->start = now; +#ifdef CONFIG_HAVE_LONG_LONG + info->count = 0; +#else + info->mscount = 0; + info->lscount = 0; +#endif + leave_critical_section(flags); + + /* Don't bother if count == 0. + * + * REVISIT: There is a logic problem with skipping if the count is zero. + * Normally this is a good thing because it makes the output concise. + * However, it can be a problem under certain conditions: + * + * It may take multiple passes through the IRQ table to enumerate the + * interrupts if the number of interrupts reported is large or if the size + * of the user buffer is small. If a count is zero it will be skipped on + * the first time through but if it becomes non-zero on the second time + * through, the output will be corrupted. Similarly if the count is non- + * zero the first time through and zero the second. + * + * A proper fix would require keep better track of where we left off + * between passes. Current that position is remembered only by the + * byte offset into the pseudo-file, f_pos. + */ + + if (copy.count == 0) + { + return 0; + } + + /* Calculate the interrupt rate from the interrupt count and the elapsed + * time. + * + * REVISIT: If these counts have not been samples and reset in a long time + * then the following will likely overflow. + */ + + elapsed = now - copy.start; + +#ifdef CONFIG_HAVE_LONG_LONG + /* elapsed = - , units=clock ticks + * rate = * TICKS_PER_SEC / elapsed + */ + + intpart = (unsigned int)((copy.count * TICK_PER_SEC) / elapsed); + if (intpart >= 10000) + { + intpart = 9999; + fracpart = 999; + } + else + { + uint64_t intcount = ((uint64_t)intpart * elapsed) / TICK_PER_SEC; + fracpart = (unsigned int) + (((copy.count - intcount) * TICK_PER_SEC * 1000) / elapsed); + } + + /* Make sure that the count is representable with snprintf format */ + + if (copy.count > ULONG_MAX) + { + count = ULONG_MAX; + } + else + { + count = (unsigned long)copy.count; + } +#else +# error Missing logic +#endif + + /* Output information about this interrupt */ + + linesize = snprintf(irqfile->line, IRQ_LINELEN, IRQ_FMT, + (unsigned int)irq, + (unsigned long)((uintptr_t)copy.handler), + (unsigned long)((uintptr_t)copy.arg), + count, intpart, fracpart); + + copysize = procfs_memcpy(irqfile->line, linesize, irqfile->buffer, + irqfile->remaining, &irqfile->offset); + + irqfile->ncopied += copysize; + irqfile->buffer += copysize; + irqfile->remaining -= copysize; + + /* Return a non-zero value to stop the traversal if the user-provided + * buffer is full. + */ + + if (irqfile->remaining > 0) + { + return 0; + } + else + { + return 1; + } +} + +/**************************************************************************** + * Name: irq_open + ****************************************************************************/ + +static int irq_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode) +{ + FAR struct irq_file_s *irqfile; + + finfo("Open '%s'\n", relpath); + + /* This PROCFS file is read-only. Any attempt to open with write access + * is not permitted. + */ + + if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) + { + ferr("ERROR: Only O_RDONLY supported\n"); + return -EACCES; + } + + /* "irqs" is the only acceptable value for the relpath */ + + if (strcmp(relpath, "irqs") != 0) + { + ferr("ERROR: relpath is '%s'\n", relpath); + return -ENOENT; + } + + /* Allocate a container to hold the file attributes */ + + irqfile = (FAR struct irq_file_s *)kmm_zalloc(sizeof(struct irq_file_s)); + if (!irqfile) + { + ferr("ERROR: Failed to allocate file attributes\n"); + return -ENOMEM; + } + + /* Save the attributes as the open-specific state in filep->f_priv */ + + filep->f_priv = (FAR void *)irqfile; + return OK; +} + +/**************************************************************************** + * Name: irq_close + ****************************************************************************/ + +static int irq_close(FAR struct file *filep) +{ + FAR struct irq_file_s *irqfile; + + /* Recover our private data from the struct file instance */ + + irqfile = (FAR struct irq_file_s *)filep->f_priv; + DEBUGASSERT(irqfile); + + /* Release the file attributes structure */ + + kmm_free(irqfile); + filep->f_priv = NULL; + return OK; +} + +/**************************************************************************** + * Name: irq_read + ****************************************************************************/ + +static ssize_t irq_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) +{ + FAR struct irq_file_s *irqfile; + size_t linesize; + size_t copysize; + + finfo("buffer=%p buflen=%d\n", buffer, (int)buflen); + + /* Recover our private data from the struct file instance */ + + irqfile = (FAR struct irq_file_s *)filep->f_priv; + DEBUGASSERT(irqfile); + + /* Save the file offset and the user buffer information */ + + irqfile->offset = filep->f_pos; + irqfile->buffer = buffer; + irqfile->remaining = buflen; + + /* The first line to output is the header */ + + linesize = snprintf(irqfile->line, IRQ_LINELEN, HDR_FMT); + + copysize = procfs_memcpy(irqfile->line, linesize, irqfile->buffer, + irqfile->remaining, &irqfile->offset); + + irqfile->ncopied = copysize; + irqfile->buffer += copysize; + irqfile->remaining -= copysize; + + /* Now traverse the list of attached interrupts, generating output for + * each. + */ + + (void)irq_foreach(irq_callback, (FAR void *)irqfile); + + /* Update the file position */ + + filep->f_pos += irqfile->ncopied; + return irqfile->ncopied; +} + +/**************************************************************************** + * Name: irq_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int irq_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + FAR struct irq_file_s *oldattr; + FAR struct irq_file_s *newattr; + + finfo("Dup %p->%p\n", oldp, newp); + + /* Recover our private data from the old struct file instance */ + + oldattr = (FAR struct irq_file_s *)oldp->f_priv; + DEBUGASSERT(oldattr); + + /* Allocate a new container to hold the task and attribute selection */ + + newattr = (FAR struct irq_file_s *)kmm_malloc(sizeof(struct irq_file_s)); + if (!newattr) + { + ferr("ERROR: Failed to allocate file attributes\n"); + return -ENOMEM; + } + + /* The copy the file attributes from the old attributes to the new */ + + memcpy(newattr, oldattr, sizeof(struct irq_file_s)); + + /* Save the new attributes in the new file structure */ + + newp->f_priv = (FAR void *)newattr; + return OK; +} + +/**************************************************************************** + * Name: irq_stat + * + * Description: Return information about a file or directory + * + ****************************************************************************/ + +static int irq_stat(const char *relpath, struct stat *buf) +{ + /* "irqs" is the only acceptable value for the relpath */ + + if (strcmp(relpath, "irqs") != 0) + { + ferr("ERROR: relpath is '%s'\n", relpath); + return -ENOENT; + } + + /* "irqs" is the name for a read-only file */ + + memset(buf, 0, sizeof(struct stat)); + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#endif /* CONFIG_SCHED_IRQMONITOR */ +#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS */ diff --git a/sched/irq/irq_spinlock.c b/sched/irq/irq_spinlock.c index a6f1ee97d18df4f1bc4018ce6400daa9f24dc937..c0303be1198a6a18e4e80766efaea5f10fafa19d 100644 --- a/sched/irq/irq_spinlock.c +++ b/sched/irq/irq_spinlock.c @@ -45,6 +45,9 @@ #include "sched/sched.h" +#if defined(CONFIG_SMP) && defined (CONFIG_SPINLOCK_IRQ) && \ + defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + /**************************************************************************** * Public Data ****************************************************************************/ @@ -138,3 +141,5 @@ void spin_unlock_irqrestore(irqstate_t flags) up_irq_restore(flags); } + +#endif /* CONFIG_SMP && CONFIG_SPINLOCK_IRQ && CONFIG_ARCH_GLOBAL_IRQDISABLE */ diff --git a/sched/module/mod_procfs.c b/sched/module/mod_procfs.c index d900165c9988e8fab4747d0545d00917ce67c04c..c658189604a18a68284e3c8b18427256d7f77c0d 100644 --- a/sched/module/mod_procfs.c +++ b/sched/module/mod_procfs.c @@ -286,7 +286,7 @@ static int modprocfs_dup(FAR const struct file *oldp, FAR struct file *newp) return -ENOMEM; } - /* The copy the file attribtes from the old attributes to the new */ + /* The copy the file attributes from the old attributes to the new */ memcpy(newpriv, oldpriv, sizeof(struct modprocfs_file_s)); diff --git a/sched/mqueue/mq_desclose.c b/sched/mqueue/mq_desclose.c index b4c72c0e961f837205cfa57c5d276ef844f14f2c..c4a5d68f52e55d6190c6bf0bd875bcbf59797c54 100644 --- a/sched/mqueue/mq_desclose.c +++ b/sched/mqueue/mq_desclose.c @@ -60,7 +60,7 @@ * Description: * Deallocate a message queue descriptor but returning it to the free list * - * Inputs: + * Input Parameters: * mqdes - message queue descriptor to free * ****************************************************************************/ @@ -82,7 +82,7 @@ * mqdes - Message queue descriptor. * group - Group that has the open descriptor. * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/mqueue/mq_descreate.c b/sched/mqueue/mq_descreate.c index d3b574f6234f8a2266447cd3802de5c6529bb2a0..47dad5bd3bc32dc09f7028a72b6a0801d46d86f7 100644 --- a/sched/mqueue/mq_descreate.c +++ b/sched/mqueue/mq_descreate.c @@ -67,10 +67,10 @@ * Description: * Allocate a message queue descriptor. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * Reference to the allocated mq descriptor. * ****************************************************************************/ @@ -109,12 +109,12 @@ static mqd_t nxmq_alloc_des(void) * Description: * Create a message queue descriptor for the specified TCB * - * Inputs: + * Input Parameters: * mtcb - task that needs the descriptor. * msgq - Named message queue containing the message * oflags - access rights for the descriptor * - * Return Value: + * Returned Value: * On success, the message queue descriptor is returned. NULL is returned * on a failure to allocate. * diff --git a/sched/mqueue/mq_getattr.c b/sched/mqueue/mq_getattr.c index b1475b6846212fea50f4374c50a1e96e678bdbe6..2bcf0902a700c642c46f69e3fa7b622541b65ce7 100644 --- a/sched/mqueue/mq_getattr.c +++ b/sched/mqueue/mq_getattr.c @@ -57,7 +57,7 @@ * mqdes - Message queue descriptor * mq_stat - Buffer in which to return attributes * - * Return Value: + * Returned Value: * 0 (OK) if attributes provided, -1 (ERROR) otherwise. * * Assumptions: diff --git a/sched/mqueue/mq_initialize.c b/sched/mqueue/mq_initialize.c index 3e46ac2554274cbed235d34024d2ab46f139e120..46e820c9fce820cdeacfe9312222ca44fdfb121f 100644 --- a/sched/mqueue/mq_initialize.c +++ b/sched/mqueue/mq_initialize.c @@ -111,7 +111,7 @@ static sq_queue_t g_desalloc; * Description: * Allocate a block of messages and place them on the free list. * - * Inputs Parameters: + * Input Parameters: * queue * ****************************************************************************/ @@ -156,10 +156,10 @@ mq_msgblockalloc(FAR sq_queue_t *queue, uint16_t nmsgs, * be called early in the initialization sequence before any of the * other message interfaces execute. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -198,10 +198,10 @@ void nxmq_initialize(void) * Allocate a block of message descriptors and place them on the free * list. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/mqueue/mq_msgfree.c b/sched/mqueue/mq_msgfree.c index 9492a93d38736d2aa5f8eeb2c6656de522013484..4ea3735f73381c2a7e9e2cc005332b6cdbca8307 100644 --- a/sched/mqueue/mq_msgfree.c +++ b/sched/mqueue/mq_msgfree.c @@ -59,10 +59,10 @@ * messages if it was a pre-allocated message. If the message was * allocated dynamically it will be deallocated. * - * Inputs: + * Input Parameters: * mqmsg - message to free * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/mqueue/mq_msgqalloc.c b/sched/mqueue/mq_msgqalloc.c index 473896c3f28568ef676141265253a1f9c47879fc..becf7bd39439b597cf29156d40f35ba353d4bb9e 100644 --- a/sched/mqueue/mq_msgqalloc.c +++ b/sched/mqueue/mq_msgqalloc.c @@ -66,7 +66,7 @@ * queue is created to determine the maximum number of * messages that may be placed in the message queue. * - * Return Value: + * Returned Value: * The allocated and initialized message queue structure or NULL in the * event of a failure. * diff --git a/sched/mqueue/mq_msgqfree.c b/sched/mqueue/mq_msgqfree.c index b52494813e196eb83946b0b7fce57ae48a2f4196..54f858ced8778b83fc88c9591403bd4d0b9125fb 100644 --- a/sched/mqueue/mq_msgqfree.c +++ b/sched/mqueue/mq_msgqfree.c @@ -57,10 +57,10 @@ * closed so that no thread will attempt access it while it is being * deleted. * - * Inputs: + * Input Parameters: * msgq - Named essage queue to be freed * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/mqueue/mq_notify.c b/sched/mqueue/mq_notify.c index 8dd0e89080d3e1c12fc6762f43edb3667a7f4f41..3cf3d42278ae161746962be2e9941d9d96809f59 100644 --- a/sched/mqueue/mq_notify.c +++ b/sched/mqueue/mq_notify.c @@ -78,7 +78,7 @@ * sigev_signo - The signo to use for the notification * sigev_value - Value associated with the signal * - * Return Value: + * Returned Value: * On success mq_notify() returns 0; on error, -1 is returned, with * errno set to indicate the error. * diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 78479314ff7d3b96e85507a291fbb2dee59bba1e..00ab85e373e2eccb0024cbe57f2885bfa343e286 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -302,7 +302,7 @@ ssize_t nxmq_do_receive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, * time the task is unblocked */ - DEBUGASSERT(btcb); + DEBUGASSERT(btcb != NULL); btcb->msgwaitq = NULL; msgq->nwaitnotfull--; diff --git a/sched/mqueue/mq_recover.c b/sched/mqueue/mq_recover.c index 087dc4d34178fb3794e0691195e60eef2c8d3197..b150c0a28b557380b0f1f2bbdff0fb6a8e42df64 100644 --- a/sched/mqueue/mq_recover.c +++ b/sched/mqueue/mq_recover.c @@ -58,10 +58,10 @@ * via pthread_cancel. I checks if the task was waiting for a message * queue event and adjusts counts appropriately. * - * Inputs: + * Input Parameters: * tcb - The TCB of the terminated task or thread * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/mqueue/mq_release.c b/sched/mqueue/mq_release.c index c916c7b41dc591d5306659efd388e9331762955d..2e253b915b30e87d843ae3ab84a7deaa6204e3fc 100644 --- a/sched/mqueue/mq_release.c +++ b/sched/mqueue/mq_release.c @@ -55,10 +55,10 @@ * This function closes all of the message queues opened by members of * the task group. * - * Inputs: + * Input Parameters: * group - The task group that is terminating. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/mqueue/mq_setattr.c b/sched/mqueue/mq_setattr.c index de238e4601be0b945be1d799ed5beba5d58153a1..eb70f779de4f7f14942e9e7b2e7fee57857b77c6 100644 --- a/sched/mqueue/mq_setattr.c +++ b/sched/mqueue/mq_setattr.c @@ -65,7 +65,7 @@ * mq_stat - New attributes * oldstate - Old attributes * - * Return Value: + * Returned Value: * 0 (OK) if attributes are set successfully, otherwise * -1 (ERROR). * diff --git a/sched/mqueue/mq_sndinternal.c b/sched/mqueue/mq_sndinternal.c index 933d684a13ca2d1ff86dd3fe97eeb76e0e2e1e14..7ad32132cb216d115818a907520ccbb2d34d669c 100644 --- a/sched/mqueue/mq_sndinternal.c +++ b/sched/mqueue/mq_sndinternal.c @@ -131,7 +131,7 @@ int nxmq_verify_send(mqd_t mqdes, FAR const char *msg, size_t msglen, * the g_msgfreeirq list. If this is unsuccessful, the calling interrupt * handler will be notified. * - * Inputs: + * Input Parameters: * None * * Returned Value: diff --git a/sched/mqueue/mq_timedreceive.c b/sched/mqueue/mq_timedreceive.c index 9194a79da7ecd90c27f6d00fa595f87bc13863f1..af95097e899d40768894b83d9bf630bc18d87e90 100644 --- a/sched/mqueue/mq_timedreceive.c +++ b/sched/mqueue/mq_timedreceive.c @@ -239,8 +239,8 @@ ssize_t nxmq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen, /* Start the watchdog */ - wd_start(rtcb->waitdog, ticks, (wdentry_t)nxmq_rcvtimeout, - 1, getpid()); + (void)wd_start(rtcb->waitdog, ticks, (wdentry_t)nxmq_rcvtimeout, + 1, getpid()); } /* Get the message from the message queue */ diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c index 43924d490125465ded9b9c219eb4dd006db0b37e..66682e68f7d76c1b821e6a3ea87fb105bd19825b 100644 --- a/sched/mqueue/mq_timedsend.c +++ b/sched/mqueue/mq_timedsend.c @@ -271,7 +271,8 @@ int nxmq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio, /* Start the watchdog and begin the wait for MQ not full */ - wd_start(rtcb->waitdog, ticks, (wdentry_t)nxmq_sndtimeout, 1, getpid()); + (void)wd_start(rtcb->waitdog, ticks, (wdentry_t)nxmq_sndtimeout, + 1, getpid()); /* And wait for the message queue to be non-empty */ diff --git a/sched/mqueue/mq_waitirq.c b/sched/mqueue/mq_waitirq.c index ee24c4d9f74fce1325952092fab566473e14659b..d542adc8af954da8bf38683409332b8057835f13 100644 --- a/sched/mqueue/mq_waitirq.c +++ b/sched/mqueue/mq_waitirq.c @@ -65,7 +65,7 @@ * wtcb - A pointer to the TCB of the task that is waiting on a message * queue, but has received a signal instead. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/paging/paging.h b/sched/paging/paging.h index cccda6e4ed94efefe8c3283fba98f1121bd0f02d..c7e253b421e0de589c7f73af100508173da2af58 100644 --- a/sched/paging/paging.h +++ b/sched/paging/paging.h @@ -107,7 +107,7 @@ extern FAR struct tcb_s *g_pftcb; * This is the entry point of the worker thread that performs the actual * page file. * - * Input parameters: + * Input Parameters: * argc, argv (not used) * * Returned Value: diff --git a/sched/paging/pg_miss.c b/sched/paging/pg_miss.c index 6bec634e061cb648854dc27a865c740e2b928302..75beda6827b723b560f4f530d1bc59b7cef0777d 100644 --- a/sched/paging/pg_miss.c +++ b/sched/paging/pg_miss.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/paging/pg_miss.c * - * Copyright (C) 2010, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -162,7 +162,7 @@ void pg_miss(void) pginfo("New worker priority. %d->%d\n", wtcb->sched_priority, ftcb->sched_priority); - sched_setpriority(wtcb, ftcb->sched_priority); + (void)nxsched_setpriority(wtcb, ftcb->sched_priority); } /* Signal the page fill worker thread. diff --git a/sched/paging/pg_worker.c b/sched/paging/pg_worker.c index 1c8ee188a4f196476ad8d0946c0dfa8e44f076ee..e6fe07b62a8318cc77abd5041ae8dbee408cf326 100644 --- a/sched/paging/pg_worker.c +++ b/sched/paging/pg_worker.c @@ -2,7 +2,7 @@ * sched/paging/pg_worker.c * Page fill worker thread implementation. * - * Copyright (C) 2010-2011, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -140,7 +141,7 @@ static systime_t g_starttime; * task that is waiting for a fill. * - Signal the page fill worker thread. * - * Input parameters: + * Input Parameters: * tcb - The TCB of the task that just received the fill. * result - The result of the page fill operation. * @@ -185,7 +186,7 @@ static void pg_callback(FAR struct tcb_s *tcb, int result) { pginfo("New worker priority. %d->%d\n", wtcb->sched_priority, priority); - sched_setpriority(wtcb, priority); + (void)nxsched_setpriority(wtcb, priority); } /* Save the page fill result (don't permit the value -EBUSY) */ @@ -222,7 +223,7 @@ static void pg_callback(FAR struct tcb_s *tcb, int result) * The result (NULL or a TCB pointer) will be returned in the global * variable, g_pftcb. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -296,7 +297,7 @@ static inline bool pg_dequeue(void) pginfo("New worker priority. %d->%d\n", wtcb->sched_priority, priority); - sched_setpriority(wtcb, priority); + (void)nxsched_setpriority(wtcb, priority); } /* Return with g_pftcb holding the pointer to @@ -333,7 +334,7 @@ static inline bool pg_dequeue(void) * prioritized list, or (2) when a page fill completes and there are more * pages to be filled in g_waitingforfill list. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -440,7 +441,7 @@ static inline bool pg_startfill(void) * - Set g_pftcb to NULL. * - Restore the default priority of the page fill worker thread. * - * Input parameters: + * Input Parameters: * None. * * Returned Value: @@ -458,7 +459,7 @@ static inline void pg_alldone(void) g_pftcb = NULL; pginfo("New worker priority. %d->%d\n", wtcb->sched_priority, CONFIG_PAGING_DEFPRIO); - sched_setpriority(wtcb, CONFIG_PAGING_DEFPRIO); + (void)nxsched_setpriority(wtcb, CONFIG_PAGING_DEFPRIO); } /**************************************************************************** @@ -474,7 +475,7 @@ static inline void pg_alldone(void) * This function is just a dumb wrapper around up_unblocktask(). This * function simply makes the task that just received the fill ready-to-run. * - * Input parameters: + * Input Parameters: * None. * * Returned Value: @@ -514,7 +515,7 @@ static inline void pg_fillcomplete(void) * after completing a page fill. * - A configurable timeout with no activity. * - * Input parameters: + * Input Parameters: * argc, argv (not used) * * Returned Value: diff --git a/sched/pthread/pthread_cleanup.c b/sched/pthread/pthread_cleanup.c index a4f6e45b21904f54490a443ea9dc62a0420891d4..cbfc2558be0f127b196264479e7fbe5387468299 100644 --- a/sched/pthread/pthread_cleanup.c +++ b/sched/pthread/pthread_cleanup.c @@ -64,7 +64,7 @@ * Input Parameters: * tcb - The TCB of the pthread that is exiting or being canceled. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_completejoin.c b/sched/pthread/pthread_completejoin.c index 0b934c1033e9cf30996bcf56db79f99f7f921c3a..6dc23185c5d05951b3554f690c5e2609baedd723 100644 --- a/sched/pthread/pthread_completejoin.c +++ b/sched/pthread/pthread_completejoin.c @@ -115,7 +115,7 @@ static bool pthread_notifywaiters(FAR struct join_s *pjoin) * Parameters: * pid * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/pthread/pthread_condbroadcast.c b/sched/pthread/pthread_condbroadcast.c index 0fddd76927316f88e0becba422d1ce01a4a61563..5a19538882cdf71d36279e5d1a34c28d8e0eff15 100644 --- a/sched/pthread/pthread_condbroadcast.c +++ b/sched/pthread/pthread_condbroadcast.c @@ -59,7 +59,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_condsignal.c b/sched/pthread/pthread_condsignal.c index 5826a425de13caef01be0b591fd02665475dfc02..21eab53ec213cf5783fd924421bbcfb7bdf0c8c0 100644 --- a/sched/pthread/pthread_condsignal.c +++ b/sched/pthread/pthread_condsignal.c @@ -58,7 +58,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_condtimedwait.c b/sched/pthread/pthread_condtimedwait.c index b27c279397bb9c4532ea5675d7dff7b33a40475d..0093d3def31735f3c7c937ee793a4deac8424fbd 100644 --- a/sched/pthread/pthread_condtimedwait.c +++ b/sched/pthread/pthread_condtimedwait.c @@ -75,7 +75,7 @@ * pid - the task ID of the task to wakeup * signo - The signal to use to wake up the task * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -156,7 +156,7 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo) * mutex - the mutex that protects the condition variable * abstime - wait until this absolute time * - * Return Value: + * Returned Value: * OK (0) on success; A non-zero errno value is returned on failure. * * Assumptions: @@ -274,8 +274,10 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex, { /* Start the watchdog */ - wd_start(rtcb->waitdog, ticks, (wdentry_t)pthread_condtimedout, - 2, (uint32_t)mypid, (uint32_t)SIGCONDTIMEDOUT); + (void)wd_start(rtcb->waitdog, ticks, + (wdentry_t)pthread_condtimedout, + 2, (uint32_t)mypid, + (uint32_t)SIGCONDTIMEDOUT); /* Take the condition semaphore. Do not restore interrupts * until we return from the wait. This is necessary to diff --git a/sched/pthread/pthread_condwait.c b/sched/pthread/pthread_condwait.c index b3716da0a6dd12ce774b3095a05cfe926fa095d6..734dc55bad374289b57f1367963c6b905644957e 100644 --- a/sched/pthread/pthread_condwait.c +++ b/sched/pthread/pthread_condwait.c @@ -62,7 +62,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 54d5afec54b9cce688ba306881d540db9a5043f9..7f6f2ed2b271e87194c555790ce846b344e7de36 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/pthread/pthread_create.c * - * Copyright (C) 2007-2009, 2011, 2013-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2013-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -49,6 +50,7 @@ #include #include +#include #include #include #include @@ -101,7 +103,7 @@ static const char g_pthreadname[] = ""; * tcb - Address of the new task's TCB * arg - The argument to provide to the pthread on startup. * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -131,7 +133,7 @@ static inline void pthread_argsetup(FAR struct pthread_tcb_s *tcb, pthread_addr_ * Parameters: * pjoin * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -193,7 +195,7 @@ static void pthread_start(void) if (ptcb->cmn.sched_priority > ptcb->cmn.init_priority) { - DEBUGVERIFY(sched_setpriority(&ptcb->cmn, ptcb->cmn.init_priority)); + DEBUGVERIFY(nxsched_setpriority(&ptcb->cmn, ptcb->cmn.init_priority)); } /* Pass control to the thread entry point. In the kernel build this has to @@ -230,7 +232,7 @@ static void pthread_start(void) * start_routine * arg * - * Returned value: + * Returned Value: * OK (0) on success; a (non-negated) errno value on failure. The errno * variable is not set. * @@ -321,19 +323,19 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, * thread. */ - ret = sched_getparam(0, ¶m); - if (ret == ERROR) + ret = nxsched_getparam(0, ¶m); + if (ret < 0) { - errcode = get_errno(); + errcode = -ret; goto errout_with_join; } /* Get the scheduler policy for this thread */ - policy = sched_getscheduler(0); - if (policy == ERROR) + policy = nxsched_getscheduler(0); + if (policy < 0) { - errcode = get_errno(); + errcode = -policy; goto errout_with_join; } } @@ -527,7 +529,7 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, if (ret < 0) { - ret = get_errno(); + ret = -ret; } } @@ -547,10 +549,10 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, if (ptcb->cmn.sched_priority < parent->sched_priority) { - ret = sched_setpriority(&ptcb->cmn, parent->sched_priority); + ret = nxsched_setpriority(&ptcb->cmn, parent->sched_priority); if (ret < 0) { - ret = get_errno(); + ret = -ret; } } } diff --git a/sched/pthread/pthread_detach.c b/sched/pthread/pthread_detach.c index 47e0a3b42dca4feaaaa493cbcb545c40db5257bb..184f1642727e72eda3e117f74e92ee54d79f2584 100644 --- a/sched/pthread/pthread_detach.c +++ b/sched/pthread/pthread_detach.c @@ -68,7 +68,7 @@ * Parameters: * thread * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code. * * Assumptions: diff --git a/sched/pthread/pthread_findjoininfo.c b/sched/pthread/pthread_findjoininfo.c index 23fcc6a46d761e26e44bff7e7735aedc468cfd48..9ddc34cdd8f021418b3714906f9de45cab7339ef 100644 --- a/sched/pthread/pthread_findjoininfo.c +++ b/sched/pthread/pthread_findjoininfo.c @@ -58,7 +58,7 @@ * group - The that the pid is (or was) a member of of * pid - The ID of the pthread * - * Return Value: + * Returned Value: * None or pointer to the found entry. * * Assumptions: diff --git a/sched/pthread/pthread_getaffinity.c b/sched/pthread/pthread_getaffinity.c index f4d46f1976a38e492d69179e48e6cf8fcd7feb1e..d3eb4d9f8964b254c3db3a8aa72f965322dd004a 100644 --- a/sched/pthread/pthread_getaffinity.c +++ b/sched/pthread/pthread_getaffinity.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/pthread/pthread_getaffinity.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,8 @@ #include #include +#include + #include "pthread/pthread.h" #ifdef CONFIG_SMP @@ -69,7 +71,7 @@ * cpusetsize - Size of cpuset. MUST be sizeofcpu_set_t(). * cpuset - The location to return the thread's new affinity set. * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an errno value is returned indicating the * nature of the failure. * @@ -86,15 +88,14 @@ int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, DEBUGASSERT(thread > 0 && cpusetsize == sizeof(cpu_set_t) && cpuset != NULL); - /* Let sched_getaffinity do all of the work */ + /* Let nxsched_getaffinity do all of the work */ - ret = sched_getaffinity((pid_t)thread, cpusetsize, cpuset); + ret = nxsched_getaffinity((pid_t)thread, cpusetsize, cpuset); if (ret < 0) { - /* If sched_getaffinity() fails, return the errno */ + /* If nxsched_getaffinity() fails, return the positive errno */ - ret = get_errno(); - DEBUGASSERT(ret > 0); + ret = -ret; } return ret; diff --git a/sched/pthread/pthread_getschedparam.c b/sched/pthread/pthread_getschedparam.c index a71bc488cdb007aca78cd279a845c393311f0849..64d4f860639ba58c987977ea2afa93586c01a034 100644 --- a/sched/pthread/pthread_getschedparam.c +++ b/sched/pthread/pthread_getschedparam.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/pthread/pthread_getschedparam.c * - * Copyright (C) 2007, 2008, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -37,11 +37,16 @@ * Included Files ****************************************************************************/ +#include + #include #include #include #include #include + +#include + #include "pthread/pthread.h" /**************************************************************************** @@ -75,7 +80,7 @@ * policy - The location to store the thread's scheduling policy. * param - The location to store the thread's priority. * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, the error code ESRCH if the value specified * by thread does not refer to an existing thread. * @@ -90,30 +95,36 @@ int pthread_getschedparam(pthread_t thread, FAR int *policy, sinfo("Thread ID=%d policy=0x%p param=0x%p\n", thread, policy, param); - if (!policy || !param) + if (policy == NULL || param == NULL) { ret = EINVAL; } else { - /* Get the schedparams of the thread. */ + /* Get the scheduler parameters of the thread. */ - ret = sched_getparam((pid_t)thread, param); - if (ret != OK) + ret = nxsched_getparam((pid_t)thread, param); + if (ret < 0) { - ret = EINVAL; + ret = -ret; } - - /* Return the policy. */ - - *policy = sched_getscheduler((pid_t)thread); - if (*policy == ERROR) + else { - ret = get_errno(); + /* Get the scheduler policy. */ + + ret = nxsched_getscheduler((pid_t)thread); + if (ret < 0) + { + ret = -ret; + } + else + { + *policy = ret; + ret = OK; + } } } sinfo("Returning %d\n", ret); return ret; } - diff --git a/sched/pthread/pthread_getspecific.c b/sched/pthread/pthread_getspecific.c index 51927549c115680b80c71907aa3c1ae2e4a55910..889f712dd35a8d1783c5540183ecad6ff82133e5 100644 --- a/sched/pthread/pthread_getspecific.c +++ b/sched/pthread/pthread_getspecific.c @@ -65,7 +65,7 @@ * Parameters: * key = The data key to get or set * - * Return Value: + * Returned Value: * The function pthread_getspecific() returns the thread-specific data * associated with the given key. If no thread specific data is * associated with the key, then the value NULL is returned. diff --git a/sched/pthread/pthread_initialize.c b/sched/pthread/pthread_initialize.c index 3887ab7e8f881996b6c67a14c346a539caa14b00..5da4bcdaa026bc91fd73380959395ea98bd67dec 100644 --- a/sched/pthread/pthread_initialize.c +++ b/sched/pthread/pthread_initialize.c @@ -64,7 +64,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -91,7 +91,7 @@ void pthread_initialize(void) * intr - false: ignore EINTR errors when locking; true tread EINTR as * other errors by returning the errno value * - * Return Value: + * Returned Value: * 0 on success or an errno value on failure. * ****************************************************************************/ @@ -164,6 +164,8 @@ int pthread_sem_trytake(sem_t *sem) int pthread_sem_give(sem_t *sem) { + int ret; + /* Verify input parameters */ @@ -172,16 +174,13 @@ int pthread_sem_give(sem_t *sem) { /* Give the semaphore */ - if (nxsem_post(sem) == OK) + ret = nxsem_post(sem); + if (ret < 0) { - return OK; + return -ret; } - else - { - /* nxsem_post() reported an error */ - return get_errno(); - } + return OK; } else { diff --git a/sched/pthread/pthread_join.c b/sched/pthread/pthread_join.c index 4f22777b9a97121b64c78420bcf4f82a208b755c..24bec6bb0d124970e0947441a5e4126f18aa3c0b 100644 --- a/sched/pthread/pthread_join.c +++ b/sched/pthread/pthread_join.c @@ -70,7 +70,7 @@ * thread * pexit_value * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, one of the following error codes: * * EINVAL The value specified by thread does not refer to joinable diff --git a/sched/pthread/pthread_keycreate.c b/sched/pthread/pthread_keycreate.c index 60be2fb5e32de1a1f5687f8d84255e5ba692a59b..9daade6a312f916ef24e1074d28615f21e6c398b 100644 --- a/sched/pthread/pthread_keycreate.c +++ b/sched/pthread/pthread_keycreate.c @@ -71,7 +71,7 @@ * with each key that is invoked when a thread exits. However, this * argument is ignored in the current implementation. * - * Return Value: + * Returned Value: * If successful, the pthread_key_create() function will store the newly * created key value at *key and return zero (OK). Otherwise, an error * number will bereturned to indicate the error: diff --git a/sched/pthread/pthread_keydelete.c b/sched/pthread/pthread_keydelete.c index 57cd46309a411c9c1cf4e41b11bf061d749cf9b6..ab72fad9db95be43c708188448dc21f7bf1fe48f 100644 --- a/sched/pthread/pthread_keydelete.c +++ b/sched/pthread/pthread_keydelete.c @@ -60,7 +60,7 @@ * Parameters: * key = the key to delete * - * Return Value: + * Returned Value: * Always returns ENOSYS. * * Assumptions: diff --git a/sched/pthread/pthread_kill.c b/sched/pthread/pthread_kill.c index 1c2663e47e1286452a45c57c286a6be9e69b522f..e3f04a0b7aed80b7456869487f861d850708c32b 100644 --- a/sched/pthread/pthread_kill.c +++ b/sched/pthread/pthread_kill.c @@ -70,7 +70,7 @@ * signo - The signal number to send. If 'signo' is zero, no signal is * sent, but all error checking is performed. * - * Return Value: + * Returned Value: * On success the signal was send and zero is returned. On error one * of the following error numbers is returned. * diff --git a/sched/pthread/pthread_mutex.c b/sched/pthread/pthread_mutex.c index 6e1edd49d83c434e8456cb8dac41e7cbeddc9be2..02092a011795aeff842cf50598ca1889255c5f33 100644 --- a/sched/pthread/pthread_mutex.c +++ b/sched/pthread/pthread_mutex.c @@ -64,7 +64,7 @@ * Parameters: * mutex - The mutex to be locked * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -107,7 +107,7 @@ static void pthread_mutex_add(FAR struct pthread_mutex_s *mutex) * Parameters: * mutex - The mutex to be locked * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -172,7 +172,7 @@ static void pthread_mutex_remove(FAR struct pthread_mutex_s *mutex) * intr - false: ignore EINTR errors when locking; true treat EINTR as * other errors by returning the errno value * - * Return Value: + * Returned Value: * 0 on success or an errno value on failure. * ****************************************************************************/ @@ -242,7 +242,7 @@ int pthread_mutex_take(FAR struct pthread_mutex_s *mutex, bool intr) * intr - false: ignore EINTR errors when locking; true treat EINTR as * other errors by returning the errno value * - * Return Value: + * Returned Value: * 0 on success or an errno value on failure. * ****************************************************************************/ @@ -299,7 +299,7 @@ int pthread_mutex_trytake(FAR struct pthread_mutex_s *mutex) * Parameters: * mutex - The mutex to be unlocked * - * Return Value: + * Returned Value: * 0 on success or an errno value on failure. * ****************************************************************************/ diff --git a/sched/pthread/pthread_mutexconsistent.c b/sched/pthread/pthread_mutexconsistent.c index c00331d1f9a642ace817ebeb4c54a33012091fb5..d4b2b246a9cf038da895f6dccde8842f2144e1aa 100644 --- a/sched/pthread/pthread_mutexconsistent.c +++ b/sched/pthread/pthread_mutexconsistent.c @@ -129,7 +129,14 @@ int pthread_mutex_consistent(FAR pthread_mutex_t *mutex) */ status = nxsem_reset((FAR sem_t *)&mutex->sem, 1); - ret = (status != OK) ? get_errno() : OK; + if (status < 0) + { + ret = -status; + } + else + { + ret = OK; + } } /* Otherwise the mutex is held by some active thread. Let's not @@ -146,10 +153,10 @@ int pthread_mutex_consistent(FAR pthread_mutex_t *mutex) #ifdef CONFIG_PTHREAD_MUTEX_TYPES mutex->nlocks = 0; #endif + ret = OK; } sched_unlock(); - ret = OK; } sinfo("Returning %d\n", ret); diff --git a/sched/pthread/pthread_mutexdestroy.c b/sched/pthread/pthread_mutexdestroy.c index 17f58fbda531cb250f97a14ac8038d200b622c98..7c5055504cf9dcfdfa900be763ebe1d6b878ac12 100644 --- a/sched/pthread/pthread_mutexdestroy.c +++ b/sched/pthread/pthread_mutexdestroy.c @@ -63,7 +63,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_mutexinit.c b/sched/pthread/pthread_mutexinit.c index 6624c47349ee9f5e9ab40239ba1e632d6f8008d7..a648544bfad91e8f00dfcc3869ce04d4ab823d2a 100644 --- a/sched/pthread/pthread_mutexinit.c +++ b/sched/pthread/pthread_mutexinit.c @@ -61,7 +61,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -119,18 +119,18 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex, /* Initialize the mutex like a semaphore with initial count = 1 */ status = nxsem_init((FAR sem_t *)&mutex->sem, pshared, 1); - if (status != OK) + if (status < 0) { - ret = get_errno(); + ret = -ret; } #ifdef CONFIG_PRIORITY_INHERITANCE /* Initialize the semaphore protocol */ status = nxsem_setprotocol((FAR sem_t *)&mutex->sem, proto); - if (status != OK) + if (status < 0) { - ret = get_errno(); + ret = -status; } #endif diff --git a/sched/pthread/pthread_mutexlock.c b/sched/pthread/pthread_mutexlock.c index 223b2193c59a898b06a7fc6e12619058207bd7da..88611c7be36b9fbf938fc1eaaec05f8ecec56b43 100644 --- a/sched/pthread/pthread_mutexlock.c +++ b/sched/pthread/pthread_mutexlock.c @@ -91,7 +91,7 @@ * Parameters: * mutex - A reference to the mutex to be locked. * - * Return Value: + * Returned Value: * 0 on success or an errno value on failure. Note that the errno EINTR * is never returned by pthread_mutex_lock(). * diff --git a/sched/pthread/pthread_mutextrylock.c b/sched/pthread/pthread_mutextrylock.c index b88916ae5048c89fca3c5e8dd1c564e768c776ab..fb74a76d5c44e121cd025167379e23fb501e52fd 100644 --- a/sched/pthread/pthread_mutextrylock.c +++ b/sched/pthread/pthread_mutextrylock.c @@ -69,7 +69,7 @@ * Parameters: * mutex - A reference to the mutex to be locked. * - * Return Value: + * Returned Value: * 0 on success or an errno value on failure. Note that the errno EINTR * is never returned by pthread_mutex_trylock(). * diff --git a/sched/pthread/pthread_mutexunlock.c b/sched/pthread/pthread_mutexunlock.c index a29fc490da11b37411f6f203dbd11ca1331616bb..75492515ac92d3ed61fec6084a5bacac23dafc31 100644 --- a/sched/pthread/pthread_mutexunlock.c +++ b/sched/pthread/pthread_mutexunlock.c @@ -61,7 +61,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * Returns true if the mutex is locked * ****************************************************************************/ @@ -105,7 +105,7 @@ static inline bool pthread_mutex_islocked(FAR struct pthread_mutex_s *mutex) * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_release.c b/sched/pthread/pthread_release.c index ff7164f1ebe8aeac7cb373eef15cc793e1e23f5c..fd79544c9c4d073d8fb25a98f207d9889508b31e 100644 --- a/sched/pthread/pthread_release.c +++ b/sched/pthread/pthread_release.c @@ -61,7 +61,7 @@ * group = The task group containing the pthread resources to be * released. * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/pthread/pthread_setaffinity.c b/sched/pthread/pthread_setaffinity.c index cf8ccf639fd4d3c90f5f3253bedd66affdc3a005..5f3ba7283c783f26de42334ed26af3547179cc6a 100644 --- a/sched/pthread/pthread_setaffinity.c +++ b/sched/pthread/pthread_setaffinity.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/pthread/pthread_setaffinity.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,8 @@ #include #include +#include + #include "pthread/pthread.h" #ifdef CONFIG_SMP @@ -71,7 +73,7 @@ * cpusetsize - Size of cpuset. MUST be sizeofcpu_set_t(). * cpuset - Provides the new affinity set for the thread. * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an errno value is returned indicating the * nature of the failure. * @@ -88,18 +90,11 @@ int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, DEBUGASSERT(thread > 0 && cpusetsize == sizeof(cpu_set_t) && cpuset != NULL); - /* Let sched_setaffinity do all of the work */ - - ret = sched_setaffinity((pid_t)thread, cpusetsize, cpuset); - if (ret < 0) - { - /* If sched_setaffinity() fails, return the errno */ + /* Let nxsched_setaffinity do all of the work, adjusting the return value */ - ret = get_errno(); - DEBUGASSERT(ret > 0); - } - - return ret; + ret = nxsched_setaffinity((pid_t)thread, cpusetsize, cpuset); + return ret < 0 ? -ret : OK; } #endif /* CONFIG_SMP */ + diff --git a/sched/pthread/pthread_setschedparam.c b/sched/pthread/pthread_setschedparam.c index 3c04cfb0232029e86934f28c053c52f50c2c8413..bfbbf2dbcd10adba382816defcc51d0fca3efe68 100644 --- a/sched/pthread/pthread_setschedparam.c +++ b/sched/pthread/pthread_setschedparam.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/pthread/pthread_setschedparam.c * - * Copyright (C) 2007, 2008, 2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2012, 2015, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -37,12 +38,16 @@ * Included Files ****************************************************************************/ +#include + #include #include #include #include #include +#include + #include "pthread/pthread.h" /**************************************************************************** @@ -77,7 +82,7 @@ * SCHED_RR. SCHED_OTHER and SCHED_SPORADIC are not supported. * param - Provides the new priority of the thread. * - * Return Value: + * Returned Value: * 0 if successful. Otherwise, an error code identifying the cause of the * failure: * @@ -94,8 +99,6 @@ * specified. * ESRCH The value specified by thread does not refer to a existing thread. * - * Assumptions: - * ****************************************************************************/ int pthread_setschedparam(pthread_t thread, int policy, @@ -105,18 +108,14 @@ int pthread_setschedparam(pthread_t thread, int policy, sinfo("thread ID=%d policy=%d param=0x%p\n", thread, policy, param); - /* Set the errno to some non-zero value (failsafe) */ - - set_errno(EINVAL); - - /* Let sched_setscheduler do all of the work */ + /* Let nxsched_setscheduler do all of the work */ - ret = sched_setscheduler((pid_t)thread, policy, param); - if (ret != OK) + ret = nxsched_setscheduler((pid_t)thread, policy, param); + if (ret < 0) { - /* If sched_setscheduler() fails, return the errno */ + /* If nxsched_setscheduler() fails, return the positive errno value */ - ret = get_errno(); + ret = -ret; } return ret; diff --git a/sched/pthread/pthread_setschedprio.c b/sched/pthread/pthread_setschedprio.c index cf31d9f013f0f6fea3e2df79d6e5049df3e518aa..aed67e45593feb0cb2de5326d64102c5284ed3b6 100644 --- a/sched/pthread/pthread_setschedprio.c +++ b/sched/pthread/pthread_setschedprio.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/pthread/pthread_setschedprio.c * - * Copyright (C) 2007, 2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -38,10 +38,14 @@ ****************************************************************************/ #include + #include #include #include + +#include #include + #include "sched/sched.h" /**************************************************************************** @@ -57,12 +61,12 @@ * If the thread_setschedprio() function fails, the scheduling priority * of the target thread will not be changed. * - * Inputs: + * Input Parameters: * thread - the thread ID of the task to reprioritize. * prio - The new thread priority. The range of valid priority numbers is * from SCHED_PRIORITY_MIN through SCHED_PRIORITY_MAX. * - * Return Value: + * Returned Value: * OK if successful, otherwise an error number. This function can * fail for the following reasons: * @@ -83,25 +87,21 @@ int pthread_setschedprio(pthread_t thread, int prio) * modified. */ - ret = sched_getparam((pid_t)thread, ¶m); + ret = nxsched_getparam((pid_t)thread, ¶m); if (ret < 0) { - goto errout_with_errno; + return -ret; } #endif - /* Call sched_setparam() to change the priority */ + /* Call nxsched_setparam() to change the priority */ param.sched_priority = prio; - ret = sched_setparam((pid_t)thread, ¶m); - if (ret >= 0) + ret = nxsched_setparam((pid_t)thread, ¶m); + if (ret < 0) { - return OK; + return -ret; } -#ifdef CONFIG_SCHED_SPORADIC -errout_with_errno: -#endif - ret = get_errno(); - return ret; + return OK; } diff --git a/sched/pthread/pthread_setspecific.c b/sched/pthread/pthread_setspecific.c index 3a0db5b7ef441fa64a11e5620418d0c8785a9e2e..371353b424adaa6b1f6cffa0a1bc058f7e8b38ed 100644 --- a/sched/pthread/pthread_setspecific.c +++ b/sched/pthread/pthread_setspecific.c @@ -72,7 +72,7 @@ * key = The data key to get or set * value = The value to bind to the key. * - * Return Value: + * Returned Value: * If successful, pthread_setspecific() will return zero (OK). * Otherwise, an error number will be returned: * diff --git a/sched/pthread/pthread_sigmask.c b/sched/pthread/pthread_sigmask.c index fb87f28c3f264a8d42815d7369a5b15bf4b425e2..43eb6c27eda74e39f184df8f7e5a9876dac9e783 100644 --- a/sched/pthread/pthread_sigmask.c +++ b/sched/pthread/pthread_sigmask.c @@ -71,7 +71,7 @@ * set - Location of the new signal mask * oset - Location to store the old signal mask * - * Return Value: + * Returned Value: * On success, this function will return 0 (OK). It will return EINVAL if * how is invalid. * diff --git a/sched/sched/Make.defs b/sched/sched/Make.defs index 0626d9e39b02c9a33f278d7b67b33f11e43e6b2a..49056289ad1719b31b0212c7bebf0d9d544474ca 100644 --- a/sched/sched/Make.defs +++ b/sched/sched/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # sched/sched/Make.defs # -# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -77,6 +77,8 @@ else ifeq ($(CONFIG_SCHED_SPORADIC),y) CSRCS += sched_resumescheduler.c else ifeq ($(CONFIG_SCHED_INSTRUMENTATION),y) CSRCS += sched_resumescheduler.c +else ifeq ($(CONFIG_SMP),y) +CSRCS += sched_resumescheduler.c endif ifeq ($(CONFIG_SCHED_CPULOAD),y) @@ -96,6 +98,15 @@ ifeq ($(CONFIG_SCHED_INSTRUMENTATION_BUFFER),y) CSRCS += sched_note.c endif +ifeq ($(CONFIG_SMP),y) +CSRCS += sched_tasklistlock.c +ifeq ($(CONFIG_ARCH_GLOBAL_IRQDISABLE),y) +CSRCS += sched_thistask.c +else ifeq ($(CONFIG_ARCH_HAVE_FETCHADD),y) +CSRCS += sched_thistask.c +endif +endif + # Include sched build support DEPPATH += --dep-path sched diff --git a/sched/sched/sched.h b/sched/sched/sched.h index eea2a3b1c2ccb09dda0fa3e0c018f7dee014e2a0..dca36d1f6c90575c1cbeeef1a7ea6d1fb28b1018 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched.h * - * Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -63,21 +63,31 @@ * tasks built into the design). */ +#if CONFIG_MAX_TASKS & (CONFIG_MAX_TASKS - 1) +# error CONFIG_MAX_TASKS must be power of 2 +#endif + #define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1) #define PIDHASH(pid) ((pid) & MAX_TASKS_MASK) /* These are macros to access the current CPU and the current task on a CPU. * These macros are intended to support a future SMP implementation. + * NOTE: this_task() for SMP is implemented in sched_thistask.c if the CPU + * supports disabling of inter-processor interrupts or if it supports the + * atomic fetch add operation. */ #ifdef CONFIG_SMP # define current_task(cpu) ((FAR struct tcb_s *)g_assignedtasks[cpu].head) # define this_cpu() up_cpu_index() +# if !defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) && !defined(CONFIG_ARCH_HAVE_FETCHADD) +# define this_task() (current_task(this_cpu())) +# endif #else # define current_task(cpu) ((FAR struct tcb_s *)g_readytorun.head) # define this_cpu() (0) +# define this_task() (current_task(this_cpu())) #endif -#define this_task() (current_task(this_cpu())) /* List attribute flags */ @@ -167,7 +177,7 @@ extern volatile dq_queue_t g_readytorun; * and * - Tasks/threads that have not been assigned to a CPU. * - * Otherwise, the TCB will be reatined in an assigned task list, + * Otherwise, the TCB will be retained in an assigned task list, * g_assignedtasks. As its name suggests, on 'g_assignedtasks queue for CPU * 'n' would contain only tasks/threads that are assigned to CPU 'n'. Tasks/ * threads would be assigned a particular CPU by one of two mechanisms: @@ -281,7 +291,7 @@ extern struct pidhash_s g_pidhash[CONFIG_MAX_TASKS]; /* This is a table of task lists. This table is indexed by the task stat * enumeration type (tstate_t) and provides a pointer to the associated * static task list (if there is one) as well as a a set of attribute flags - * indicating properities of the list, for example, if the list is an + * indicating properties of the list, for example, if the list is an * ordered list or not. */ @@ -360,6 +370,18 @@ extern volatile spinlock_t g_cpu_schedlock SP_SECTION; extern volatile spinlock_t g_cpu_locksetlock SP_SECTION; extern volatile cpu_set_t g_cpu_lockset SP_SECTION; +/* Used to lock tasklist to prevent from concurrent access */ + +extern volatile spinlock_t g_cpu_tasklistlock SP_SECTION; + +#if defined(CONFIG_ARCH_HAVE_FETCHADD) && !defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) +/* This is part of the sched_lock() logic to handle atomic operations when + * locking the scheduler. + */ + +extern volatile int16_t g_global_lockcount; +#endif + #endif /* CONFIG_SMP */ /**************************************************************************** @@ -376,15 +398,15 @@ void sched_mergeprioritized(FAR dq_queue_t *list1, FAR dq_queue_t *list2, bool sched_mergepending(void); void sched_addblocked(FAR struct tcb_s *btcb, tstate_t task_state); void sched_removeblocked(FAR struct tcb_s *btcb); -int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority); +int nxsched_setpriority(FAR struct tcb_s *tcb, int sched_priority); /* Priority inheritance support */ #ifdef CONFIG_PRIORITY_INHERITANCE -int sched_reprioritize(FAR struct tcb_s *tcb, int sched_priority); +int nxsched_reprioritize(FAR struct tcb_s *tcb, int sched_priority); #else -# define sched_reprioritize(tcb,sched_priority) \ - sched_setpriority(tcb,sched_priority) +# define nxsched_reprioritize(tcb,sched_priority) \ + nxsched_setpriority(tcb,sched_priority) #endif /* Support for tickless operation */ @@ -419,13 +441,30 @@ void sched_sporadic_lowpriority(FAR struct tcb_s *tcb); #endif #ifdef CONFIG_SMP +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) || defined(CONFIG_ARCH_HAVE_FETCHADD) +FAR struct tcb_s *this_task(void); +#endif + int sched_cpu_select(cpu_set_t affinity); int sched_cpu_pause(FAR struct tcb_s *tcb); -# define sched_islocked(tcb) spin_islocked(&g_cpu_schedlock) + +irqstate_t sched_tasklist_lock(void); +void sched_tasklist_unlock(irqstate_t lock); + +#if defined(CONFIG_ARCH_HAVE_FETCHADD) && !defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) +# define sched_islocked_global() \ + (spin_islocked(&g_cpu_schedlock) || g_global_lockcount > 0) +#else +# define sched_islocked_global() \ + spin_islocked(&g_cpu_schedlock) +#endif + +# define sched_islocked_tcb(tcb) sched_islocked_global() + #else -# define sched_cpu_select(a) (0) -# define sched_cpu_pause(t) (-38) /* -ENOSYS */ -# define sched_islocked(tcb) ((tcb)->lockcount > 0) +# define sched_cpu_select(a) (0) +# define sched_cpu_pause(t) (-38) /* -ENOSYS */ +# define sched_islocked_tcb(tcb) ((tcb)->lockcount > 0) #endif /* CPU load measurement support */ diff --git a/sched/sched/sched_addblocked.c b/sched/sched/sched_addblocked.c index 34303681c5ce72cd9c546f0d44508ae8e966204f..487330714de122111a5d9253a1df46fbe1a67c86 100644 --- a/sched/sched/sched_addblocked.c +++ b/sched/sched/sched_addblocked.c @@ -55,11 +55,11 @@ * This function adds a TCB to one of the blocked state task lists as * inferred from task_state. * - * Inputs: + * Input Parameters: * btcb - Points to the TCB that is blocked * task_state - identifies the state of the blocked task * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -77,6 +77,12 @@ void sched_addblocked(FAR struct tcb_s *btcb, tstate_t task_state) DEBUGASSERT(task_state >= FIRST_BLOCKED_STATE && task_state <= LAST_BLOCKED_STATE); +#ifdef CONFIG_SMP + /* Lock the tasklists before accessing */ + + irqstate_t lock = sched_tasklist_lock(); +#endif + /* Add the TCB to the blocked task list associated with this state. */ tasklist = TLIST_BLOCKED(task_state); @@ -96,6 +102,12 @@ void sched_addblocked(FAR struct tcb_s *btcb, tstate_t task_state) dq_addlast((FAR dq_entry_t *)btcb, tasklist); } +#ifdef CONFIG_SMP + /* Unlock the tasklists */ + + sched_tasklist_unlock(lock); +#endif + /* Make sure the TCB's state corresponds to the list */ btcb->task_state = task_state; diff --git a/sched/sched/sched_addprioritized.c b/sched/sched/sched_addprioritized.c index b94b60255dbe658d7887c2460c0a46586521146e..15e20319be9ac1cab73cc9ea71a3ed63785a395f 100644 --- a/sched/sched/sched_addprioritized.c +++ b/sched/sched/sched_addprioritized.c @@ -56,11 +56,11 @@ * Description: * This function adds a TCB to a prioritized TCB list. * - * Inputs: + * Input Parameters: * tcb - Points to the TCB to add to the prioritized list * list - Points to the prioritized list to add tcb to * - * Return Value: + * Returned Value: * true if the head of the list has changed. * * Assumptions: diff --git a/sched/sched/sched_addreadytorun.c b/sched/sched/sched_addreadytorun.c index 95b7bf647491fd0cfd4b81aed536c4d0564bea43..e24fa2471eedc1cc17252ee2b356932c159fa2e3 100644 --- a/sched/sched/sched_addreadytorun.c +++ b/sched/sched/sched_addreadytorun.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/sched/sched_addreadytorun.c * - * Copyright (C) 2007-2009, 2014, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014, 2016-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -60,10 +61,10 @@ * instead. The pending tasks will be made ready-to-run when preemption is * unlocked. * - * Inputs: + * Input Parameters: * btcb - Points to the blocked TCB that is ready-to-run * - * Return Value: + * Returned Value: * true if the currently active task (the head of the ready-to-run list) * has changed. * @@ -141,13 +142,13 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) * * If the currently active task has preemption disabled and the new TCB * would cause this task to be pre-empted, the new task is added to the - * g_pendingtasks list instead. Thepending tasks will be made + * g_pendingtasks list instead. The pending tasks will be made * ready-to-run when preemption isunlocked. * - * Inputs: + * Input Parameters: * btcb - Points to the blocked TCB that is ready-to-run * - * Return Value: + * Returned Value: * true if the currently active task (the head of the ready-to-run list) * has changed. * @@ -173,6 +174,10 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) int cpu; int me; + /* Lock the tasklists before accessing */ + + irqstate_t lock = sched_tasklist_lock(); + /* Check if the blocked TCB is locked to this CPU */ if ((btcb->flags & TCB_FLAG_CPU_LOCKED) != 0) @@ -190,7 +195,7 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) cpu = sched_cpu_select(btcb->affinity); } - /* Get the task currently running on the CPU (maybe the IDLE task) */ + /* Get the task currently running on the CPU (may be the IDLE task) */ rtcb = (FAR struct tcb_s *)g_assignedtasks[cpu].head; @@ -236,7 +241,7 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) */ me = this_cpu(); - if ((spin_islocked(&g_cpu_schedlock) || irq_cpu_locked(me)) && + if ((sched_islocked_global() || irq_cpu_locked(me)) && task_state != TSTATE_TASK_ASSIGNED) { /* Add the new ready-to-run task to the g_pendingtasks task list for @@ -339,10 +344,9 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) else if (g_cpu_nestcount[me] <= 0) { - /* Release our hold on the IRQ lock. */ - - spin_clrbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, - &g_cpu_irqlock); + /* Do nothing here + * NOTE: spin_clrbit() will be done in sched_resumescheduler() + */ } /* Sanity check. g_cpu_netcount should be greater than zero @@ -384,7 +388,7 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) * different CPU the next time that it runs. */ - if (spin_islocked(&g_cpu_schedlock)) + if (sched_islocked_global()) { next->task_state = TSTATE_TASK_PENDING; tasklist = (FAR dq_queue_t *)&g_pendingtasks; @@ -405,7 +409,7 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) /* No context switch. Assign the CPU and set the assigned state. * * REVISIT: I have seen this assertion fire. Apparently another - * CPU may add another, higher prioirity task to the same + * CPU may add another, higher priority task to the same * g_assignedtasks[] list sometime after sched_cpu_select() was * called above, leaving this TCB in the wrong task list if task_state * is TSTATE_TASK_ASSIGNED). @@ -426,6 +430,9 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb) } } + /* Unlock the tasklists */ + + sched_tasklist_unlock(lock); return doswitch; } diff --git a/sched/sched/sched_cpuload.c b/sched/sched/sched_cpuload.c index ef35c39848c48594cd7e77bdb9a0cd57be024788..1ee7275bd349252b8163e229f574ebcfc85ea30c 100644 --- a/sched/sched/sched_cpuload.c +++ b/sched/sched/sched_cpuload.c @@ -110,10 +110,10 @@ volatile uint32_t g_cpuload_total; * Description: * Collect data that can be used for CPU load measurements. * - * Inputs: + * Input Parameters: * cpu - The CPU that we are performing the load operations on. * - * Return Value: + * Returned Value: * None * * Assumptions/Limitations: @@ -156,10 +156,10 @@ static inline void sched_cpu_process_cpuload(int cpu) * Description: * Collect data that can be used for CPU load measurements. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions/Limitations: @@ -228,7 +228,7 @@ void weak_function sched_process_cpuload(void) * pid - The task ID of the thread of interest. pid == 0 is the IDLE thread. * cpuload - The location to return the CPU load * - * Return Value: + * Returned Value: * OK (0) on success; a negated errno value on failure. The only reason * that this function can fail is if 'pid' no longer refers to a valid * thread. diff --git a/sched/sched/sched_cpuselect.c b/sched/sched/sched_cpuselect.c index c995cb8764433cc4a290229bb6a077eb78898a84..b96436cdd49f42043a9ea6fd612a93548db80f47 100644 --- a/sched/sched/sched_cpuselect.c +++ b/sched/sched/sched_cpuselect.c @@ -65,10 +65,10 @@ * Return the index to the CPU with the lowest priority running task, * possbily its IDLE task. * - * Inputs: + * Input Parameters: * affinity - The set of CPUs on which the thread is permitted to run. * - * Return Value: + * Returned Value: * Index of the CPU with the lowest priority running task * * Assumptions: diff --git a/sched/sched/sched_foreach.c b/sched/sched/sched_foreach.c index 1ee962d7728b89ce7552eed1e8f84443a166279f..3bd7898a849de40faebddb2f326f597260c4289c 100644 --- a/sched/sched/sched_foreach.c +++ b/sched/sched/sched_foreach.c @@ -59,7 +59,7 @@ * handler - The function to be called with the TCB of * each task * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/sched/sched_garbage.c b/sched/sched/sched_garbage.c index 7c853232d05dea5caff99a8955301395f796aa4f..a5fce0c8d0538ab0378729ae0b12b7bd8cc5eeb4 100644 --- a/sched/sched/sched_garbage.c +++ b/sched/sched/sched_garbage.c @@ -53,7 +53,7 @@ * Description: * Clean-up deferred de-allocations of user memory * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -110,7 +110,7 @@ static inline void sched_kucleanup(void) * Description: * Return TRUE if there is user heap garbage to be collected. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -133,7 +133,7 @@ static inline bool sched_have_kugarbage(void) * Description: * Clean-up deferred de-allocations of kernel memory * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -184,7 +184,7 @@ static inline void sched_kcleanup(void) * Description: * Return TRUE if there is kernal heap garbage to be collected. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -220,7 +220,7 @@ static inline bool sched_have_kgarbage(void) * collection to be called from the IDLE thread because it runs at a very * low priority and could cause false memory out conditions. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -254,7 +254,7 @@ void sched_garbage_collection(void) * state. The looping nature of the IDLE loops should catch any missed * garbage from the test on the next time arround. * - * Input parameters: + * Input Parameters: * None * * Returned Value: diff --git a/sched/sched/sched_getaffinity.c b/sched/sched/sched_getaffinity.c index e7d355b50fef628d72ca5b21040c5411a2c087e7..7a15bc7d578472fb56bfd2044ee73d916d97d708 100644 --- a/sched/sched/sched_getaffinity.c +++ b/sched/sched/sched_getaffinity.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_getaffinity.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,8 @@ #include #include +#include + #include "sched/sched.h" /**************************************************************************** @@ -51,37 +53,45 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_getscheduler + * Name: nxsched_getaffinity * * Description: - * sched_getaffinity() writes the affinity mask of the thread whose ID + * nxsched_getaffinity() writes the affinity mask of the thread whose ID * is pid into the cpu_set_t pointed to by mask. The cpusetsize * argument specifies the size (in bytes) of mask. If pid is zero, then * the mask of the calling thread is returned. * - * Inputs: + * nxsched_getaffinity() is identical to the function sched_getaffinity(), + * differing only in its return value: This function does not modify the + * errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getparam(). + * + * Input Parameters: * pid - The ID of thread whose affinity set will be retrieved. - * cpusetsize - Size of cpuset. MUST be sizeofcpu_set_t(). - * cpuset - The location to return the thread's new affinity set. + * cpusetsize - Size of mask. MUST be sizeofcpu_set_t(). + * mask - The location to return the thread's new affinity set. * - * Return Value: - * 0 if successful. Otherwise, ERROR (-1) is returned, and errno is - * set appropriately: + * Returned Value: + * Zero (OK) if successful. Otherwise, a negated errno value is returned: * * ESRCH The task whose ID is pid could not be found. * ****************************************************************************/ -int sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) +int nxsched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) { FAR struct tcb_s *tcb; + int ret; DEBUGASSERT(cpusetsize == sizeof(cpu_set_t) && mask != NULL); /* Verify that the PID corresponds to a real task */ sched_lock(); - if (!pid) + if (pid == 0) { tcb = this_task(); } @@ -92,13 +102,53 @@ int sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) if (tcb == NULL) { - set_errno(ESRCH); - return ERROR; + ret = -ESRCH; } + else + { + /* Return the affinity mask from the TCB. */ - /* Return the affinity mask from the TCB. */ + *mask = tcb->affinity; + ret = OK; + } - *mask = tcb->affinity; sched_unlock(); - return OK; + return ret; +} + +/**************************************************************************** + * Name: sched_getaffinity + * + * Description: + * sched_getaffinity() writes the affinity mask of the thread whose ID + * is pid into the cpu_set_t pointed to by mask. The cpusetsize + * argument specifies the size (in bytes) of mask. If pid is zero, then + * the mask of the calling thread is returned. + * + * This function is a simply wrapper around nxsched_getaffinity() that + * sets the errno value in the event of an error. + * + * Input Parameters: + * pid - The ID of thread whose affinity set will be retrieved. + * cpusetsize - Size of mask. MUST be sizeofcpu_set_t(). + * mask - The location to return the thread's new affinity set. + * + * Returned Value: + * 0 if successful. Otherwise, ERROR (-1) is returned, and errno is + * set appropriately: + * + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +int sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) +{ + int ret = nxsched_getaffinity(pid, cpusetsize, mask); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + + return ret; } diff --git a/sched/sched/sched_getfiles.c b/sched/sched/sched_getfiles.c index 7e634053d925fe1588c393397570c38312f70671..d36fe7f0c0fb38453192bf926eff175c25391b2c 100644 --- a/sched/sched/sched_getfiles.c +++ b/sched/sched/sched_getfiles.c @@ -58,7 +58,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * A pointer to the errno. * * Assumptions: diff --git a/sched/sched/sched_getparam.c b/sched/sched/sched_getparam.c index 72833d9471f11a22fdc967aa3b990aa4313628ea..c1668d00c5d8e16c662d7cc305ff7bbf2652eb47 100644 --- a/sched/sched/sched_getparam.c +++ b/sched/sched/sched_getparam.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_getparam.c * - * Copyright (C) 2007, 2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -41,6 +41,9 @@ #include #include +#include + +#include #include "clock/clock.h" #include "sched/sched.h" @@ -50,63 +53,67 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_getparam + * Name: nxsched_getparam * * Description: - * This function gets the scheduling priority of the task - * specified by pid. + * This function gets the scheduling priority of the task specified by + * pid. It is identical to the function sched_getparam(), differing only + * in its return value: This function does not modify the errno variable. * - * Inputs: + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getparam(). + * + * Input Parameters: * pid - the task ID of the task. If pid is zero, the priority * of the calling task is returned. * param - A structure whose member sched_priority is the integer * priority. The task's priority is copied to the sched_priority * element of this structure. * - * Return Value: - * 0 (OK) if successful, otherwise -1 (ERROR). - * - * This function can fail if param is null or if pid does - * not correspond to any task. + * Returned Value: + * 0 (OK) if successful, otherwise a negated errno value is returned to + * indicate the nature of the failure.. * - * Assumptions: + * This function can fail if param is null (EINVAL) or if pid does + * not correspond to any task (ESRCH). * ****************************************************************************/ -int sched_getparam (pid_t pid, FAR struct sched_param *param) +int nxsched_getparam (pid_t pid, FAR struct sched_param *param) { FAR struct tcb_s *rtcb; FAR struct tcb_s *tcb; int ret = OK; - if (!param) + if (param == NULL) { - return ERROR; + return -EINVAL; } /* Check if the task to restart is the calling task */ rtcb = this_task(); - if ((pid == 0) || (pid == rtcb->pid)) + if (pid == 0 || pid == rtcb->pid) { /* Return the priority if the calling task. */ param->sched_priority = (int)rtcb->sched_priority; } - /* Ths pid is not for the calling task, we will have to look it up */ + /* This PID is not for the calling task, we will have to look it up */ else { - /* Get the TCB associated with this pid */ + /* Get the TCB associated with this PID */ sched_lock(); tcb = sched_gettcb(pid); if (!tcb) { - /* This pid does not correspond to any known task */ + /* This PID does not correspond to any known task */ - ret = ERROR; + ret = -ESRCH; } else { @@ -150,3 +157,38 @@ int sched_getparam (pid_t pid, FAR struct sched_param *param) return ret; } +/**************************************************************************** + * Name: sched_getparam + * + * Description: + * This function gets the scheduling priority of the task specified by + * pid. This function is a simply wrapper around nxsched_getparam() that + * sets the errno value in the event of an error. + * + * Input Parameters: + * pid - the task ID of the task. If pid is zero, the priority + * of the calling task is returned. + * param - A structure whose member sched_priority is the integer + * priority. The task's priority is copied to the sched_priority + * element of this structure. + * + * Returned Value: + * 0 (OK) if successful, otherwise -1 (ERROR) with the errno value set + * to indicate the nature of the problem. + * + * This function can fail if param is null (EINVAL) or if pid does + * not correspond to any task (ESRCH). + * + ****************************************************************************/ + +int sched_getparam (pid_t pid, FAR struct sched_param *param) +{ + int ret = nxsched_getparam(pid, param); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + + return ret; +} diff --git a/sched/sched/sched_getscheduler.c b/sched/sched/sched_getscheduler.c index 47ba73fa9cc6c952999158673798cf20db7cbc4d..13150854ba7b94653e3e8a9782a416feffc5103a 100644 --- a/sched/sched/sched_getscheduler.c +++ b/sched/sched/sched_getscheduler.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_getscheduler.c * - * Copyright (C) 2007, 2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include #include +#include #include #include "sched/sched.h" @@ -52,36 +53,42 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_getscheduler + * Name: nxsched_getscheduler * * Description: * sched_getscheduler() returns the scheduling policy currently - * applied to the task identified by pid. If pid equals zero, the + * applied to the task identified by pid. If pid equals zero, the * policy of the calling task will be retrieved. * - * Inputs: + * This functions is identical to the function sched_getscheduler(), + * differing only in its return value: This function does not modify + * the errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getscheduler(). + * + * Input Parameters: * pid - the task ID of the task to query. If pid is zero, the * calling task is queried. * - * Return Value: + * Returned Value: * On success, sched_getscheduler() returns the policy for the task - * (either SCHED_FIFO or SCHED_RR). On error, ERROR (-1) is - * returned, and errno is set appropriately: + * (either SCHED_FIFO or SCHED_RR). On error, a negated errno value + * returned: * * ESRCH The task whose ID is pid could not be found. * - * Assumptions: - * ****************************************************************************/ -int sched_getscheduler(pid_t pid) +int nxsched_getscheduler(pid_t pid) { FAR struct tcb_s *tcb; int policy; /* Verify that the PID corresponds to a real task */ - if (!pid) + if (pid == 0) { tcb = this_task(); } @@ -90,10 +97,9 @@ int sched_getscheduler(pid_t pid) tcb = sched_gettcb(pid); } - if (!tcb) + if (tcb == NULL) { - set_errno(ESRCH); - return ERROR; + return -ESRCH; } /* Return the scheduling policy from the TCB. NOTE that the user- @@ -103,3 +109,39 @@ int sched_getscheduler(pid_t pid) policy = (tcb->flags & TCB_FLAG_POLICY_MASK) >> TCB_FLAG_POLICY_SHIFT; return policy + 1; } + +/**************************************************************************** + * Name: sched_getscheduler + * + * Description: + * sched_getscheduler() returns the scheduling policy currently + * applied to the task identified by pid. If pid equals zero, the + * policy of the calling task will be retrieved. + * + * sched_getscheduler() is a simply wrapper around nxsched_getscheduler() + * that sets the errno value in the event of an error. + * + * Input Parameters: + * pid - the task ID of the task to query. If pid is zero, the + * calling task is queried. + * + * Returned Value: + * On success, sched_getscheduler() returns the policy for the task + * (either SCHED_FIFO or SCHED_RR). On error, ERROR (-1) is + * returned, and errno is set appropriately: + * + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +int sched_getscheduler(pid_t pid) +{ + int ret = nxsched_getscheduler(pid); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + + return ret; +} diff --git a/sched/sched/sched_getsockets.c b/sched/sched/sched_getsockets.c index 2601f90783a9b1343fe5c6e1950b7c8e4fa28993..a2dfdedd18cd1834af6d266d96f0ccb02c88346a 100644 --- a/sched/sched/sched_getsockets.c +++ b/sched/sched/sched_getsockets.c @@ -57,7 +57,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * A pointer to the errno. * * Assumptions: diff --git a/sched/sched/sched_getstreams.c b/sched/sched/sched_getstreams.c index 91f3c9f6f35a8c147466879e480243b92b935408..0a99a1e453f6d08a93551931d8cb14ebcea73b60 100644 --- a/sched/sched/sched_getstreams.c +++ b/sched/sched/sched_getstreams.c @@ -54,7 +54,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * A pointer to the errno. * * Assumptions: diff --git a/sched/sched/sched_lock.c b/sched/sched/sched_lock.c index 708b7780b13e27250e3f83c20268303688a5c4dd..dbe20c0634928e7bf00f0a77fb6d02e4bcedd037 100644 --- a/sched/sched/sched_lock.c +++ b/sched/sched/sched_lock.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_lock.c * - * Copyright (C) 2007, 2009, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,9 @@ #include #include +#include + +#include #include #include @@ -116,6 +119,13 @@ volatile spinlock_t g_cpu_schedlock SP_SECTION = SP_UNLOCKED; volatile spinlock_t g_cpu_locksetlock SP_SECTION; volatile cpu_set_t g_cpu_lockset SP_SECTION; +#if defined(CONFIG_ARCH_HAVE_FETCHADD) && !defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) +/* This is part of the sched_lock() logic to handle atomic operations when + * locking the scheduler. + */ + +volatile int16_t g_global_lockcount; +#endif #endif /* CONFIG_SMP */ /**************************************************************************** @@ -132,32 +142,74 @@ volatile cpu_set_t g_cpu_lockset SP_SECTION; * either calls sched_unlock() (the appropriate number of times) or * until it blocks itself. * - * Inputs + * Input Parameters: * None * - * Return Value: + * Returned Value: * OK on success; ERROR on failure * ****************************************************************************/ +#ifdef CONFIG_SMP + int sched_lock(void) { - FAR struct tcb_s *rtcb = this_task(); + FAR struct tcb_s *rtcb; +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + irqstate_t flags; +#endif + int cpu; + + /* The following operation is non-atomic unless CONFIG_ARCH_GLOBAL_IRQDISABLE + * or CONFIG_ARCH_HAVE_FETCHADD is defined. + */ + +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + /* If the CPU supports suppression of interprocessor interrupts, then simple + * disabling interrupts will provide sufficient protection for the following + * operation. + */ + + flags = up_irq_save(); + +#elif defined(CONFIG_ARCH_HAVE_FETCHADD) + /* If the CPU supports an atomic fetch add operation, then we can use the + * global lockcount to assure that the following operation is atomic. + */ + + DEBUGASSERT((uint16_t)g_global_lockcount < INT16_MAX); /* Not atomic! */ + (void)up_fetchadd16(&g_global_lockcount, 1); +#endif + + /* This operation is save if CONFIG_ARCH_HAVE_FETCHADD is defined. NOTE + * we cannot use this_task() because it calls sched_lock(). + */ + + cpu = this_cpu(); + rtcb = current_task(cpu); /* Check for some special cases: (1) rtcb may be NULL only during early * boot-up phases, and (2) sched_lock() should have no effect if called * from the interrupt level. */ - if (rtcb && !up_interrupt_context()) + if (rtcb == NULL || up_interrupt_context()) + { +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + up_irq_restore(flags); +#elif defined(CONFIG_ARCH_HAVE_FETCHADD) + DEBUGASSERT(g_global_lockcount > 0); + (void)up_fetchsub16(&g_global_lockcount, 1); +#endif + } + else { - /* Catch attempts to increment the lockcount beyound the range of the + /* Catch attempts to increment the lockcount beyond the range of the * integer type. */ DEBUGASSERT(rtcb->lockcount < MAX_LOCK_COUNT); -#ifdef CONFIG_SMP /* We must hold the lock on this CPU before we increment the lockcount * for the first time. Holding the lock is sufficient to lockout context * switching. @@ -184,7 +236,6 @@ int sched_lock(void) DEBUGASSERT(g_cpu_schedlock == SP_LOCKED && (g_cpu_lockset & (1 << this_cpu())) != 0); } -#endif /* A counter is used to support locking. This allows nested lock * operations on this thread (on any CPU) @@ -192,6 +243,12 @@ int sched_lock(void) rtcb->lockcount++; +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + up_irq_restore(flags); +#elif defined(CONFIG_ARCH_HAVE_FETCHADD) + DEBUGASSERT(g_global_lockcount > 0); + (void)up_fetchsub16(&g_global_lockcount, 1); +#endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION /* Check if we just acquired the lock */ @@ -204,7 +261,6 @@ int sched_lock(void) } #endif -#ifdef CONFIG_SMP /* Move any tasks in the ready-to-run list to the pending task list * where they will not be available to run until the scheduler is * unlocked and sched_mergepending() is called. @@ -213,8 +269,49 @@ int sched_lock(void) sched_mergeprioritized((FAR dq_queue_t *)&g_readytorun, (FAR dq_queue_t *)&g_pendingtasks, TSTATE_TASK_PENDING); + } + + return OK; +} + +#else /* CONFIG_SMP */ + +int sched_lock(void) +{ + FAR struct tcb_s *rtcb = this_task(); + + /* Check for some special cases: (1) rtcb may be NULL only during early + * boot-up phases, and (2) sched_lock() should have no effect if called + * from the interrupt level. + */ + + if (rtcb != NULL && !up_interrupt_context()) + { + /* Catch attempts to increment the lockcount beyond the range of the + * integer type. + */ + + DEBUGASSERT(rtcb->lockcount < MAX_LOCK_COUNT); + + /* A counter is used to support locking. This allows nested lock + * operations on this thread (on any CPU) + */ + + rtcb->lockcount++; + +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION + /* Check if we just acquired the lock */ + + if (rtcb->lockcount == 1) + { + /* Note that we have pre-emption locked */ + + sched_note_premption(rtcb, true); + } #endif } return OK; } + +#endif /* CONFIG_SMP */ diff --git a/sched/sched/sched_lockcount.c b/sched/sched/sched_lockcount.c index c3a8ef19030f8fa30c83a5003e12a82f037ffebb..9aeef35894a3b205de0ae078168c7214783eec3f 100644 --- a/sched/sched/sched_lockcount.c +++ b/sched/sched/sched_lockcount.c @@ -57,10 +57,10 @@ * execution. sched_unlock() will have to called that many times from * this thread in order to re-enable pre-emption. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * lockcount * ****************************************************************************/ diff --git a/sched/sched/sched_mergepending.c b/sched/sched/sched_mergepending.c index 39968e6e116c9bba4a4e8eee912f577ac388862e..8a90d417703dc8822e786ba2de171ff4d85174e1 100644 --- a/sched/sched/sched_mergepending.c +++ b/sched/sched/sched_mergepending.c @@ -68,10 +68,10 @@ * This function merges the prioritized g_pendingtasks list into the * prioritized ready-to-run task list. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * true if the head of the ready-to-run task list has changed indicating * a context switch is needed. * @@ -173,10 +173,10 @@ bool sched_mergepending(void) * This function merges the prioritized g_pendingtasks list into the * prioritized ready-to-run task list. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * true if the head of the ready-to-run task list has changed indicating * a context switch is needed. * @@ -199,6 +199,10 @@ bool sched_mergepending(void) int cpu; int me; + /* Lock the tasklist before accessing */ + + irqstate_t lock = sched_tasklist_lock(); + /* Remove and process every TCB in the g_pendingtasks list. * * Do nothing if (1) pre-emption is still disabled (by any CPU), or (2) if @@ -206,7 +210,7 @@ bool sched_mergepending(void) */ me = this_cpu(); - if (!spin_islocked(&g_cpu_schedlock) && !irq_cpu_locked(me)) + if (!sched_islocked_global() && !irq_cpu_locked(me)) { /* Find the CPU that is executing the lowest priority task */ @@ -215,7 +219,7 @@ bool sched_mergepending(void) { /* The pending task list is empty */ - return ret; + goto errout_with_lock; } cpu = sched_cpu_select(ALL_CPUS /* ptcb->affinity */); @@ -244,7 +248,7 @@ bool sched_mergepending(void) * Check if that happened. */ - if (spin_islocked(&g_cpu_schedlock) || irq_cpu_locked(me)) + if (sched_islocked_global() || irq_cpu_locked(me)) { /* Yes.. then we may have incorrectly placed some TCBs in the * g_readytorun list (unlikely, but possible). We will have to @@ -259,7 +263,7 @@ bool sched_mergepending(void) * pending task list. */ - return ret; + goto errout_with_lock; } /* Set up for the next time through the loop */ @@ -269,7 +273,7 @@ bool sched_mergepending(void) { /* The pending task list is empty */ - return ret; + goto errout_with_lock; } cpu = sched_cpu_select(ALL_CPUS /* ptcb->affinity */); @@ -285,6 +289,11 @@ bool sched_mergepending(void) TSTATE_TASK_READYTORUN); } +errout_with_lock: + + /* Unlock the tasklist */ + + sched_tasklist_unlock(lock); return ret; } #endif /* CONFIG_SMP */ diff --git a/sched/sched/sched_mergeprioritized.c b/sched/sched/sched_mergeprioritized.c index 90ef9dfbad99bf9f9f116b13b2532f754b22697a..7fb7d072840c042fef76148e4cc03b884a13b2ad 100644 --- a/sched/sched/sched_mergeprioritized.c +++ b/sched/sched/sched_mergeprioritized.c @@ -58,14 +58,14 @@ * into the prioritized task list, 'list2'. On return 'list2' will contain * the prioritized content of both lists; 'list1' will be empty. * - * Inputs: + * Input Parameters: * list1 - Points to the prioritized list to merge into list 1. This list * will be empty upon return. * list2 - That list that will contained the prioritized content of * both lists upon return. * task_state - The task state/list index associated with list2. * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -83,6 +83,12 @@ void sched_mergeprioritized(FAR dq_queue_t *list1, FAR dq_queue_t *list2, FAR struct tcb_s *tcb2; FAR struct tcb_s *tmp; +#ifdef CONFIG_SMP + /* Lock the tasklists before accessing */ + + irqstate_t lock = sched_tasklist_lock(); +#endif + DEBUGASSERT(list1 != NULL && list2 != NULL); /* Get a private copy of list1, clearing list1. We do this early so that @@ -99,7 +105,7 @@ void sched_mergeprioritized(FAR dq_queue_t *list1, FAR dq_queue_t *list2, { /* Special case.. list1 is empty. There is nothing to be done. */ - return; + goto ret_with_lock; } /* Now the TCBs are no longer accessible and we can change the state on @@ -122,7 +128,7 @@ void sched_mergeprioritized(FAR dq_queue_t *list1, FAR dq_queue_t *list2, /* Special case.. list2 is empty. Move list1 to list2. */ dq_move(&clone, list2); - return; + goto ret_with_lock; } /* Now loop until all entries from list1 have been merged into list2. tcb1 @@ -171,4 +177,13 @@ void sched_mergeprioritized(FAR dq_queue_t *list1, FAR dq_queue_t *list2, } } while (tcb1 != NULL); + +ret_with_lock: + +#ifdef CONFIG_SMP + /* Unlock the tasklists */ + + sched_tasklist_unlock(lock); +#endif + return; } diff --git a/sched/sched/sched_note.c b/sched/sched/sched_note.c index 6dc17b9936a7c74c97ab840922f459375040091b..40470b6561f4bb4bc8ee61d440eff84396d179fb 100644 --- a/sched/sched/sched_note.c +++ b/sched/sched/sched_note.c @@ -94,6 +94,10 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen); static struct note_info_s g_note_info; +#ifdef CONFIG_SMP +static volatile spinlock_t g_note_lock; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -299,21 +303,10 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen) } #endif - /* REVISIT: In the single CPU case, the following should be safe because - * the logic is always called within a critical section, but in the SMP - * case we have protection. One option would be to precalculate and - * advancing the new head entry before writing the data into the buffer. - * That will eliminate fatal race conditions (although could result in - * single notes being corrupted harmlessly). - * - * But there is a complexity: Advancing the head pointer where the note - * buffer is almost full could advance the head to wrap beyond the tail - * leaving the buffer in a bad state. A solution to this would be to pre- - * remove entries at the tail of the buffer as necessary to make certain - * that there will be space for the new note at the beginning of the - * buffer. I am less certain that this can be done safely in the SMP - * case. - */ +#ifdef CONFIG_SMP + irqstate_t flags = up_irq_save(); + spin_lock_wo_note(&g_note_lock); +#endif /* Get the index to the head of the circular buffer */ @@ -345,6 +338,11 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen) } g_note_info.ni_head = head; + +#ifdef CONFIG_SMP + spin_unlock_wo_note(&g_note_lock); + up_irq_restore(flags); +#endif } /**************************************************************************** diff --git a/sched/sched/sched_releasetcb.c b/sched/sched/sched_releasetcb.c index b7046aa790ae94516ff498ea92f474a853b32daa..26ab60b7f783a30d723496cd44793a1ece3838d1 100644 --- a/sched/sched/sched_releasetcb.c +++ b/sched/sched/sched_releasetcb.c @@ -102,7 +102,7 @@ static void sched_releasepid(pid_t pid) * however, there are certain error recovery contexts where the TCB my * not be fully initialized when sched_releasetcb is called. * - * Return Value: + * Returned Value: * OK on success; ERROR on failure * * Assumptions: diff --git a/sched/sched/sched_removeblocked.c b/sched/sched/sched_removeblocked.c index 36c92e96f0893301032ab2825fe6e6892d563b02..9ed15a98bbc5f81a33794af643e688ff3fc12891 100644 --- a/sched/sched/sched_removeblocked.c +++ b/sched/sched/sched_removeblocked.c @@ -55,10 +55,10 @@ * This function removes a TCB from one of the blocked state task * lists as inferred from the task_state inside the TCB. * - * Inputs: + * Input Parameters: * btcb - Points to the TCB that is blocked * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/sched/sched_removereadytorun.c b/sched/sched/sched_removereadytorun.c index 231310f62db10627eab22387d6698f3eac5ad5cc..aab359aa7dd7ad1c745fc47a6691677293b9def9 100644 --- a/sched/sched/sched_removereadytorun.c +++ b/sched/sched/sched_removereadytorun.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "irq/irq.h" #include "sched/sched.h" @@ -56,10 +57,10 @@ * Description: * This function removes a TCB from the ready to run list. * - * Inputs: + * Input Parameters: * rtcb - Points to the TCB that is ready-to-run * - * Return Value: + * Returned Value: * true if the currently active task (the head of the ready-to-run list) * has changed. * @@ -115,10 +116,10 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) * Description: * This function removes a TCB from the ready to run list. * - * Inputs: + * Input Parameters: * rtcb - Points to the TCB that is ready-to-run * - * Return Value: + * Returned Value: * true if the currently active task (the head of the ready-to-run list) * has changed. * @@ -138,6 +139,10 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) bool doswitch = false; int cpu; + /* Lock the tasklists before accessing */ + + irqstate_t lock = sched_tasklist_lock(); + /* Which CPU (if any) is the task running on? Which task list holds the * TCB? */ @@ -203,7 +208,7 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) * REVISIT: What if it is not the IDLE thread? */ - if (!spin_islocked(&g_cpu_schedlock) && !irq_cpu_locked(me)) + if (!sched_islocked_global() && !irq_cpu_locked(me)) { /* Search for the highest priority task that can run on this * CPU. @@ -233,8 +238,6 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) tmptcb = (FAR struct tcb_s *) dq_remfirst((FAR dq_queue_t *)&g_readytorun); - DEBUGASSERT(tmptcb == rtrtcb); - dq_addfirst((FAR dq_entry_t *)tmptcb, tasklist); tmptcb->cpu = cpu; @@ -283,10 +286,9 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) else if (g_cpu_nestcount[me] <= 0) { - /* Release our hold on the IRQ lock. */ - - spin_clrbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock, - &g_cpu_irqlock); + /* Do nothing here + * NOTE: spin_clrbit() will be done in sched_resumescheduler() + */ } /* Sanity check. g_cpu_netcount should be greater than zero @@ -330,6 +332,10 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) /* Since the TCB is no longer in any list, it is now invalid */ rtcb->task_state = TSTATE_TASK_INVALID; + + /* Unlock the tasklists */ + + sched_tasklist_unlock(lock); return doswitch; } #endif /* CONFIG_SMP */ diff --git a/sched/sched/sched_reprioritize.c b/sched/sched/sched_reprioritize.c index d9431cf165e83a98a904f7e8ab198a1112a5360f..3c65eec35f1c7e3f4bab3ed27684ce984a56dd8f 100644 --- a/sched/sched/sched_reprioritize.c +++ b/sched/sched/sched_reprioritize.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_reprioritize.c * - * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2012, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,8 @@ #include #include +#include + #include "sched/sched.h" #ifdef CONFIG_PRIORITY_INHERITANCE @@ -52,7 +54,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_reprioritize + * Name: nxsched_reprioritize * * Description: * This function sets the priority of a specified task. @@ -61,31 +63,29 @@ * to sched_yield() -- The task will be moved to after all other tasks * with the same priority. * - * Inputs: + * Input Parameters: * tcb - the TCB of task to reprioritize. * sched_priority - The new task priority * - * Return Value: - * On success, sched_setparam() returns 0 (OK). On error, -1 - * (ERROR) is returned, and errno is set appropriately. + * Returned Value: + * On success, sched_reporioritize() returns 0 (OK). On error, a negated + * errno value is returned. * * EINVAL The parameter 'param' is invalid or does not make sense for the * current scheduling policy. * EPERM The calling task does not have appropriate privileges. * ESRCH The task whose ID is pid could not be found. * - * Assumptions: - * ****************************************************************************/ -int sched_reprioritize(FAR struct tcb_s *tcb, int sched_priority) +int nxsched_reprioritize(FAR struct tcb_s *tcb, int sched_priority) { - /* This function is equivalent to sched_setpriority() BUT it also has the + /* This function is equivalent to nxsched_setpriority() BUT it also has the * side effect of discarding all priority inheritance history. This is * done only on explicit, user-initiated reprioritization. */ - int ret = sched_setpriority(tcb, sched_priority); + int ret = nxsched_setpriority(tcb, sched_priority); if (ret == 0) { /* Reset the base_priority -- the priority that the thread would return diff --git a/sched/sched/sched_resumescheduler.c b/sched/sched/sched_resumescheduler.c index 96097d4fcd610623f25f6d382ad4069b9538fd7d..08f104a5d838092bdd7548d711e1333c83f12b9a 100644 --- a/sched/sched/sched_resumescheduler.c +++ b/sched/sched/sched_resumescheduler.c @@ -45,10 +45,11 @@ #include #include +#include "irq/irq.h" #include "sched/sched.h" #if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) || \ - defined(CONFIG_SCHED_INSTRUMENTATION) + defined(CONFIG_SCHED_INSTRUMENTATION) || defined(CONFIG_SMP) /**************************************************************************** * Public Functions @@ -101,7 +102,44 @@ void sched_resume_scheduler(FAR struct tcb_s *tcb) sched_note_resume(tcb); #endif +#ifdef CONFIG_SMP + /* NOTE: The following logic for adjusting global IRQ controls were + * derived from sched_addreadytorun() and sched_removedreadytorun() + * Here, we only handles clearing logic to defer unlocking IRQ lock + * followed by context switching. + */ + + int me = this_cpu(); + + /* Adjust global IRQ controls. If irqcount is greater than zero, + * then this task/this CPU holds the IRQ lock + */ + + if (tcb->irqcount > 0) + { + /* Do notihing here + * NOTE: spin_setbit() is done in sched_addreadytorun() + * and sched_removereadytorun() + */ + } + + /* No.. This CPU will be relinquishing the lock. But this works + * differently if we are performing a context switch from an + * interrupt handler and the interrupt handler has established + * a critical section. We can detect this case when + * g_cpu_nestcount[me] > 0. + */ + + else if (g_cpu_nestcount[me] <= 0) + { + /* Release our hold on the IRQ lock. */ + + spin_clrbit(&g_cpu_irqset, me, &g_cpu_irqsetlock, + &g_cpu_irqlock); + } +#endif /* CONFIG_SMP */ + } #endif /* CONFIG_RR_INTERVAL > 0 || CONFIG_SCHED_SPORADIC || \ - * CONFIG_SCHED_INSTRUMENTATION */ + * CONFIG_SCHED_INSTRUMENTATION || CONFIG_SMP */ diff --git a/sched/sched/sched_roundrobin.c b/sched/sched/sched_roundrobin.c index 9aa5a6b8edf30b74b0374e5801337f43b44fe76c..e19c6377eeafc668bcf5f911744cdda662ffd344 100644 --- a/sched/sched/sched_roundrobin.c +++ b/sched/sched/sched_roundrobin.c @@ -73,12 +73,12 @@ * Description: * Check if the currently executing task has exceeded its time slice. * - * Inputs: + * Input Parameters: * tcb - The TCB of the currently executing task * ticks - The number of ticks that have elapsed on the interval timer. * noswitches - True: Can't do context switches now. * - * Return Value: + * Returned Value: * The number if ticks remaining until the next time slice expires. * Zero is returned if there is no time slicing (i.e., the task at the * head of the ready-to-run list does not support round robin @@ -121,7 +121,7 @@ uint32_t sched_roundrobin_process(FAR struct tcb_s *tcb, uint32_t ticks, /* Did decrementing the timeslice counter cause the timeslice to expire? */ ret = tcb->timeslice; - if (tcb->timeslice <= 0 && !sched_islocked(tcb)) + if (tcb->timeslice <= 0 && !sched_islocked_tcb(tcb)) { /* We will also suppress context switches if we were called via one * of the unusual cases handled by sched_timer_reasses(). In that diff --git a/sched/sched/sched_rrgetinterval.c b/sched/sched/sched_rrgetinterval.c index 3faefb44d2d9f193e3d1580e2092c407239af08d..fc96d8bd3b7e4279ca92293cab2afa8d4f869b03 100644 --- a/sched/sched/sched_rrgetinterval.c +++ b/sched/sched/sched_rrgetinterval.c @@ -62,12 +62,12 @@ * is written into 'interval. The identified process should be running * under the SCHED_RRscheduling policy.' * - * Inputs: + * Input Parameters: * pid - the task ID of the task. If pid is zero, the priority of the * calling task is returned. * interval - a structure used to return the time slice * - * Return Value: + * Returned Value: * On success, sched_rr_get_interval() returns OK (0). On error, * ERROR (-1) is returned, and errno is set to: * diff --git a/sched/sched/sched_setaffinity.c b/sched/sched/sched_setaffinity.c index f7fb59281244e3ea4a3df0196370eb5c38f3dc1b..d9ba77966969abbbe59ea079ac7b90db5ccd8802 100644 --- a/sched/sched/sched_setaffinity.c +++ b/sched/sched/sched_setaffinity.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_setaffinity.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_getscheduler + * Name: nxsched_setaffinity * * Description: * sched_setaffinity() sets the CPU affinity mask of the thread whose ID @@ -62,29 +62,34 @@ * bytes) of the data pointed to by mask. Normally this argument would * be specified as sizeof(cpu_set_t). * - * If the thread specified by pid is not currently running on one of the - * CPUs specified in mask, then that thread is migrated to one of the + * If the thread specified by pid is not currently running on one of the + * CPUs specified in mask, then that thread is migrated to one of the * CPUs specified in mask. * - * Inputs: - * pid - The ID of thread whose affinity set will be modified. - * cpusetsize - Size of cpuset. MUST be sizeofcpu_set_t(). - * cpuset - The location to return the thread's new affinity set. + * nxsched_setaffinity() is identical to the function sched_setparam(), + * differing only in its return value: This function does not modify + * the errno variable. This is a non-standard, internal OS function and + * is not intended for use by application logic. Applications should + * use the standard sched_setparam(). * - * Return Value: - * 0 if successful. Otherwise, ERROR (-1) is returned, and errno is - * set appropriately: + * Input Parameters: + * pid - The ID of thread whose affinity set will be modified. + * cpusetsize - Size of mask. MUST be sizeofcpu_set_t(). + * mask - The location to return the thread's new affinity set. * - * ESRCH The task whose ID is pid could not be found. + * Returned Value: + * Zero (OK) if successful. Otherwise, a negated errno value is returned: + * + * ESRCH The task whose ID is pid could not be found. * ****************************************************************************/ -int sched_setaffinity(pid_t pid, size_t cpusetsize, FAR const cpu_set_t *mask) +int nxsched_setaffinity(pid_t pid, size_t cpusetsize, + FAR const cpu_set_t *mask) { FAR struct tcb_s *tcb; irqstate_t flags; - int errcode = 0; - int ret; + int ret = OK; DEBUGASSERT(cpusetsize == sizeof(cpu_set_t) && mask != NULL); @@ -102,7 +107,7 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, FAR const cpu_set_t *mask) if (tcb == NULL) { - errcode = ESRCH; + ret = -ESRCH; goto errout_with_lock; } @@ -113,7 +118,7 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, FAR const cpu_set_t *mask) flags = enter_critical_section(); if ((tcb->flags & TCB_FLAG_CPU_LOCKED) != 0) { - errcode = EINVAL; + ret = -EINVAL; goto errout_with_csection; } @@ -140,17 +145,13 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, FAR const cpu_set_t *mask) /* No.. then we will need to move the task from the assigned * task list to some other ready to run list. * - * sched_setpriority() will do just what we want... it will remove + * nxsched_setpriority() will do just what we want... it will remove * the task from its current position in the some assigned task list * and then simply put it back in the right place. This works even * if the task is this task. */ - ret = sched_setpriority(tcb, tcb->sched_priority); - if (ret < 0) - { - errcode = get_errno(); - } + ret = nxsched_setpriority(tcb, tcb->sched_priority); } } @@ -159,11 +160,47 @@ errout_with_csection: errout_with_lock: sched_unlock(); - if (errcode != 0) + return ret; +} + +/**************************************************************************** + * Name: sched_setaffinity + * + * Description: + * sched_setaffinity() sets the CPU affinity mask of the thread whose ID + * is pid to the value specified by mask. If pid is zero, then the + * calling thread is used. The argument cpusetsize is the length (i + * bytes) of the data pointed to by mask. Normally this argument would + * be specified as sizeof(cpu_set_t). + * + * If the thread specified by pid is not currently running on one of the + * CPUs specified in mask, then that thread is migrated to one of the + * CPUs specified in mask. + * + * This function is a simply wrapper around nxsched_setaffinity() that sets + * the errno value in the event of an error. + * + * Input Parameters: + * pid - The ID of thread whose affinity set will be modified. + * cpusetsize - Size of mask. MUST be sizeofcpu_set_t(). + * mask - The location to return the thread's new affinity set. + * + * Returned Value: + * 0 if successful. Otherwise, ERROR (-1) is returned, and errno is + * set appropriately: + * + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +int sched_setaffinity(pid_t pid, size_t cpusetsize, FAR const cpu_set_t *mask) +{ + int ret = nxsched_setaffinity(pid, cpusetsize, mask); + if (ret < 0) { - set_errno(errcode); - return ERROR; + set_errno(-ret); + ret = ERROR; } - return OK; + return ret; } diff --git a/sched/sched/sched_setparam.c b/sched/sched/sched_setparam.c index 93bfccfe4333b643f52fdf1af4bd2ed1fa84fe56..9a36299d7b73f35215b66781fc5a4dec2b551b62 100644 --- a/sched/sched/sched_setparam.c +++ b/sched/sched/sched_setparam.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/sched/sched_setparam.c * - * Copyright (C) 2007, 2009, 2013, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013, 2015-2016, 2018 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,6 +45,7 @@ #include #include +#include #include #include @@ -55,48 +57,50 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_setparam + * Name: nxsched_setparam * * Description: - * This function sets the priority of a specified task. + * This function sets the priority of a specified task. It is identical + * to the function sched_setparam(), differing only in its return value: + * This function does not modify the errno variable. * * NOTE: Setting a task's priority to the same value has a similar effect * to sched_yield() -- The task will be moved to after all other tasks * with the same priority. * - * Inputs: + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_setparam(). + * + * Input Parameters: * pid - the task ID of the task to reprioritize. If pid is zero, the * priority of the calling task is changed. * param - A structure whose member sched_priority is the integer priority. * The range of valid priority numbers is from SCHED_PRIORITY_MIN * through SCHED_PRIORITY_MAX. * - * Return Value: - * On success, sched_setparam() returns 0 (OK). On error, -1 (ERROR) is - * returned, and errno is set appropriately. - * - * EINVAL The parameter 'param' is invalid or does not make sense for the - * current scheduling policy. - * EPERM The calling task does not have appropriate privileges. - * ESRCH The task whose ID is pid could not be found. + * Returned Value: + * 0 (OK) if successful, otherwise a negated errno value is returned to + * indicate the nature of the failure.. * - * Assumptions: + * EINVAL The parameter 'param' is invalid or does not make sense for the + * current scheduling policy. + * EPERM The calling task does not have appropriate privileges. + * ESRCH The task whose ID is pid could not be found. * ****************************************************************************/ -int sched_setparam(pid_t pid, FAR const struct sched_param *param) +int nxsched_setparam(pid_t pid, FAR const struct sched_param *param) { FAR struct tcb_s *rtcb; FAR struct tcb_s *tcb; - int errcode; int ret; /* Verify that the requested priority is in the valid range */ - if (!param) + if (param == NULL) { - errcode = EINVAL; - goto errout_with_errcode; + return -EINVAL; } /* Prohibit modifications to the head of the ready-to-run task @@ -122,7 +126,7 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param) { /* No task with this PID was found */ - errcode = ESRCH; + ret = -ESRCH; goto errout_with_lock; } } @@ -140,7 +144,7 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param) if (param->sched_ss_max_repl < 1 || param->sched_ss_max_repl > CONFIG_SCHED_SPORADIC_MAXREPL) { - errcode = EINVAL; + ret = -EINVAL; goto errout_with_lock; } @@ -174,7 +178,7 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param) if (repl_ticks < budget_ticks) #endif { - errcode = EINVAL; + ret = -EINVAL; goto errout_with_lock; } @@ -209,7 +213,6 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param) leave_critical_section(flags); if (ret < 0) { - errcode = -ret; goto errout_with_lock; } } @@ -217,16 +220,53 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param) /* Then perform the reprioritization */ - ret = sched_reprioritize(tcb, param->sched_priority); - sched_unlock(); - return ret; + ret = nxsched_reprioritize(tcb, param->sched_priority); errout_with_lock: - set_errno(errcode); sched_unlock(); - return ERROR; + return ret; +} + +/**************************************************************************** + * Name: sched_setparam + * + * Description: + * This function sets the priority of a specified task. This function is + * a simply wrapper around nxsched_setparam() that sets the errno value in + * the event of an error. + * + * NOTE: Setting a task's priority to the same value has a similar effect + * to sched_yield() -- The task will be moved to after all other tasks + * with the same priority. + * + * Input Parameters: + * pid - the task ID of the task to reprioritize. If pid is zero, the + * priority of the calling task is changed. + * param - A structure whose member sched_priority is the integer priority. + * The range of valid priority numbers is from SCHED_PRIORITY_MIN + * through SCHED_PRIORITY_MAX. + * + * Returned Value: + * On success, sched_setparam() returns 0 (OK). On error, -1 (ERROR) is + * returned, and errno is set appropriately. + * + * EINVAL The parameter 'param' is invalid or does not make sense for the + * current scheduling policy. + * EPERM The calling task does not have appropriate privileges. + * ESRCH The task whose ID is pid could not be found. + * + * Assumptions: + * + ****************************************************************************/ -errout_with_errcode: - set_errno(errcode); - return ERROR; +int sched_setparam(pid_t pid, FAR const struct sched_param *param) +{ + int ret = nxsched_setparam(pid, param); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + + return ret; } diff --git a/sched/sched/sched_setpriority.c b/sched/sched/sched_setpriority.c index abad51b801da89836c3e81a25e384266f7f4d474..d52adb286b5b2eef61dbcc9cea5e23e16b1ed845 100644 --- a/sched/sched/sched_setpriority.c +++ b/sched/sched/sched_setpriority.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_setpriority.c * - * Copyright (C) 2009, 2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -59,10 +59,10 @@ * Description: * Get the next highest priority ready-to-run task. * - * Inputs: + * Input Parameters: * tcb - the TCB of task to reprioritize. * - * Return Value: + * Returned Value: * TCB of the next highest priority ready-to-run task. * ****************************************************************************/ @@ -83,7 +83,7 @@ static FAR struct tcb_s *sched_nexttcb(FAR struct tcb_s *tcb) * then use the 'nxttcb' which will probably be the IDLE thread. */ - if (!spin_islocked(&g_cpu_schedlock) && !irq_cpu_locked(cpu)) + if (!sched_islocked_global() && !irq_cpu_locked(cpu)) { /* Search for the highest priority task that can run on this CPU. */ @@ -124,11 +124,11 @@ static FAR struct tcb_s *sched_nexttcb(FAR struct tcb_s *tcb) * to sched_yield() -- The task will be moved to after all other tasks * with the same priority. * - * Inputs: + * Input Parameters: * tcb - the TCB of task to reprioritize. * sched_priority - The new task priority * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -178,11 +178,11 @@ static inline void sched_running_setpriority(FAR struct tcb_s *tcb, * the position of the task in the ready-to-run list and if the priority * is increased, may cause the task to become running. * - * Inputs: + * Input Parameters: * tcb - the TCB of task to reprioritize. * sched_priority - The new task priority * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -267,11 +267,11 @@ static void sched_readytorun_setpriority(FAR struct tcb_s *tcb, * Change the priority of a blocked tasks. The only issue here is that * the task may like in a prioritized or an non-prioritized queue. * - * Inputs: + * Input Parameters: * tcb - the TCB of task to reprioritize. * sched_priority - The new task priority * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -315,7 +315,7 @@ static inline void sched_blocked_setpriority(FAR struct tcb_s *tcb, ****************************************************************************/ /**************************************************************************** - * Name: sched_setpriority + * Name: nxsched_setpriority * * Description: * This function sets the priority of a specified task. @@ -324,24 +324,22 @@ static inline void sched_blocked_setpriority(FAR struct tcb_s *tcb, * to sched_yield() -- The task will be moved to after all other tasks * with the same priority. * - * Inputs: + * Input Parameters: * tcb - the TCB of task to reprioritize. * sched_priority - The new task priority * - * Return Value: - * On success, sched_setparam() returns 0 (OK). On error, -1 (ERROR) is - * returned, and errno is set appropriately. + * Returned Value: + * On success, nxsched_setpriority() returns 0 (OK). On error, a negated + * errno value is returned. * * EINVAL The parameter 'param' is invalid or does not make sense for the * current scheduling policy. * EPERM The calling task does not have appropriate privileges. * ESRCH The task whose ID is pid could not be found. * - * Assumptions: - * ****************************************************************************/ -int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority) +int nxsched_setpriority(FAR struct tcb_s *tcb, int sched_priority) { irqstate_t flags; @@ -350,8 +348,7 @@ int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority) if (sched_priority < SCHED_PRIORITY_MIN || sched_priority > SCHED_PRIORITY_MAX) { - set_errno(EINVAL); - return ERROR; + return -EINVAL; } /* We need to assure that there there is no interrupt activity while @@ -383,7 +380,6 @@ int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority) sched_readytorun_setpriority(tcb, sched_priority); break; - /* CASE 3. The task is not in the ready to run list. Changing its * Priority cannot effect the currently executing task. */ diff --git a/sched/sched/sched_setscheduler.c b/sched/sched/sched_setscheduler.c index fecd1cf426a94822d0151d6221be3ec0fc63ba4e..2147ea82175e4fe4ed6d9f21208054e2b4c899d2 100644 --- a/sched/sched/sched_setscheduler.c +++ b/sched/sched/sched_setscheduler.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/sched/sched_setscheduler.c * - * Copyright (C) 2007, 2009, 2012, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2012, 2015-2016, 2018 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +46,7 @@ #include #include +#include #include #include @@ -56,15 +58,23 @@ ****************************************************************************/ /**************************************************************************** - * Name:sched_setscheduler + * Name: nxsched_setscheduler * * Description: - * sched_setscheduler() sets both the scheduling policy and the priority + * nxsched_setscheduler() sets both the scheduling policy and the priority * for the task identified by pid. If pid equals zero, the scheduler of * the calling task will be set. The parameter 'param' holds the priority * of the thread under the new policy. * - * Inputs: + * nxsched_setscheduler() is identical to the function sched_getparam(), + * differing only in its return value: This function does not modify the + * errno variable. + * + * This is a non-standard, internal OS function and is not intended for + * use by application logic. Applications should use the standard + * sched_getparam(). + * + * Input Parameters: * pid - the task ID of the task to modify. If pid is zero, the calling * task is modified. * policy - Scheduling policy requested (either SCHED_FIFO or SCHED_RR) @@ -72,25 +82,20 @@ * The range of valid priority numbers is from SCHED_PRIORITY_MIN * through SCHED_PRIORITY_MAX. * - * Return Value: - * On success, sched_setscheduler() returns OK (zero). On error, ERROR - * (-1) is returned, and errno is set appropriately: + * Returned Value: + * On success, nxsched_setscheduler() returns OK (zero). On error, a + * negated errno value is returned: * * EINVAL The scheduling policy is not one of the recognized policies. * ESRCH The task whose ID is pid could not be found. * - * Assumptions: - * ****************************************************************************/ -int sched_setscheduler(pid_t pid, int policy, - FAR const struct sched_param *param) +int nxsched_setscheduler(pid_t pid, int policy, + FAR const struct sched_param *param) { FAR struct tcb_s *tcb; irqstate_t flags; -#ifdef CONFIG_SCHED_SPORADIC - int errcode; -#endif int ret; /* Check for supported scheduling policy */ @@ -104,8 +109,7 @@ int sched_setscheduler(pid_t pid, int policy, #endif ) { - set_errno(EINVAL); - return ERROR; + return -EINVAL; } /* Check if the task to modify the calling task */ @@ -120,8 +124,7 @@ int sched_setscheduler(pid_t pid, int policy, tcb = sched_gettcb(pid); if (!tcb) { - set_errno(ESRCH); - return ERROR; + return -ESRCH; } /* Prohibit any context switches while we muck with priority and scheduler @@ -138,6 +141,8 @@ int sched_setscheduler(pid_t pid, int policy, { default: DEBUGPANIC(); + break; + case SCHED_FIFO: { #ifdef CONFIG_SCHED_SPORADIC @@ -186,7 +191,7 @@ int sched_setscheduler(pid_t pid, int policy, if (param->sched_ss_max_repl < 1 || param->sched_ss_max_repl > CONFIG_SCHED_SPORADIC_MAXREPL) { - errcode = EINVAL; + ret = -EINVAL; goto errout_with_irq; } @@ -220,7 +225,7 @@ int sched_setscheduler(pid_t pid, int policy, if (repl_ticks < budget_ticks) #endif { - errcode = EINVAL; + ret = -EINVAL; goto errout_with_irq; } @@ -260,7 +265,6 @@ int sched_setscheduler(pid_t pid, int policy, if (ret < 0) { - errcode = -ret; goto errout_with_irq; } } @@ -278,15 +282,56 @@ int sched_setscheduler(pid_t pid, int policy, /* Set the new priority */ - ret = sched_reprioritize(tcb, param->sched_priority); + ret = nxsched_reprioritize(tcb, param->sched_priority); sched_unlock(); - return (ret >= 0) ? OK : ERROR; + return ret; #ifdef CONFIG_SCHED_SPORADIC errout_with_irq: - set_errno(errcode); leave_critical_section(flags); sched_unlock(); - return ERROR; + return ret; #endif } + +/**************************************************************************** + * Name: sched_setscheduler + * + * Description: + * sched_setscheduler() sets both the scheduling policy and the priority + * for the task identified by pid. If pid equals zero, the scheduler of + * the calling task will be set. The parameter 'param' holds the priority + * of the thread under the new policy. + * + * This function is a simply wrapper around nxsched_getparam() that + * sets the errno value in the event of an error. + * + * Input Parameters: + * pid - the task ID of the task to modify. If pid is zero, the calling + * task is modified. + * policy - Scheduling policy requested (either SCHED_FIFO or SCHED_RR) + * param - A structure whose member sched_priority is the new priority. + * The range of valid priority numbers is from SCHED_PRIORITY_MIN + * through SCHED_PRIORITY_MAX. + * + * Returned Value: + * On success, sched_setscheduler() returns OK (zero). On error, ERROR + * (-1) is returned, and errno is set appropriately: + * + * EINVAL The scheduling policy is not one of the recognized policies. + * ESRCH The task whose ID is pid could not be found. + * + ****************************************************************************/ + +int sched_setscheduler(pid_t pid, int policy, + FAR const struct sched_param *param) +{ + int ret = nxsched_setscheduler(pid, policy, param); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + + return ret; +} diff --git a/sched/sched/sched_sporadic.c b/sched/sched/sched_sporadic.c index 666416cf7dd50f9dd7ad2b856e1581497e066b5d..d78faaa031d8c621d10b5ff806960150f7f03d80 100644 --- a/sched/sched/sched_sporadic.c +++ b/sched/sched/sched_sporadic.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_sporadic.c * - * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -129,7 +129,19 @@ static int sporadic_set_lowpriority(FAR struct tcb_s *tcb) #ifdef CONFIG_PRIORITY_INHERITANCE /* If the priority was boosted above the higher priority, than just - * reset the base priority. + * reset the base priority and continue to run at the boosted priority. + * + * REVISIT: There is a logic flaw here... If the priority was NOT + * boosted above the hi_priority, then it still may still need to + * boosted with respect to the lo_priority. If the highest priority + * thread waiting on a semaphore held by the sporadic thread is greater + * than the low priority (but less than the hi_priority), the new + * sched_priority should be set to that priority, not to the lo_priority + * + * In order to do this we would need to know the highest priority from + * among all tasks waiting for the all semaphores held by the sporadic + * task. That information could be retained by the priority inheritance + * logic of sem_holder.c for use here. */ if (tcb->sched_priority > tcb->base_priority) @@ -138,20 +150,21 @@ static int sporadic_set_lowpriority(FAR struct tcb_s *tcb) * state. */ - tcb->base_priority = sporadic->low_priority; + tcb->base_priority = tcb->low_priority; } + else #endif - - /* Otherwise drop the priority of thread, possible causing a context - * switch. - */ - - ret = sched_reprioritize(tcb, sporadic->low_priority); - if (ret < 0) { - int errcode = get_errno(); - serr("ERROR: sched_reprioritize failed: %d\n", errcode); - return -errcode; + /* Otherwise drop the priority of thread, possible causing a context + * switch. + */ + + ret = nxsched_reprioritize(tcb, sporadic->low_priority); + if (ret < 0) + { + serr("ERROR: nxsched_reprioritize failed: %d\n", ret); + return ret; + } } return OK; @@ -188,16 +201,27 @@ static int sporadic_set_hipriority(FAR struct tcb_s *tcb) #ifdef CONFIG_PRIORITY_INHERITANCE /* If the priority was boosted above the higher priority, than just * reset the base priority. + * + * First, was the priority boosted above the lo_priority which should be + * the same as the base_priority here? (This is an unnecessary test. + * sched_priority > hi_priority would be sufficient). */ if (tcb->sched_priority > tcb->base_priority) { - /* Boosted... Do we still need to reprioritize? */ + /* Boosted... Do we still need to reprioritize? If we were boosted to + * a priority above the hi_priority then we do not need to do anything + * except to adjust the base_priority + * + * REVISIT: This logic is probably okay. But may lead to problems + * when the hi_priority is resumed. See REVISIT comments in + * sporadic_set_lowpriority(). + */ - if (sporadic->hi_priority < sporadic->base_priority) + if (tcb->sched_priority > sporadic->hi_priority) { - /* No.. the current execution priority is lower than the - * boosted priority. Just reset the base priority. + /* No.. the new execution priority is lower than the boosted + * priority. Just reset the base priority. */ tcb->base_priority = sporadic->hi_priority; @@ -214,12 +238,11 @@ static int sporadic_set_hipriority(FAR struct tcb_s *tcb) /* Then reprioritize to the higher priority */ - ret = sched_reprioritize(tcb, sporadic->hi_priority); + ret = nxsched_reprioritize(tcb, sporadic->hi_priority); if (ret < 0) { - int errcode = get_errno(); - serr("ERROR: sched_reprioritize failed: %d\n", errcode); - return -errcode; + serr("ERROR: nxsched_reprioritize failed: %d\n", ret); + return ret; } return OK; @@ -322,7 +345,7 @@ static int sporadic_interval_start(FAR struct replenishment_s *mrepl) /* Start the timer that will terminate the low priority cycle. This timer * expiration is independent of what else may occur (except that it must - * be cancelled if the thread exits. + * be canceled if the thread exits. */ DEBUGVERIFY(wd_start(&mrepl->timer, remainder, sporadic_interval_expire, @@ -452,7 +475,7 @@ static void sporadic_budget_expire(int argc, wdparm_t arg1, ...) * this operation is needed. */ - if (sched_islocked(tcb)) + if (sched_islocked_tcb(tcb)) { DEBUGASSERT((mrepl->flags && SPORADIC_FLAG_ALLOCED) != 0 && sporadic->nrepls > 0); @@ -600,7 +623,7 @@ static void sporadic_replenish_expire(int argc, wdparm_t arg1, ...) * this operation is needed. */ - if (sched_islocked(tcb)) + if (sched_islocked_tcb(tcb)) { /* Set the timeslice to the magic value */ @@ -1199,7 +1222,7 @@ uint32_t sched_sporadic_process(FAR struct tcb_s *tcb, uint32_t ticks, /* Does the thread have the scheduler locked? */ sporadic = tcb->sporadic; - if (sched_islocked(tcb)) + if (sched_islocked_tcb(tcb)) { /* Yes... then we have no option but to give the thread more * time at the higher priority. Dropping the priority could diff --git a/sched/sched/sched_tasklistlock.c b/sched/sched/sched_tasklistlock.c new file mode 100644 index 0000000000000000000000000000000000000000..d8946d4b7407105df873107971a363195491cda1 --- /dev/null +++ b/sched/sched/sched_tasklistlock.c @@ -0,0 +1,133 @@ +/**************************************************************************** + * sched/sched/sched_tasklistlock.c + * + * Copyright (C) 2018 Sony Corporation. All rights reserved. + * Author: Masayuki Ishikawa + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include + +#include "sched/sched.h" + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Splinlock to protect the tasklists */ + +static volatile spinlock_t g_tasklist_lock SP_SECTION = SP_UNLOCKED; + +/* Handles nested calls */ + +static volatile uint8_t g_tasklist_lock_count[CONFIG_SMP_NCPUS]; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sched_tasklist_lock() + * + * Description: + * Disable local interrupts and take the global spinlock (g_tasklist_lock) + * if the call counter (g_tasklist_lock_count[cpu]) equals to 0. Then the + * counter on the CPU is incremented to allow nested call. + * + * NOTE: This API is used to protect tasklists in the scheduler. So do not + * use this API for other purposes. + * + * Returned Value: + * An opaque, architecture-specific value that represents the state of + * the interrupts prior to the call to sched_tasklist_lock(); + ****************************************************************************/ + +irqstate_t sched_tasklist_lock(void) +{ + int me; + irqstate_t ret; + + ret = up_irq_save(); + me = this_cpu(); + + if (0 == g_tasklist_lock_count[me]) + { + spin_lock(&g_tasklist_lock); + } + + g_tasklist_lock_count[me]++; + ASSERT(0 != g_tasklist_lock_count[me]); + return ret; +} + +/**************************************************************************** + * Name: sched_tasklist_unlock() + * + * Description: + * Decrement the call counter (g_tasklist_lock_count[cpu]) and if it + * decrements to zero then release the spinlock (g_tasklist_lock) and + * restore the interrupt state as it was prior to the previous call to + * sched_tasklist_lock(). + * + * NOTE: This API is used to protect tasklists in the scheduler. So do not + * use this API for other purposes. + * + * Input Parameters: + * lock - The architecture-specific value that represents the state of + * the interrupts prior to the call to sched_tasklist_lock(). + * + * Returned Value: + * None + ****************************************************************************/ + +void sched_tasklist_unlock(irqstate_t lock) +{ + int me; + + me = this_cpu(); + + ASSERT(0 < g_tasklist_lock_count[me]); + g_tasklist_lock_count[me]--; + + if (0 == g_tasklist_lock_count[me]) + { + spin_unlock(&g_tasklist_lock); + } + + up_irq_restore(lock); +} diff --git a/sched/sched/sched_thistask.c b/sched/sched/sched_thistask.c new file mode 100644 index 0000000000000000000000000000000000000000..c1471dfaa54e744365a3446d0f609e8e92c43003 --- /dev/null +++ b/sched/sched/sched_thistask.c @@ -0,0 +1,110 @@ +/**************************************************************************** + * sched/sched/sched_thistask.c + * + * Copyright (C) 2018 Sony Corporation. All rights reserved. + * Author: Masayuki Ishikawa + * Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "sched/sched.h" + +#ifdef CONFIG_SMP + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: this_task + * + * Description: + * The functions will safely obtain the TCB that is currently running + * on the current CPU. In SMP, this must be done by disabling local + * interrupts to avoid CPU switching during access to current_task() + * + * Return Value: + * the TCB that is currently running on the current CPU. + * + ****************************************************************************/ + +FAR struct tcb_s *this_task(void) +{ + FAR struct tcb_s *tcb; +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + irqstate_t flags; + + /* If the CPU supports suppression of interprocessor interrupts, then simple + * disabling interrupts will provide sufficient protection for the following + * operations. + */ + + flags = up_irq_save(); +#elif defined(CONFIG_ARCH_HAVE_FETCHADD) + /* Global locking is supported and, hence, sched_lock() will provide the + * necessary protection. + */ + + sched_lock(); +#else + /* REVISIT: Otherwise, there is no protection available. sched_lock() and + * enter_critical section are not viable options here (because both depend + * on this_task()). + */ +# warning "Missing critical section" +#endif + + /* Obtain the TCB which is currently running on this CPU */ + + tcb = current_task(this_cpu()); + + /* Enable local interrupts */ + +#if defined(CONFIG_ARCH_GLOBAL_IRQDISABLE) + up_irq_restore(flags); +#elif defined(CONFIG_ARCH_HAVE_FETCHADD) + sched_unlock(); +#endif + return tcb; +} + +#endif /* CONFIG_SMP */ diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_timerexpiration.c index d00150654ff2399eb99b1f51dd08683decc1db38..b1c137535a32e9de09cd1d70ed6980d451828e1a 100644 --- a/sched/sched/sched_timerexpiration.c +++ b/sched/sched/sched_timerexpiration.c @@ -162,12 +162,12 @@ static struct timespec g_stop_time; * Check for operations specific to scheduling policy of the currently * active task on a single CPU. * - * Inputs: + * Input Parameters: * cpu - The CPU that we are performing the scheduler operations on. * ticks - The number of ticks that have elapsed on the interval timer. * noswitches - True: Can't do context switches now. * - * Return Value: + * Returned Value: * The number if ticks remaining until the next time slice expires. * Zero is returned if there is no time slicing (i.e., the task at the * head of the ready-to-run list does not support round robin @@ -264,11 +264,11 @@ static uint32_t sched_cpu_scheduler(int cpu, uint32_t ticks, bool noswitches) * Check for operations specific to scheduling policy of the currently * active task on a single CPU. * - * Inputs: + * Input Parameters: * ticks - The number of ticks that have elapsed on the interval timer. * noswitches - True: Can't do context switches now. * - * Return Value: + * Returned Value: * The number if ticks remaining until the next time slice expires. * Zero is returned if there is no time slicing (i.e., the task at the * head of the ready-to-run list does not support round robin diff --git a/sched/sched/sched_unlock.c b/sched/sched/sched_unlock.c index df05975f506017f18a4db9a7b1c784b741cf4d13..88140cb3757931d873062d99e2dec4a536005266 100644 --- a/sched/sched/sched_unlock.c +++ b/sched/sched/sched_unlock.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/sched/sched_unlock.c * - * Copyright (C) 2007, 2009, 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2014, 2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -64,24 +65,26 @@ * ****************************************************************************/ +#ifdef CONFIG_SMP + int sched_unlock(void) { - FAR struct tcb_s *rtcb = this_task(); -#ifdef CONFIG_SMP + FAR struct tcb_s *rtcb; int cpu; + /* This operation is safe because the scheduler is locked and no context + * switch may occur. + */ + cpu = this_cpu(); rtcb = current_task(cpu); -#else - rtcb = this_task(); -#endif /* Check for some special cases: (1) rtcb may be NULL only during * early boot-up phases, and (2) sched_unlock() should have no * effect if called from the interrupt level. */ - if (rtcb && !up_interrupt_context()) + if (rtcb != NULL && !up_interrupt_context()) { /* Prevent context switches throughout the following. */ @@ -101,7 +104,7 @@ int sched_unlock(void) if (rtcb->lockcount <= 0) { #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION - /* Note that we no longer have pre-emption */ + /* Note that we no longer have pre-emption disabled. */ sched_note_premption(rtcb, false); #endif @@ -109,7 +112,6 @@ int sched_unlock(void) rtcb->lockcount = 0; -#ifdef CONFIG_SMP /* The lockcount has decremented to zero and we need to perform * release our hold on the lock. */ @@ -119,7 +121,6 @@ int sched_unlock(void) spin_clrbit(&g_cpu_lockset, cpu, &g_cpu_locksetlock, &g_cpu_schedlock); -#endif /* Release any ready-to-run tasks that have collected in * g_pendingtasks. @@ -128,7 +129,6 @@ int sched_unlock(void) * this task to be switched out! */ -#ifdef CONFIG_SMP /* In the SMP case, the tasks remains pend(1) if we are * in a critical section, i.e., g_cpu_irqlock is locked by other * CPUs, or (2) other CPUs still have pre-emption disabled, i.e., @@ -147,17 +147,135 @@ int sched_unlock(void) * BEFORE it clears IRQ lock. */ - if (!spin_islocked(&g_cpu_schedlock) && !irq_cpu_locked(cpu) && + if (!sched_islocked_global() && !irq_cpu_locked(cpu) && g_pendingtasks.head != NULL) -#else - /* In the single CPU case, decrementing irqcount to zero is + { + up_release_pending(); + } + +#if CONFIG_RR_INTERVAL > 0 + /* If (1) the task that was running supported round-robin + * scheduling and (2) if its time slice has already expired, but + * (3) it could not slice out because pre-emption was disabled, + * then we need to swap the task out now and reassess the interval + * timer for the next time slice. + */ + + if ((rtcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_RR && + rtcb->timeslice == 0) + { + /* Yes.. that is the situation. But one more thing. The call + * to up_release_pending() above may have actually replaced + * the task at the head of the read-to-run list. In that case, + * we need only to reset the timeslice value back to the + * maximum. + */ + + if (rtcb != current_task(cpu)) + { + rtcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); + } +#ifdef CONFIG_SCHED_TICKLESS + else + { + sched_timer_reassess(); + } +#endif + } +#endif + +#ifdef CONFIG_SCHED_SPORADIC +#if CONFIG_RR_INTERVAL > 0 + else +#endif + /* If (1) the task that was running supported sporadic scheduling + * and (2) if its budget slice has already expired, but (3) it + * could not slice out because pre-emption was disabled, then we + * need to swap the task out now and reassess the interval timer + * for the next time slice. + */ + + if ((rtcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_SPORADIC && + rtcb->timeslice < 0) + { + /* Yes.. that is the situation. Force the low-priority state + * now + */ + + sched_sporadic_lowpriority(rtcb); + +#ifdef CONFIG_SCHED_TICKLESS + /* Make sure that the call to up_release_pending() did not + * change the currently active task. + */ + + if (rtcb == current_task(cpu)) + { + sched_timer_reassess(); + } +#endif + } +#endif + } + + leave_critical_section(flags); + } + + return OK; +} + +#else /* CONFIG_SMP */ + +int sched_unlock(void) +{ + FAR struct tcb_s *rtcb = this_task(); + + /* Check for some special cases: (1) rtcb may be NULL only during + * early boot-up phases, and (2) sched_unlock() should have no + * effect if called from the interrupt level. + */ + + if (rtcb != NULL && !up_interrupt_context()) + { + /* Prevent context switches throughout the following. */ + + irqstate_t flags = enter_critical_section(); + + /* Decrement the preemption lock counter */ + + if (rtcb->lockcount > 0) + { + rtcb->lockcount--; + } + + /* Check if the lock counter has decremented to zero. If so, + * then pre-emption has been re-enabled. + */ + + if (rtcb->lockcount <= 0) + { +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION + /* Note that we no longer have pre-emption disabled. */ + + sched_note_premption(rtcb, false); +#endif + /* Set the lock count to zero */ + + rtcb->lockcount = 0; + + /* Release any ready-to-run tasks that have collected in + * g_pendingtasks. + * + * NOTE: This operation has a very high likelihood of causing + * this task to be switched out! + * + * In the single CPU case, decrementing irqcount to zero is * sufficient to release the pending tasks. Further, in that * configuration, critical sections and pre-emption can operate * fully independently. */ if (g_pendingtasks.head != NULL) -#endif { up_release_pending(); } @@ -232,3 +350,5 @@ int sched_unlock(void) return OK; } + +#endif /* CONFIG_SMP */ diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index 1763ee966f71257994dbdf4b84f99332a389dd16..faca0216aa031ab1ef5d3387c89d7bd7145c16a2 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -147,7 +147,7 @@ * stat_loc - The location to return the exit status * options - ignored * - * Return Value: + * Returned Value: * If waitpid() returns because the status of a child process is available, * it will return a value equal to the process ID of the child process for * which status is reported. diff --git a/sched/sched/sched_yield.c b/sched/sched/sched_yield.c index c55a925dac044a8b7899a140ab49a468a308cbfe..320de61c10ba7ed4f81a2141f2ca2410c7907247 100644 --- a/sched/sched/sched_yield.c +++ b/sched/sched/sched_yield.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_yield.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -54,10 +54,10 @@ * This function forces the calling task to give up the CPU (only to other * tasks at the same priority). * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * 0 (OK) or -1 (ERROR) (errno is not set) * * Assumptions: @@ -67,11 +67,14 @@ int sched_yield(void) { FAR struct tcb_s *rtcb = this_task(); + int ret; /* This equivalent to just resetting the task priority to its current value * since this will cause the task to be rescheduled behind any other tasks * at the same priority. */ - return sched_setpriority(rtcb, rtcb->sched_priority); + ret = nxsched_setpriority(rtcb, rtcb->sched_priority); + return ret < 0 ? ERROR : OK; } + diff --git a/sched/semaphore/sem_destroy.c b/sched/semaphore/sem_destroy.c index 5cc05f222c3d4de2f4d980ff378d16ecef4ee0e9..7c0522d29fc3d3bb1a05a8118d909df717d76d7f 100644 --- a/sched/semaphore/sem_destroy.c +++ b/sched/semaphore/sem_destroy.c @@ -65,7 +65,7 @@ * Parameters: * sem - Semaphore to be destroyed. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -119,7 +119,7 @@ int nxsem_destroy (FAR sem_t *sem) * Parameters: * sem - Semaphore to be destroyed. * - * Return Value: + * Returned Value: * This function is a application interface. It returns zero (OK) if * successful. Otherwise, -1 (ERROR) is returned and the errno value is * set appropriately. diff --git a/sched/semaphore/sem_holder.c b/sched/semaphore/sem_holder.c index 860032fb175f4aad3d49fb66170f425f73464ff4..9095f98e7f2ded89adf4a51ddb32004caeaec4ee 100644 --- a/sched/semaphore/sem_holder.c +++ b/sched/semaphore/sem_holder.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/semaphore/sem_holder.c * - * Copyright (C) 2009-2011, 2013, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2011, 2013, 2016-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -387,7 +388,7 @@ static int nxsem_boostholderprio(FAR struct semholder_s *pholder, * switch may occur during up_block_task() processing. */ - (void)sched_setpriority(htcb, rtcb->sched_priority); + (void)nxsched_setpriority(htcb, rtcb->sched_priority); } else { @@ -425,7 +426,7 @@ static int nxsem_boostholderprio(FAR struct semholder_s *pholder, * will occur during up_block_task() processing. */ - (void)sched_setpriority(htcb, rtcb->sched_priority); + (void)nxsched_setpriority(htcb, rtcb->sched_priority); } #endif @@ -535,7 +536,7 @@ static int nxsem_restoreholderprio(FAR struct tcb_s *htcb, /* Reset the holder's priority back to the base priority. */ - sched_reprioritize(htcb, htcb->base_priority); + (void)nxsched_reprioritize(htcb, htcb->base_priority); } /* There are multiple pending priority levels. The holder thread's @@ -577,7 +578,7 @@ static int nxsem_restoreholderprio(FAR struct tcb_s *htcb, * base_priority) */ - sched_setpriority(htcb, rpriority); + nxsched_setpriority(htcb, rpriority); } else { @@ -617,7 +618,7 @@ static int nxsem_restoreholderprio(FAR struct tcb_s *htcb, * priority. */ - sched_reprioritize(htcb, htcb->base_priority); + (void)nxsched_reprioritize(htcb, htcb->base_priority); #endif } @@ -716,7 +717,7 @@ static int nxsem_restoreholderprioB(FAR struct semholder_s *pholder, * - If it is >0 then there should be no threads waiting for counts and * stcb should be null. * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -777,7 +778,7 @@ static inline void nxsem_restorebaseprio_irq(FAR struct tcb_s *stcb, * - If it is >0 then there should be no threads waiting for counts and * stcb should be null. * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -847,7 +848,7 @@ static inline void nxsem_restorebaseprio_task(FAR struct tcb_s *stcb, * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -881,7 +882,7 @@ void nxsem_initholders(void) * Parameters: * sem - A reference to the semaphore being destroyed * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -932,7 +933,7 @@ void nxsem_destroyholder(FAR sem_t *sem) * htcb - TCB of the thread that just obtained the semaphore * sem - A reference to the incremented semaphore * - * Return Value: + * Returned Value: * 0 (OK) or -1 (ERROR) if unsuccessful * * Assumptions: @@ -975,7 +976,7 @@ void nxsem_addholder_tcb(FAR struct tcb_s *htcb, FAR sem_t *sem) * Parameters: * sem - A reference to the incremented semaphore * - * Return Value: + * Returned Value: * 0 (OK) or -1 (ERROR) if unsuccessful * * Assumptions: @@ -997,7 +998,7 @@ void nxsem_addholder(FAR sem_t *sem) * Parameters: * None * - * Return Value: + * Returned Value: * 0 (OK) or -1 (ERROR) if unsuccessful * * Assumptions: @@ -1026,7 +1027,7 @@ void nxsem_boostpriority(FAR sem_t *sem) * Parameters: * sem - A reference to the semaphore being posted * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -1076,7 +1077,7 @@ void nxsem_releaseholder(FAR sem_t *sem) * - If it is >0 then there should be no threads waiting for counts and * stcb should be null. * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -1121,7 +1122,7 @@ void nxsem_restorebaseprio(FAR struct tcb_s *stcb, FAR sem_t *sem) * Parameters: * sem - A reference to the semaphore no longer being waited for * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -1150,7 +1151,7 @@ void nxsem_canceled(FAR struct tcb_s *stcb, FAR sem_t *sem) * Parameters: * sem - A reference to the semaphore * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -1176,7 +1177,7 @@ void sem_enumholders(FAR sem_t *sem) * Parameters: * sem - A reference to the semaphore * - * Return Value: + * Returned Value: * The number of available holder containers * * Assumptions: diff --git a/sched/semaphore/sem_initialize.c b/sched/semaphore/sem_initialize.c index 769313781c78d3f4cfdacd7a4b564ee66d83425f..3b629de0a4bf0c1f49ac34f83e69d9e00ee4cb7b 100644 --- a/sched/semaphore/sem_initialize.c +++ b/sched/semaphore/sem_initialize.c @@ -59,7 +59,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/semaphore/sem_post.c b/sched/semaphore/sem_post.c index 08a399b916628382300cd6ca0d96f06ccda94420..67822aca194e529ec98ffcc936cb9362720f3329 100644 --- a/sched/semaphore/sem_post.c +++ b/sched/semaphore/sem_post.c @@ -74,7 +74,7 @@ * Parameters: * sem - Semaphore descriptor * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -165,6 +165,12 @@ int nxsem_post(FAR sem_t *sem) up_unblock_task(stcb); } + else + { + /* This should not happen. */ + + DEBUGPANIC(); + } } /* Check if we need to drop the priority of any threads holding @@ -205,7 +211,7 @@ int nxsem_post(FAR sem_t *sem) * Parameters: * sem - Semaphore descriptor * - * Return Value: + * Returned Value: * This function is a standard, POSIX application interface. It will * return zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. diff --git a/sched/semaphore/sem_recover.c b/sched/semaphore/sem_recover.c index bccb904e07b20d5172f6278a8cadd7bcf0716bcd..343ba330a956c7ecfe3eb4957be90a40e67b682a 100644 --- a/sched/semaphore/sem_recover.c +++ b/sched/semaphore/sem_recover.c @@ -64,10 +64,10 @@ * only the task, there is not mechanism to traverse all of the semaphores * with counts held by the task. * - * Inputs: + * Input Parameters: * tcb - The TCB of the terminated task or thread * - * Return Value: + * Returned Value: * None. * * Assumptions: @@ -105,7 +105,7 @@ void nxsem_recover(FAR struct tcb_s *tcb) nxsem_canceled(tcb, sem); /* And increment the count on the semaphore. This releases the count - * that was taken by sem_post(). This count decremented the semaphore + * that was taken by sem_wait(). This count decremented the semaphore * count to negative and caused the thread to be blocked in the first * place. */ diff --git a/sched/semaphore/sem_reset.c b/sched/semaphore/sem_reset.c index 28a0965a4cb86211c8f00c0b866737fc154d0c23..81f8fce83a40628033eecf1ea7b6c28e9cb7a26e 100644 --- a/sched/semaphore/sem_reset.c +++ b/sched/semaphore/sem_reset.c @@ -64,7 +64,7 @@ * sem - Semaphore descriptor to be reset * count - The requested semaphore count * - * Return Value: + * Returned Value: * This is an internal OS interface, not available to applications, and * hence follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. diff --git a/sched/semaphore/sem_setprotocol.c b/sched/semaphore/sem_setprotocol.c index f4b202b22bc5212ffe675bc6ccd19d43f1eea569..be98b88c1728b9a4b72d4945bdaaf503433a2745 100644 --- a/sched/semaphore/sem_setprotocol.c +++ b/sched/semaphore/sem_setprotocol.c @@ -82,7 +82,7 @@ * modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -153,7 +153,7 @@ int nxsem_setprotocol(FAR sem_t *sem, int protocol) * modified * protocol - The new protocol to use * - * Return Value: + * Returned Value: * This function is exposed as a non-standard application interface. It * returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. diff --git a/sched/semaphore/sem_tickwait.c b/sched/semaphore/sem_tickwait.c index 350a7a1cec3ea3ee739f5fd2858524e87540bc04..fd549e4aa372bd6d155f59ee03ff438f0e761773 100644 --- a/sched/semaphore/sem_tickwait.c +++ b/sched/semaphore/sem_tickwait.c @@ -76,7 +76,7 @@ * posted. If ticks is zero, then this function is equivalent * to nxsem_trywait(). * - * Return Value: + * Returned Value: * This is an internal OS interface, not available to applications, and * hence follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. diff --git a/sched/semaphore/sem_timedwait.c b/sched/semaphore/sem_timedwait.c index 98e5c84b2b726c133eb8bde51f732067649f9609..a5ae5116f4be16fa557bcdd586f1f131462123fc 100644 --- a/sched/semaphore/sem_timedwait.c +++ b/sched/semaphore/sem_timedwait.c @@ -86,7 +86,7 @@ * sem - Semaphore object * abstime - The absolute time to wait until a timeout is declared. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -235,7 +235,7 @@ errout_with_irqdisabled: * sem - Semaphore object * abstime - The absolute time to wait until a timeout is declared. * - * Return Value: + * Returned Value: * Zero (OK) is returned on success. On failure, -1 (ERROR) is returned * and the errno is set appropriately: * diff --git a/sched/semaphore/sem_timeout.c b/sched/semaphore/sem_timeout.c index 377793930b9be603cb453fa75df2cda552704703..d4ba2a0d88ebfe9d87be44beddc08ce72316e4b3 100644 --- a/sched/semaphore/sem_timeout.c +++ b/sched/semaphore/sem_timeout.c @@ -63,7 +63,7 @@ * argc - The number of arguments (should be 1) * pid - The task ID of the task to wakeup * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/semaphore/sem_trywait.c b/sched/semaphore/sem_trywait.c index e990427c456df611b6aa9b0b2e07528015ad6fd3..d7480e05406c4e61267666a280fb338dcad503f8 100644 --- a/sched/semaphore/sem_trywait.c +++ b/sched/semaphore/sem_trywait.c @@ -65,7 +65,7 @@ * Parameters: * sem - the semaphore descriptor * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -136,7 +136,7 @@ int nxsem_trywait(FAR sem_t *sem) * Parameters: * sem - the semaphore descriptor * - * Return Value: + * Returned Value: * Zero (OK) on success or -1 (ERROR) if unsuccessful. If this function * returns -1(ERROR), then the cause of the failure will be reported in * errno variable as: diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c index 5b2b8ceb5d8afb17b80aad9ee45da8eb838ea3a6..9bb1d3105c368e7a792ef190be7d589f5b7d6d41 100644 --- a/sched/semaphore/sem_wait.c +++ b/sched/semaphore/sem_wait.c @@ -72,7 +72,7 @@ * Parameters: * sem - Semaphore descriptor. * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -221,7 +221,7 @@ int nxsem_wait(FAR sem_t *sem) * Parameters: * sem - Semaphore descriptor. * - * Return Value: + * Returned Value: * This function is a standard, POSIX application interface. It returns * zero (OK) if successful. Otherwise, -1 (ERROR) is returned and * the errno value is set appropriately. Possible errno values include: diff --git a/sched/semaphore/sem_waitirq.c b/sched/semaphore/sem_waitirq.c index 4ca202f07e2cb16b4ffe213a8dc4df39bae6f43f..11254e8fcb6c76b769f95e4f9a9285d7615f8731 100644 --- a/sched/semaphore/sem_waitirq.c +++ b/sched/semaphore/sem_waitirq.c @@ -70,7 +70,7 @@ * errcode - EINTR if the semaphore wait was awakened by a signal; * ETIMEDOUT if awakened by a timeout * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/semaphore/spinlock.c b/sched/semaphore/spinlock.c index 674ebb6b522ace304b42c3f38efe011760343f19..6d58dfcc3cd719062cd356a0a015dfce7609d599 100644 --- a/sched/semaphore/spinlock.c +++ b/sched/semaphore/spinlock.c @@ -139,6 +139,38 @@ void spin_lock(FAR volatile spinlock_t *lock) SP_DMB(); } +/**************************************************************************** + * Name: spin_lock_wo_note + * + * Description: + * If this CPU does not already hold the spinlock, then loop until the + * spinlock is successfully locked. + * + * This implementation is the same as the above spin_lock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to lock. + * + * Returned Value: + * None. When the function returns, the spinlock was successfully locked + * by this CPU. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_lock_wo_note(FAR volatile spinlock_t *lock) +{ + while (up_testset(lock) == SP_LOCKED) + { + SP_DSB(); + } + + SP_DMB(); +} + /**************************************************************************** * Name: spin_unlock * @@ -171,6 +203,33 @@ void spin_unlock(FAR volatile spinlock_t *lock) } #endif +/**************************************************************************** + * Name: spin_unlock_wo_note + * + * Description: + * Release one count on a non-reentrant spinlock. + * + * This implementation is the same as the above spin_unlock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to unlock. + * + * Returned Value: + * None. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_unlock_wo_note(FAR volatile spinlock_t *lock) +{ + SP_DMB(); + *lock = SP_UNLOCKED; + SP_DSB(); +} + /**************************************************************************** * Name: spin_lockr * @@ -409,7 +468,7 @@ void spin_setbit(FAR volatile cpu_set_t *set, unsigned int cpu, irqstate_t flags; /* Disable local interrupts to prevent being re-entered from an interrupt - * on the same CPU. This does not effect the behavior on other CPUs. + * on the same CPU. This may not effect interrupt behavior on other CPUs. */ flags = up_irq_save(); @@ -468,7 +527,7 @@ void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu, irqstate_t flags; /* Disable local interrupts to prevent being re-entered from an interrupt - * on the same CPU. This does not effect the behavior on other CPUs. + * on the same CPU. This may not effect interrupt behavior on other CPUs. */ flags = up_irq_save(); diff --git a/sched/signal/sig_action.c b/sched/signal/sig_action.c index 1b2f3be67e0321aa39ed08ed63c89bd1d2c123c0..d40ec627ed87f7d6921fcd2bc19cb06dda135e81 100644 --- a/sched/signal/sig_action.c +++ b/sched/signal/sig_action.c @@ -139,7 +139,7 @@ static FAR sigactq_t *nxsig_alloc_action(void) * act - Location of new handler * oact - Location to store only handler * - * Return Value: + * Returned Value: * 0 (OK), or -1 (ERROR) if the signal number is invalid. * (errno is not set) * diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c index ebe31093aec44714d97ae4f15c762f1527385b02..67f834a75fa777c3c72e1695b2d917907b0983e1 100644 --- a/sched/signal/sig_dispatch.c +++ b/sched/signal/sig_dispatch.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/signal/sig_dispatch.c * - * Copyright (C) 2007, 2009, 2011, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -201,11 +202,11 @@ static FAR sigpendq_t * DEBUGASSERT(group != NULL); - /* Pending sigals can be added from interrupt level. */ + /* Pending signals can be added from interrupt level. */ flags = enter_critical_section(); - /* Seach the list for a sigpendion on this signal */ + /* Search the list for a action pending on this signal */ for (sigpend = (FAR sigpendq_t *)group->tg_sigpendingq.head; (sigpend && sigpend->info.si_signo != signo); @@ -345,9 +346,6 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info) else { -#ifdef CONFIG_SMP - int cpu; -#endif /* Queue any sigaction's requested by this task. */ ret = nxsig_queue_action(stcb, info); @@ -356,32 +354,13 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info) flags = enter_critical_section(); -#ifdef CONFIG_SMP - /* If the thread is running on another CPU, then pause that CPU. We can - * then setup the for signal delivery on the running thread. When the - * CPU is resumed, the signal handler will then execute. - */ - - cpu = sched_cpu_pause(stcb); -#endif /* CONFIG_SMP */ - /* Then schedule execution of the signal handling action on the - * recipient's thread. + * recipient's thread. SMP related handling will be done in + * up_schedule_sigaction() */ up_schedule_sigaction(stcb, nxsig_deliver); -#ifdef CONFIG_SMP - /* Resume the paused CPU (if any) */ - - if (cpu >= 0) - { - /* I am not yet sure how to handle a failure here. */ - - DEBUGVERIFY(up_cpu_resume(cpu)); - } -#endif /* CONFIG_SMP */ - /* Check if the task is waiting for an unmasked signal. If so, then * unblock it. This must be performed in a critical section because * signals can be queued from the interrupt level. @@ -434,7 +413,7 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info) * Description: * This is the front-end for nxsig_tcbdispatch that should be typically * be used to dispatch a signal. If HAVE_GROUP_MEMBERS is defined, - * then function will follow the group signal delivery algorthrims: + * then function will follow the group signal delivery algorithms: * * This front-end does the following things before calling * nxsig_tcbdispatch. diff --git a/sched/signal/sig_pending.c b/sched/signal/sig_pending.c index 7dc44fc4569904f5e3baad7e162333f44ef0b2c4..4dc27e0d988fd08a2c1d7d4623bee981ff28ca30 100644 --- a/sched/signal/sig_pending.c +++ b/sched/signal/sig_pending.c @@ -62,7 +62,7 @@ * Parameters: * set - The location to return the pending signal set. * - * Return Value: + * Returned Value: * 0 (OK) or -1 (ERROR) * * Assumptions: diff --git a/sched/signal/sig_procmask.c b/sched/signal/sig_procmask.c index 19bf70316e608d3bd61aee03dcbe4d9a70552d09..27f1d771025752002c6d361a4310c6ad6443f7e9 100644 --- a/sched/signal/sig_procmask.c +++ b/sched/signal/sig_procmask.c @@ -92,7 +92,7 @@ * set - Location of the new signal mask * oset - Location to store the old signal mask * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -197,7 +197,7 @@ int nxsig_procmask(int how, FAR const sigset_t *set, FAR sigset_t *oset) * set - Location of the new signal mask * oset - Location to store the old signal mask * - * Return Value: + * Returned Value: * This function will return 0 (OK) on success or -1 (ERROR) if how is * invalid. In the latter case, the errno variable will be set to EINVAL. * diff --git a/sched/signal/sig_queue.c b/sched/signal/sig_queue.c index 455b7ea72d50f76cda9cd82cef88a60fccd5cab3..00e08f26c0e32952be33588873f7bc43f29c9503 100644 --- a/sched/signal/sig_queue.c +++ b/sched/signal/sig_queue.c @@ -76,7 +76,7 @@ * signo - Signal number * value - Value to pass to task with signal * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -157,7 +157,7 @@ int nxsig_queue(int pid, int signo, void *sival_ptr) * signo - Signal number * value - Value to pass to task with signal * - * Return Value: + * Returned Value: * On success (at least one signal was sent), zero (OK) is returned. On * any failure, -1 (ERROR) is returned and errno varaible is set * appropriately: diff --git a/sched/signal/sig_suspend.c b/sched/signal/sig_suspend.c index 4bfc114b34973bcb19892a65ffefb30ef50cc1f0..8a8c068cdfc590128f35f0159b46a7d02394ca1c 100644 --- a/sched/signal/sig_suspend.c +++ b/sched/signal/sig_suspend.c @@ -75,7 +75,7 @@ * Parameters: * set - signal mask to use while suspended. * - * Return Value: + * Returned Value: * -1 (ERROR) always * * Assumptions: diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c index 948c91723d1da29de78af1727a21942fffe0ce8a..edc8a2c990a388b2275cdd187f753a51c5fd0c5c 100644 --- a/sched/signal/sig_timedwait.c +++ b/sched/signal/sig_timedwait.c @@ -226,7 +226,7 @@ void nxsig_wait_irq(FAR struct tcb_s *wtcb, int errcode) * info - The returned value (may be NULL). * timeout - The amount of time to wait (may be NULL) * - * Return Value: + * Returned Value: * This is an internal OS interface and should not be used by applications. * It follows the NuttX internal error return policy: Zero (OK) is * returned on success. A negated errno value is returned on failure. @@ -356,8 +356,8 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info, /* Start the watchdog */ - wd_start(rtcb->waitdog, waitticks, (wdentry_t)nxsig_timeout, - 1, wdparm.pvarg); + (void)wd_start(rtcb->waitdog, waitticks, + (wdentry_t)nxsig_timeout, 1, wdparm.pvarg); /* Now wait for either the signal or the watchdog */ @@ -483,7 +483,7 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info, * info - The returned value (may be NULL). * timeout - The amount of time to wait (may be NULL) * - * Return Value: + * Returned Value: * Signal number that cause the wait to be terminated, otherwise -1 (ERROR) * is returned with errno set to either: * diff --git a/sched/signal/sig_waitinfo.c b/sched/signal/sig_waitinfo.c index 92d11acf2860e324aa3f5d59b729e81589f26604..0bac27e33ff569bcef9577eb2724537789523dea 100644 --- a/sched/signal/sig_waitinfo.c +++ b/sched/signal/sig_waitinfo.c @@ -59,7 +59,7 @@ * set - The pending signal set * info - The returned value * - * Return Value: + * Returned Value: * Signal number that cause the wait to be terminated, otherwise -1 (ERROR) * is returned and the errno variable is set appropriately. * diff --git a/sched/task/task_activate.c b/sched/task/task_activate.c index 47791c7a259504439d6ef9554a674c2ccef133b8..18dad9c71f1442b024ff06576bf43042a7e8aa30 100644 --- a/sched/task/task_activate.c +++ b/sched/task/task_activate.c @@ -60,7 +60,7 @@ * Input Parameters: * tcb - The TCB for the task for the task (same as the task_init argument). * - * Return Value: + * Returned Value: * Always returns OK * ****************************************************************************/ diff --git a/sched/task/task_atexit.c b/sched/task/task_atexit.c index ba26f3ab8cc8d7927d368828159a8197c687f2e6..91c6c9c6394a8e2ba1503391d39445546117cf1f 100644 --- a/sched/task/task_atexit.c +++ b/sched/task/task_atexit.c @@ -82,7 +82,7 @@ * Input Parameters: * func - A pointer to the function to be called when the task exits. * - * Return Value: + * Returned Value: * Zero on success. Non-zero on failure. * ****************************************************************************/ diff --git a/sched/task/task_cancelpt.c b/sched/task/task_cancelpt.c index bcd03621a90a9c762d27a15926ac0ef9838b76d7..9220264278b4f82b61f476de374d43d4233edde0 100644 --- a/sched/task/task_cancelpt.c +++ b/sched/task/task_cancelpt.c @@ -103,7 +103,7 @@ * Input Parameters: * None * - * Returned Value + * Returned Value: * true is returned if a cancellation is pending but cannot be performed * now due to the nesting level. * @@ -194,7 +194,7 @@ bool enter_cancellation_point(void) * Input Parameters: * None * - * Returned Value + * Returned Value: * None * ****************************************************************************/ @@ -274,7 +274,7 @@ void leave_cancellation_point(void) * Input Parameters: * None * - * Returned Value + * Returned Value: * true is returned if a cancellation is pending but cannot be performed * now due to the nesting level. * diff --git a/sched/task/task_create.c b/sched/task/task_create.c index a1d07e1d8ecb6d28fa467085ac9399b2c873caa0..f09d04578c057abc271b7e00fac60afc471c4e11 100644 --- a/sched/task/task_create.c +++ b/sched/task/task_create.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/task/task_create.c * - * Copyright (C) 2007-2010, 2013-2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2010, 2013-2014, 2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -77,10 +78,10 @@ * should be terminated with a NULL argv[] value. If no * parameters are required, argv may be NULL. * - * Return Value: - * Returns the non-zero process ID of the new task or ERROR if memory is - * insufficient or the task cannot be created. The errno will be set to - * indicate the nature of the error (always ENOMEM). + * Returned Value: + * Returns the positive, non-zero process ID of the new task or a negated + * errno value to indicate the nature of any failure. If memory is + * insufficient or the task cannot be created -ENOMEM will be returned. * ****************************************************************************/ @@ -90,7 +91,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, { FAR struct task_tcb_s *tcb; pid_t pid; - int errcode; int ret; /* Allocate a TCB for the new task. */ @@ -99,19 +99,17 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, if (!tcb) { serr("ERROR: Failed to allocate TCB\n"); - errcode = ENOMEM; - goto errout; + return -ENOMEM; } +#ifdef HAVE_TASK_GROUP /* Allocate a new task group with privileges appropriate for the parent * thread type. */ -#ifdef HAVE_TASK_GROUP ret = group_allocate(tcb, ttype); if (ret < 0) { - errcode = -ret; goto errout_with_tcb; } #endif @@ -129,7 +127,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, ret = group_setuptaskfiles(tcb); if (ret < OK) { - errcode = -ret; goto errout_with_tcb; } } @@ -140,7 +137,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, ret = up_create_stack((FAR struct tcb_s *)tcb, stack_size, ttype); if (ret < OK) { - errcode = -ret; goto errout_with_tcb; } @@ -149,7 +145,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, ret = task_schedsetup(tcb, priority, task_start, entry, ttype); if (ret < OK) { - errcode = -ret; goto errout_with_tcb; } @@ -157,13 +152,12 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, (void)task_argsetup(tcb, name, argv); +#ifdef HAVE_TASK_GROUP /* Now we have enough in place that we can join the group */ -#ifdef HAVE_TASK_GROUP ret = group_initialize(tcb); if (ret < 0) { - errcode = -ret; goto errout_with_tcb; } #endif @@ -177,7 +171,8 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, ret = task_activate((FAR struct tcb_s *)tcb); if (ret < OK) { - errcode = get_errno(); + ret = -get_errno(); + DEBUGASSERT(ret < 0); /* The TCB was added to the active task list by task_schedsetup() */ @@ -189,16 +184,60 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority, errout_with_tcb: sched_releasetcb((FAR struct tcb_s *)tcb, ttype); - -errout: - set_errno(errcode); - return ERROR; + return ret; } /**************************************************************************** * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: nxtask_create + * + * Description: + * This function creates and activates a new task with a specified + * priority and returns its system-assigned ID. + * + * The entry address entry is the address of the "main" function of the + * task. This function will be called once the C environment has been + * set up. The specified function will be called with four arguments. + * Should the specified routine return, a call to exit() will + * automatically be made. + * + * Note that four (and only four) arguments must be passed for the spawned + * functions. + * + * nxtask_create() is identical to the function task_create(), differing + * only in its return value: This function does not modify the errno + * variable. This is a non-standard, internal OS function and is not + * intended for use by application logic. Applications should use + * task_create(). + * + * Input Parameters: + * name - Name of the new task + * priority - Priority of the new task + * stack_size - size (in bytes) of the stack needed + * entry - Entry point of a new task + * arg - A pointer to an array of input parameters. Up to + * CONFIG_MAX_TASK_ARG parameters may be provided. If fewer + * than CONFIG_MAX_TASK_ARG parameters are passed, the list + * should be terminated with a NULL argv[] value. If no + * parameters are required, argv may be NULL. + * + * Returned Value: + * Returns the positive, non-zero process ID of the new task or a negated + * errno value to indicate the nature of any failure. If memory is + * insufficient or the task cannot be created -ENOMEM will be returned. + * + ****************************************************************************/ + +int nxtask_create(FAR const char *name, int priority, + int stack_size, main_t entry, FAR char * const argv[]) +{ + return thread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_size, + entry, argv); +} + /**************************************************************************** * Name: task_create * @@ -226,10 +265,10 @@ errout: * should be terminated with a NULL argv[] value. If no * parameters are required, argv may be NULL. * - * Return Value: + * Returned Value: * Returns the non-zero process ID of the new task or ERROR if memory is - * insufficient or the task cannot be created. The errno will be set to - * indicate the nature of the error (always ENOMEM). + * insufficient or the task cannot be created. The errno will be set in + * the failure case to indicate the nature of the error. * ****************************************************************************/ @@ -237,8 +276,14 @@ errout: int task_create(FAR const char *name, int priority, int stack_size, main_t entry, FAR char * const argv[]) { - return thread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_size, - entry, argv); + int ret = nxtask_create(name, priority, stack_size, entry, argv); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + + return ret; } #endif @@ -251,10 +296,20 @@ int task_create(FAR const char *name, int priority, * configures the newly started thread to run in kernel model. * * Input Parameters: - * (same as task_create()) + * name - Name of the new task + * priority - Priority of the new task + * stack_size - size (in bytes) of the stack needed + * entry - Entry point of a new task + * arg - A pointer to an array of input parameters. Up to + * CONFIG_MAX_TASK_ARG parameters may be provided. If fewer + * than CONFIG_MAX_TASK_ARG parameters are passed, the list + * should be terminated with a NULL argv[] value. If no + * parameters are required, argv may be NULL. * - * Return Value: - * (same as task_create()) + * Returned Value: + * Returns the positive, non-zero process ID of the new task or a negated + * errno value to indicate the nature of any failure. If memory is + * insufficient or the task cannot be created -ENOMEM will be returned. * ****************************************************************************/ diff --git a/sched/task/task_exit.c b/sched/task/task_exit.c index 6a04073f2949167bcc282319035ee67b5fc3fc61..5972051f9b5f87dd340d2fb47e9f1c17a50f949a 100644 --- a/sched/task/task_exit.c +++ b/sched/task/task_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/task/task_exit.c * - * Copyright (C) 2008-2009, 2012-2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2014, 2016, 2018 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -69,10 +70,10 @@ * and task_restart(). In the last two cases, the task will be terminated * as though exit() were called. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * OK on success; or ERROR on failure * * Assumeptions: @@ -82,9 +83,24 @@ int task_exit(void) { - FAR struct tcb_s *dtcb = this_task(); + FAR struct tcb_s *dtcb; FAR struct tcb_s *rtcb; int ret; +#ifdef CONFIG_SMP + int cpu; + + /* Get the current CPU. By assumption, we are within a critical section + * and, hence, the CPU index will remain stable. + * + * Avoid using this_task() because it may assume a state that is not + * appropriate for an exiting task. + */ + + cpu = this_cpu(); + dtcb = current_task(cpu); +#else + dtcb = this_task(); +#endif /* Remove the TCB of the current task from the ready-to-run list. A context * switch will definitely be necessary -- that must be done by the @@ -95,7 +111,22 @@ int task_exit(void) */ (void)sched_removereadytorun(dtcb); + + /* Get the new task at the head of the ready to run list */ + +#ifdef CONFIG_SMP + rtcb = current_task(cpu); +#else rtcb = this_task(); +#endif + +#ifdef CONFIG_SMP + /* Because clearing the global IRQ control in sched_removereadytorun() + * was moved to sched_resume_scheduler(). So call the API here. + */ + + sched_resume_scheduler(rtcb); +#endif /* We are now in a bad state -- the head of the ready to run task list * does not correspond to the thread that is running. Disabling pre- diff --git a/sched/task/task_getgroup.c b/sched/task/task_getgroup.c index 34f52c2c9cc283e8e3c7435f20812d42cfcfc4d6..871d4b1f4ce0db1d8c258c77c59e3d9f2fadf7c5 100644 --- a/sched/task/task_getgroup.c +++ b/sched/task/task_getgroup.c @@ -60,7 +60,7 @@ * Parameters: * pid - The task ID to use in the lookup. * - * Return Value: + * Returned Value: * On success, a pointer to the group task structure is returned. This * function can fail only if there is no group that corresponds to the * groupd ID. diff --git a/sched/task/task_init.c b/sched/task/task_init.c index f9b7002d331aac0cd1726713b547f4667af19df1..2d15f84736eeed4be93587698ef4d47e98456e62 100644 --- a/sched/task/task_init.c +++ b/sched/task/task_init.c @@ -80,7 +80,7 @@ * should be terminated with a NULL argv[] value. If no * parameters are required, argv may be NULL. * - * Return Value: + * Returned Value: * OK on success; ERROR on failure with errno set appropriately. (See * task_schedsetup() for possible failure conditions). On failure, the * caller is responsible for freeing the stack memory and for calling diff --git a/sched/task/task_onexit.c b/sched/task/task_onexit.c index 6d3d47fce6b4df8fe667d36e3c22c3df1da7405c..135ed2b65750e8def4b5cdd8717c2bafdfa3d2b5 100644 --- a/sched/task/task_onexit.c +++ b/sched/task/task_onexit.c @@ -84,7 +84,7 @@ * arg - An argument that will be provided to the on_exit() function when * the task exits. * - * Return Value: + * Returned Value: * Zero on success. Non-zero on failure. * ****************************************************************************/ diff --git a/sched/task/task_posixspawn.c b/sched/task/task_posixspawn.c index 1922690aab1a75e5ce6c225a35aed28e827bf4c2..e3f11a8b991c57134abcd37829f68025ecdee904 100644 --- a/sched/task/task_posixspawn.c +++ b/sched/task/task_posixspawn.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/task/task_posixspawn.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -351,7 +352,8 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, pid, path, file_actions, attr, argv); /* If there are no file actions to be performed and there is no change to - * the signal mask, then start the new child task directly from the parent task. + * the signal mask, then start the new child task directly from the parent + * task. */ #ifndef CONFIG_DISABLE_SIGNALS @@ -390,14 +392,12 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, /* Get the priority of this (parent) task */ - ret = sched_getparam(0, ¶m); + ret = nxsched_getparam(0, ¶m); if (ret < 0) { - int errcode = get_errno(); - - serr("ERROR: sched_getparam failed: %d\n", errcode); + serr("ERROR: nxsched_getparam failed: %d\n", ret); spawn_semgive(&g_spawn_parmsem); - return errcode; + return -ret; } /* Disable pre-emption so that the proxy does not run until waitpid @@ -420,9 +420,8 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, (FAR char * const *)NULL); if (proxy < 0) { - ret = get_errno(); + ret = -proxy; serr("ERROR: Failed to start posix_spawn_proxy: %d\n", ret); - goto errout_with_lock; } diff --git a/sched/task/task_recover.c b/sched/task/task_recover.c index 7c6bee2114847f4094b8a11383a75213bd6c8224..c4fea9b9b09c3a9f1876abbe3ca10a9a2a7433e4 100644 --- a/sched/task/task_recover.c +++ b/sched/task/task_recover.c @@ -63,10 +63,10 @@ * via pthread_cancel. I checks checks for semaphores, message queue, and * watchdog timer resources stranded in bad conditions. * - * Inputs: + * Input Parameters: * tcb - The TCB of the terminated task or thread * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/task/task_reparent.c b/sched/task/task_reparent.c index 075a391940e3fde92b2ff560bcd99df860513e34..88f2bb8b459710017a2ae0ca44cfed535650ee26 100644 --- a/sched/task/task_reparent.c +++ b/sched/task/task_reparent.c @@ -64,7 +64,7 @@ * of the current parent task) * chpid - PID of the child to be reparented. * - * Return Value: + * Returned Value: * 0 (OK) on success; A negated errno value on failure. * ****************************************************************************/ diff --git a/sched/task/task_restart.c b/sched/task/task_restart.c index c7ad08e3843e77514dc4d6e320f339956f467e18..a8ff6570681a18ad14a3a492240273f9c047cdc0 100644 --- a/sched/task/task_restart.c +++ b/sched/task/task_restart.c @@ -63,11 +63,11 @@ * reinitialized with same ID, priority, original entry point, stack size, * and parameters it had when it was first started. * - * Inputs: + * Input Parameters: * pid - The task ID of the task to delete. An ID of zero signifies the * calling task. * - * Return Value: + * Returned Value: * OK on sucess; ERROR on failure. * * This function can fail if: diff --git a/sched/task/task_setcanceltype.c b/sched/task/task_setcanceltype.c index b7536f46258def3500035d15679728cdd732939a..3c08c5d320645b3bca9d91f92e087b0cf4ae5513 100644 --- a/sched/task/task_setcanceltype.c +++ b/sched/task/task_setcanceltype.c @@ -52,7 +52,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: task_setcancelstate + * Name: task_setcanceltype * * Description: * The task_setcanceltype() function atomically both sets the calling diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c index b05111709075c78d4f3962895aafc0c24275d5e3..8389e2bc544223c72964d51ebf680d1c89184bc8 100644 --- a/sched/task/task_setup.c +++ b/sched/task/task_setup.c @@ -57,6 +57,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* This is an artificial limit to detect error conditions where an argv[] * list is not properly terminated. */ @@ -81,10 +82,10 @@ static const char g_noname[] = ""; * Description: * This function assigns the next unique task ID to a task. * - * Inputs: + * Input Parameters: * tcb - TCB of task * - * Return: + * Returned Value: * OK on success; ERROR on failure (errno is not set) * ****************************************************************************/ @@ -343,7 +344,7 @@ static inline void task_dupdspace(FAR struct tcb_s *tcb) * entry - Thread user entry point * ttype - Type of the new thread: task, pthread, or kernel thread * - * Return Value: + * Returned Value: * OK on success; ERROR on failure. * * This function can only failure is it is unable to assign a new, unique @@ -445,10 +446,10 @@ static int thread_schedsetup(FAR struct tcb_s *tcb, int priority, * Assign the task name. * * Input Parameters: - * tcb - Address of the new task's TCB - * name - Name of the new task + * tcb - Address of the new task's TCB + * name - Name of the new task * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -490,7 +491,7 @@ static void task_namesetup(FAR struct task_tcb_s *tcb, FAR const char *name) * terminated with a NULL argv[] value. If no parameters are * required, argv may be NULL. * - * Return Value: + * Returned Value: * Zero (OK) on success; a negated errno on failure. * ****************************************************************************/ @@ -630,7 +631,7 @@ static inline int task_stackargsetup(FAR struct task_tcb_s *tcb, * main - Application start point of the new task * ttype - Type of the new thread: task or kernel thread * - * Return Value: + * Returned Value: * OK on success; ERROR on failure. * * This function can only failure is it is unable to assign a new, unique @@ -657,13 +658,13 @@ int task_schedsetup(FAR struct task_tcb_s *tcb, int priority, start_t start, * pthread_schedsetup() is called from pthread_create(), * * Input Parameters: - * tcb - Address of the new task's TCB - * priority - Priority of the new task - * start - Start-up function (probably pthread_start()) - * entry - Entry point of the new pthread - * ttype - Type of the new thread: task, pthread, or kernel thread + * tcb - Address of the new task's TCB + * priority - Priority of the new task + * start - Start-up function (probably pthread_start()) + * entry - Entry point of the new pthread + * ttype - Type of the new thread: task, pthread, or kernel thread * - * Return Value: + * Returned Value: * OK on success; ERROR on failure. * * This function can only failure is it is unable to assign a new, unique @@ -700,16 +701,15 @@ int pthread_schedsetup(FAR struct pthread_tcb_s *tcb, int priority, * task runs in. * * Input Parameters: - * tcb - Address of the new task's TCB - * name - Name of the new task (not used) - * argv - A pointer to an array of input parameters. - * Up to CONFIG_MAX_TASK_ARG parameters may be - * provided. If fewer than CONFIG_MAX_TASK_ARG - * parameters are passed, the list should be - * terminated with a NULL argv[] value. - * If no parameters are required, argv may be NULL. - * - * Return Value: + * tcb - Address of the new task's TCB + * name - Name of the new task (not used) + * argv - A pointer to an array of input parameters. Up to + * CONFIG_MAX_TASK_ARG parameters may be provided. If fewer than + * CONFIG_MAX_TASK_ARG parameters are passed, the list should be + * terminated with a NULL argv[] value. If no parameters are + * required, argv may be NULL. + * + * Returned Value: * OK * ****************************************************************************/ diff --git a/sched/task/task_spawn.c b/sched/task/task_spawn.c index 852585d8c8e0bb3eeef03782dff810dae53d1a1a..4e6120a63ab89cb73018b0d5f6e01e56e55eaca9 100644 --- a/sched/task/task_spawn.c +++ b/sched/task/task_spawn.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/task/task_spawn.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,9 @@ #include #include +#include +#include + #include "sched/sched.h" #include "group/group.h" #include "task/spawn.h" @@ -123,9 +126,10 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name, /* Set the default priority to the same priority as this task */ - ret = sched_getparam(0, ¶m); + ret = nxsched_getparam(0, ¶m); if (ret < 0) { + ret = -ret; goto errout; } @@ -135,11 +139,11 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name, /* Start the task */ - pid = task_create(name, priority, stacksize, entry, argv); + pid = nxtask_create(name, priority, stacksize, entry, argv); if (pid < 0) { - ret = get_errno(); - serr("ERROR: task_create failed: %d\n", ret); + ret = -pid; + serr("ERROR: nxtask_create failed: %d\n", ret); goto errout; } @@ -378,14 +382,12 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry, /* Get the priority of this (parent) task */ - ret = sched_getparam(0, ¶m); + ret = nxsched_getparam(0, ¶m); if (ret < 0) { - int errcode = get_errno(); - - serr("ERROR: sched_getparam failed: %d\n", errcode); + serr("ERROR: nxsched_getparam failed: %d\n", ret); spawn_semgive(&g_spawn_parmsem); - return errcode; + return -ret; } /* Disable pre-emption so that the proxy does not run until waitpid @@ -402,15 +404,14 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry, * task. */ - proxy = task_create("task_spawn_proxy", param.sched_priority, - CONFIG_POSIX_SPAWN_PROXY_STACKSIZE, - (main_t)task_spawn_proxy, - (FAR char * const *)NULL); + proxy = nxtask_create("task_spawn_proxy", param.sched_priority, + CONFIG_POSIX_SPAWN_PROXY_STACKSIZE, + (main_t)task_spawn_proxy, + (FAR char * const *)NULL); if (proxy < 0) { - ret = get_errno(); + ret = -proxy; serr("ERROR: Failed to start task_spawn_proxy: %d\n", ret); - goto errout_with_lock; } diff --git a/sched/task/task_spawnparms.c b/sched/task/task_spawnparms.c index 1a9e5f79fcdd4f1415a3df2f425cd833c18a4930..20dd13de3ad05ca8a62b813872f671a9c7d0ed96 100644 --- a/sched/task/task_spawnparms.c +++ b/sched/task/task_spawnparms.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/task/task_spawnparms.c * - * Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -194,7 +194,7 @@ void spawn_semtake(FAR sem_t *sem) * attr - The attributes to use * * Returned Value: - * Errors are not reported by this function. This is because errors + * Errors are not reported by this function. This is not because errors * cannot occur, but rather that the new task has already been started * so there is no graceful way to handle errors detected in this context * (unless we delete the new task and recover). @@ -208,6 +208,7 @@ void spawn_semtake(FAR sem_t *sem) int spawn_execattrs(pid_t pid, FAR const posix_spawnattr_t *attr) { struct sched_param param; + int ret; DEBUGASSERT(attr); @@ -223,17 +224,14 @@ int spawn_execattrs(pid_t pid, FAR const posix_spawnattr_t *attr) if ((attr->flags & POSIX_SPAWN_SETSCHEDPARAM) != 0) { #ifdef CONFIG_SCHED_SPORADIC - int ret; - /* Get the current sporadic scheduling parameters. Those will not be * modified. */ - ret = sched_getparam(pid, ¶m); + ret = nxsched_getparam(pid, ¶m); if (ret < 0) { - int errcode = get_errno(); - return -errcode; + return ret; } #endif @@ -242,7 +240,7 @@ int spawn_execattrs(pid_t pid, FAR const posix_spawnattr_t *attr) param.sched_priority = attr->priority; /* If we are setting *both* the priority and the scheduler, - * then we will call sched_setscheduler() below. + * then we will call nxsched_setscheduler() below. */ if ((attr->flags & POSIX_SPAWN_SETSCHEDULER) == 0) @@ -250,18 +248,26 @@ int spawn_execattrs(pid_t pid, FAR const posix_spawnattr_t *attr) sinfo("Setting priority=%d for pid=%d\n", param.sched_priority, pid); - (void)sched_setparam(pid, ¶m); + ret = nxsched_setparam(pid, ¶m); + if (ret < 0) + { + return ret; + } } } /* If we are only changing the scheduling policy, then reset * the priority to the default value (the same as this thread) in - * preparation for the sched_setscheduler() call below. + * preparation for the nxsched_setscheduler() call below. */ else if ((attr->flags & POSIX_SPAWN_SETSCHEDULER) != 0) { - (void)sched_getparam(0, ¶m); + ret = nxsched_getparam(0, ¶m); + if (ret < 0) + { + return ret; + } } /* Are we setting the scheduling policy? If so, use the priority @@ -283,7 +289,7 @@ int spawn_execattrs(pid_t pid, FAR const posix_spawnattr_t *attr) param.sched_ss_init_budget.tv_sec = attr->budget.tv_sec; param.sched_ss_init_budget.tv_nsec = attr->budget.tv_nsec; #endif - (void)sched_setscheduler(pid, attr->policy, ¶m); + (void)nxsched_setscheduler(pid, attr->policy, ¶m); } return OK; diff --git a/sched/task/task_start.c b/sched/task/task_start.c index b1f1e3cd1a8c7e83b46cd82d039bc7b69e9ea848..a0c88329e52282fe32844c85cd44760fd0c70a11 100644 --- a/sched/task/task_start.c +++ b/sched/task/task_start.c @@ -70,10 +70,10 @@ * execution of a task. It receives initial control when the task is * started and calls main entry point of the newly started task. * - * Inputs: + * Input Parameters: * None * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/task/task_starthook.c b/sched/task/task_starthook.c index 6bf8de96955d1b3e2cb97baff8b1863817066535..908629a646e4d43e308c2ba8ba1b78970968cbeb 100644 --- a/sched/task/task_starthook.c +++ b/sched/task/task_starthook.c @@ -58,12 +58,12 @@ * The start hook is useful, for example, for setting up automatic * configuration of C++ constructors. * - * Inputs: + * Input Parameters: * tcb - The new, unstarted task task that needs the start hook * starthook - The pointer to the start hook function * arg - The argument to pass to the start hook function. * - * Return: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/task/task_terminate.c b/sched/task/task_terminate.c index 2edb7492779e72a3accfbd02f0cf67b18a05a925..8215d70f9c6454e6df21d0ff73a2902248595ce6 100644 --- a/sched/task/task_terminate.c +++ b/sched/task/task_terminate.c @@ -84,13 +84,13 @@ * exit() and pthread_exit(). In those cases task_exithook() has already * been called with nonblocking == false; * - * Inputs: + * Input Parameters: * pid - The task ID of the task to delete. A pid of zero * signifies the calling task. * nonblocking - True: The task is an unhealthy, partially torn down * state and is not permitted to block. * - * Return Value: + * Returned Value: * OK on success; or ERROR on failure * * This function can fail if the provided pid does not correspond to a diff --git a/sched/task/task_vfork.c b/sched/task/task_vfork.c index 7c15868cc93f47998dd686c29d72357ff0958c25..124a7fd077991b55742c0ea628ba7f7fc884b577 100644 --- a/sched/task/task_vfork.c +++ b/sched/task/task_vfork.c @@ -57,6 +57,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* vfork() requires architecture-specific support as well as waipid(). */ #if defined(CONFIG_ARCH_HAVE_VFORK) && defined(CONFIG_SCHED_WAITPID) @@ -81,7 +82,7 @@ * tcb - Address of the new task's TCB * name - Name of the new task * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -109,7 +110,7 @@ static inline void vfork_namesetup(FAR struct tcb_s *parent, * parent - Address of the parent task's TCB * child - Address of the child task's TCB * - * Return Value: + * Returned Value: * Zero (OK) on success; a negated errno on failure. * ****************************************************************************/ @@ -176,7 +177,7 @@ static inline int vfork_stackargsetup(FAR struct tcb_s *parent, * parent - Address of the parent task's TCB * child - Address of the child task's TCB * - * Return Value: + * Returned Value: * Zero (OK) on success; a negated errno on failure. * ****************************************************************************/ diff --git a/sched/timer/timer_create.c b/sched/timer/timer_create.c index e6c775093d2dac195cc485626e23c7248793a0ce..f842690a9274f4f53768b320a956356848f155d1 100644 --- a/sched/timer/timer_create.c +++ b/sched/timer/timer_create.c @@ -146,7 +146,7 @@ static FAR struct posix_timer_s *timer_allocate(void) * asynchronous notification. evp may be NULL (see above). * timerid - The pre-thread timer created by the call to timer_create(). * - * Return Value: + * Returned Value: * If the call succeeds, timer_create() will return 0 (OK) and update the * location referenced by timerid to a timer_t, which can be passed to the * other per-thread timer calls. If an error occurs, the function will diff --git a/sched/timer/timer_delete.c b/sched/timer/timer_delete.c index 6d6e5bebc12fefcf0932c522a7efc5e29242eff5..63a189427db3e7d982fb5c8fd0ffa5748ef3bd57 100644 --- a/sched/timer/timer_delete.c +++ b/sched/timer/timer_delete.c @@ -64,7 +64,7 @@ * timerid - The per-thread timer, previously created by the call to * timer_create(), to be deleted. * - * Return Value: + * Returned Value: * If the call succeeds, timer_create() will return 0 (OK). Otherwise, * the function will return a value of -1 (ERROR) and set errno to * indicate the error. diff --git a/sched/timer/timer_getoverrun.c b/sched/timer/timer_getoverrun.c index da07dcedcacc5936ebed171a04559cce88a8b443..c5aaee879980c85a465874f1f33caabd46a4c613 100644 --- a/sched/timer/timer_getoverrun.c +++ b/sched/timer/timer_getoverrun.c @@ -76,7 +76,7 @@ * timerid - The pre-thread timer, previously created by the call to * timer_create(), whose overrun count will be returned.. * - * Return Value: + * Returned Value: * If the timer_getoverrun() function succeeds, it will return the timer * expiration overrun count as explained above. timer_getoverrun() will * fail if: diff --git a/sched/timer/timer_gettime.c b/sched/timer/timer_gettime.c index 25e016876552f7303729f4c0aa219209a1e15826..138b7a5f7d8aae5739c6e96350b1730afb1c904d 100644 --- a/sched/timer/timer_gettime.c +++ b/sched/timer/timer_gettime.c @@ -68,7 +68,7 @@ * timerid - The pre-thread timer, previously created by the call to * timer_create(), whose remaining time count will be returned.. * - * Return Value: + * Returned Value: * If the timer_gettime() succeeds, a value of 0 (OK) will be returned. * If an error occurs, the value -1 (ERROR) will be returned, and errno * set to indicate the error. diff --git a/sched/timer/timer_initialize.c b/sched/timer/timer_initialize.c index 25a64b1a51afef22525b569370b96694350f320b..1ab262c26e972c9573f05bbd9684bedf03531ddd 100644 --- a/sched/timer/timer_initialize.c +++ b/sched/timer/timer_initialize.c @@ -91,7 +91,7 @@ volatile sq_queue_t g_alloctimers; * Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -132,7 +132,7 @@ void weak_function timer_initialize(void) * Parameters: * pid - the task ID of the thread that exited * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/timer/timer_release.c b/sched/timer/timer_release.c index 2608092a16f9a2da6bd8f0bdca6eed5cdd9f99fc..eef4fcae6af522397d03a6f1f2b72e46924d2cdd 100644 --- a/sched/timer/timer_release.c +++ b/sched/timer/timer_release.c @@ -106,7 +106,7 @@ static inline void timer_free(struct posix_timer_s *timer) * timer - The per-thread timer, previously created by the call to * timer_create(), to be deleted. * - * Return Value: + * Returned Value: * If the call succeeds, timer_release() will return 0 (OK) or 1 (meaning * that the timer is still valid). Otherwise, the function will return a * negated errno value: diff --git a/sched/timer/timer_settime.c b/sched/timer/timer_settime.c index 9be2104c3560c9fae47d52585264e70026887f77..3311de1c7f58b0cc6b42fe739d196e321dbf635a 100644 --- a/sched/timer/timer_settime.c +++ b/sched/timer/timer_settime.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/timer/timer_settime.c * - * Copyright (C) 2007-2010, 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2010, 2013-2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -76,7 +77,7 @@ static void timer_timeout(int argc, wdparm_t itimer); * Parameters: * timer - A reference to the POSIX timer that just timed out * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -131,7 +132,7 @@ static inline void timer_signotify(FAR struct posix_timer_s *timer) * Parameters: * timer - A reference to the POSIX timer that just timed out * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -164,7 +165,7 @@ static inline void timer_restart(FAR struct posix_timer_s *timer, * itimer - A reference to the POSIX timer that just timed out * signo - The signal to use to wake up the task * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -283,7 +284,7 @@ static void timer_timeout(int argc, wdparm_t itimer) * ovalue - A location in which to return the time remaining from the * previous timer setting. (ignored) * - * Return Value: + * Returned Value: * If the timer_settime() succeeds, a value of 0 (OK) will be returned. * If an error occurs, the value -1 (ERROR) will be returned, and errno set * to indicate the error. @@ -390,6 +391,15 @@ int timer_settime(timer_t timerid, int flags, timer->pt_last = delay; ret = wd_start(timer->pt_wdog, delay, (wdentry_t)timer_timeout, 1, (uint32_t)((wdparm_t)timer)); + if (ret < 0) + { + set_errno(-ret); + ret = ERROR; + } + else + { + ret = OK; + } } leave_critical_section(intflags); diff --git a/sched/wdog/wd_cancel.c b/sched/wdog/wd_cancel.c index 040385d31d50c39abc556cc974fbe73ebdfbc379..6eaab00c3be2383e131c8460ff933efaa4a935af 100644 --- a/sched/wdog/wd_cancel.c +++ b/sched/wdog/wd_cancel.c @@ -64,7 +64,7 @@ * Parameters: * wdog - ID of the watchdog to cancel. * - * Return Value: + * Returned Value: * Zero (OK) is returned on success; A negated errno value is returned to * indicate the nature of any failure. * diff --git a/sched/wdog/wd_create.c b/sched/wdog/wd_create.c index 8bd64961536c7a953d7f5689c140c3533f2c7275..bc8509bad70a9a108610c0abbea6a7a5dad81f55 100644 --- a/sched/wdog/wd_create.c +++ b/sched/wdog/wd_create.c @@ -63,7 +63,7 @@ * Parameters: * None * - * Return Value: + * Returned Value: * Pointer to watchdog (i.e., the watchdog ID), or NULL if insufficient * watchdogs are available. * diff --git a/sched/wdog/wd_delete.c b/sched/wdog/wd_delete.c index a497c1146e05dc15ca25f6fe232d7464d56ab07b..46fe6cef5aaf6bc4cc4cefd72c64bdf5c474965e 100644 --- a/sched/wdog/wd_delete.c +++ b/sched/wdog/wd_delete.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/wdog/wd_delete.c * - * Copyright (C) 2007-2009, 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014, 2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -66,8 +67,9 @@ * wdog - The watchdog ID to delete. This is actually a pointer to a * watchdog structure. * - * Return Value: - * Returns OK or ERROR + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is return to + * indicate the nature of any failure. * * Assumptions: * The caller has assured that the watchdog is no longer in use. @@ -113,9 +115,7 @@ int wd_delete(WDOG_ID wdog) sched_kfree(wdog); } - /* This was a pre-allocated timer. This function should not be called for - * statically allocated timers. - */ + /* Check if this is pre-allocated timer. */ else if (!WDOG_ISSTATIC(wdog)) { @@ -129,6 +129,13 @@ int wd_delete(WDOG_ID wdog) leave_critical_section(flags); } + /* This function should not be called for statically allocated timers. */ + + else + { + leave_critical_section(flags); + } + /* Return success */ return OK; diff --git a/sched/wdog/wd_gettime.c b/sched/wdog/wd_gettime.c index 0e48dec2f3888b969b34284c4e2b8c8e213290dd..1a5c31f9ccc0951269d69b8eb762624cdc9d00fd 100644 --- a/sched/wdog/wd_gettime.c +++ b/sched/wdog/wd_gettime.c @@ -58,7 +58,7 @@ * Parameters: * wdog - watchdog ID * - * Return Value: + * Returned Value: * The time in system ticks remaining until the watchdog time expires. * Zero means either that wdog is not valid or that the wdog has already * expired. diff --git a/sched/wdog/wd_initialize.c b/sched/wdog/wd_initialize.c index 54b98e4838431a9c24ebc511b9a3453a50763ce5..17e1e001a590925d9d268d34fe663412b7ce2c6f 100644 --- a/sched/wdog/wd_initialize.c +++ b/sched/wdog/wd_initialize.c @@ -90,7 +90,7 @@ static struct wdog_s g_wdpool[CONFIG_PREALLOC_WDOGS]; * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: diff --git a/sched/wdog/wd_recover.c b/sched/wdog/wd_recover.c index 2a4847471b3e61c023ba520d329723bcd70aa0be..4b2e28368bcac8cc2d2be82eda3834329e32885f 100644 --- a/sched/wdog/wd_recover.c +++ b/sched/wdog/wd_recover.c @@ -58,10 +58,10 @@ * task_delete() or via pthread_cancel(). It checks if the deleted task * is waiting for a timed event and if so cancels the timeout * - * Inputs: + * Input Parameters: * tcb - The TCB of the terminated task or thread * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index f94f9c2320716a78150ecf3436d17829bcf776c1..ec7fa96ec9d3804cea70c0264a26b217a0356f23 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/wdog/wd_start.c * - * Copyright (C) 2007-2009, 2012, 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012, 2014, 2016, 2018 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -100,11 +101,9 @@ typedef void (*wdentry4_t)(int argc, wdparm_t arg1, wdparm_t arg2, * Parameters: * None * - * Return Value: + * Returned Value: * None * - * Assumptions: - * ****************************************************************************/ static inline void wd_expiration(void) @@ -210,8 +209,9 @@ static inline void wd_expiration(void) * wdentry - function to call on timeout * parm1..4 - parameters to pass to wdentry * - * Return Value: - * OK or ERROR + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is return to + * indicate the nature of any failure. * * Assumptions: * The watchdog routine runs in the context of the timer interrupt handler @@ -229,12 +229,11 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...) irqstate_t flags; int i; - /* Verify the wdog */ + /* Verify the wdog and setup parameters */ - if (!wdog || argc > CONFIG_MAX_WDOGPARMS || delay < 0) + if (wdog == NULL || argc > CONFIG_MAX_WDOGPARMS || delay < 0) { - set_errno(EINVAL); - return ERROR; + return -EINVAL; } /* Check if the watchdog has been started. If so, stop it. @@ -407,7 +406,7 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...) * this function is called on each timer interrupt and a value of one * is implicit. * - * Return Value: + * Returned Value: * If CONFIG_SCHED_TICKLESS is defined then the number of ticks for the * next delay is provided (zero if no delay). Otherwise, this function * has no returned value. diff --git a/sched/wdog/wdog.h b/sched/wdog/wdog.h index 4b51b2355f8cb7cbc5dc4383676445e601464e49..aed26579395a7ed61b3af17ab5cd77ae02ada0d0 100644 --- a/sched/wdog/wdog.h +++ b/sched/wdog/wdog.h @@ -93,7 +93,7 @@ extern uint16_t g_wdnfree; * Parameters: * None * - * Return Value: + * Returned Value: * None * * Assumptions: @@ -120,7 +120,7 @@ void weak_function wd_initialize(void); * this function is called on each timer interrupt and a value of one * is implicit. * - * Return Value: + * Returned Value: * If CONFIG_SCHED_TICKLESS is defined then the number of ticks for the * next delay is provided (zero if no delay). Otherwise, this function * has no returned value. @@ -144,10 +144,10 @@ void wd_timer(void); * task_delete() or via pthread_cancel(). It checks if the deleted task * is waiting for a timed event and if so cancels the timeout * - * Inputs: + * Input Parameters: * tcb - The TCB of the terminated task or thread * - * Return Value: + * Returned Value: * None. * * Assumptions: diff --git a/sched/wqueue/kwork_cancel.c b/sched/wqueue/kwork_cancel.c index 659d9688b7010e662b32c24a5614ceda8f6d1727..526a3d906aade2cdb5f59a039268d0aa9a6264ee 100644 --- a/sched/wqueue/kwork_cancel.c +++ b/sched/wqueue/kwork_cancel.c @@ -63,7 +63,7 @@ * After work has been cancelled, it may be re-queue by calling work_queue() * again. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * work - The previously queue work structure to cancel * @@ -124,7 +124,7 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, * user mode work queue. After work has been cancelled, it may be re-queue * by calling work_queue() again. * - * Input parameters: + * Input Parameters: * qid - The work queue ID (must be HPWORK or LPWORK) * work - The previously queue work structure to cancel * diff --git a/sched/wqueue/kwork_hpthread.c b/sched/wqueue/kwork_hpthread.c index 8a3d3f0e88f39d1dae8e2b95da1175c74dd7aa7e..a923ad1122944931ea75b484cc7ef52ed3e87b3f 100644 --- a/sched/wqueue/kwork_hpthread.c +++ b/sched/wqueue/kwork_hpthread.c @@ -82,7 +82,7 @@ struct hp_wqueue_s g_hpwork; * bring up. This entry point is referenced by OS internally and should * not be accessed by application logic. * - * Input parameters: + * Input Parameters: * argc, argv (not used) * * Returned Value: @@ -132,7 +132,7 @@ static int work_hpthread(int argc, char *argv[]) * Description: * Start the high-priority, kernel-mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -162,11 +162,8 @@ int work_hpstart(void) DEBUGASSERT(pid > 0); if (pid < 0) { - int errcode = errno; - DEBUGASSERT(errcode > 0); - - serr("ERROR: kthread_create failed: %d\n", errcode); - return -errcode; + serr("ERROR: kthread_create failed: %d\n", (int)pid); + return (int)pid; } g_hpwork.worker[0].pid = pid; diff --git a/sched/wqueue/kwork_inherit.c b/sched/wqueue/kwork_inherit.c index 31c23b258b7f1867aa98b00fec3e1158aac1c56e..6647a415c7e2c50e25057feaaa01d82b6c605a34 100644 --- a/sched/wqueue/kwork_inherit.c +++ b/sched/wqueue/kwork_inherit.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/work/work_inherit.c * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ * Parameters: * reqprio - Requested minimum worker thread priority * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -123,7 +123,7 @@ static void lpwork_boostworker(pid_t wpid, uint8_t reqprio) * sched_unblock() processing. */ - (void)sched_setpriority(wtcb, reqprio); + (void)nxsched_setpriority(wtcb, reqprio); } else { @@ -160,7 +160,7 @@ static void lpwork_boostworker(pid_t wpid, uint8_t reqprio) * sched_unlock() processing. */ - (void)sched_setpriority(wtcb, reqprio); + (void)nxsched_setpriority(wtcb, reqprio); } #endif } @@ -178,7 +178,7 @@ static void lpwork_boostworker(pid_t wpid, uint8_t reqprio) * reqprio - Previously requested minimum worker thread priority to be * "unboosted" * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -223,7 +223,7 @@ static void lpwork_restoreworker(pid_t wpid, uint8_t reqprio) /* Reset the worker's priority back to the base priority. */ - sched_reprioritize(wtcb, wtcb->base_priority); + (void)nxsched_reprioritize(wtcb, wtcb->base_priority); } /* There are multiple pending priority levels. The worker thread's @@ -264,7 +264,7 @@ static void lpwork_restoreworker(pid_t wpid, uint8_t reqprio) * base_priority) */ - sched_setpriority(wtcb, wpriority); + nxsched_setpriority(wtcb, wpriority); } else { @@ -304,7 +304,7 @@ static void lpwork_restoreworker(pid_t wpid, uint8_t reqprio) * priority. */ - sched_reprioritize(wtcb, wtcb->base_priority); + (void)nxsched_reprioritize(wtcb, wtcb->base_priority); #endif } } @@ -324,7 +324,7 @@ static void lpwork_restoreworker(pid_t wpid, uint8_t reqprio) * Parameters: * reqprio - Requested minimum worker thread priority * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -370,7 +370,7 @@ void lpwork_boostpriority(uint8_t reqprio) * reqprio - Previously requested minimum worker thread priority to be * "unboosted" * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/sched/wqueue/kwork_lpthread.c b/sched/wqueue/kwork_lpthread.c index 4b6b3ee9979fa1cde360cf6aaabc43887819460a..5d6911fef3f235593828ade12a46e122760cdae1 100644 --- a/sched/wqueue/kwork_lpthread.c +++ b/sched/wqueue/kwork_lpthread.c @@ -84,7 +84,7 @@ struct lp_wqueue_s g_lpwork; * bring up. This entry point is referenced by OS internally and should * not be accessed by application logic. * - * Input parameters: + * Input Parameters: * argc, argv (not used) * * Returned Value: @@ -168,7 +168,7 @@ static int work_lpthread(int argc, char *argv[]) * Description: * Start the low-priority, kernel-mode worker thread(s) * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -209,12 +209,9 @@ int work_lpstart(void) DEBUGASSERT(pid > 0); if (pid < 0) { - int errcode = errno; - DEBUGASSERT(errcode > 0); - - serr("ERROR: kthread_create %d failed: %d\n", wndx, errcode); + serr("ERROR: kthread_create %d failed: %d\n", wndx, (int)pid); sched_unlock(); - return -errcode; + return (int)pid; } g_lpwork.worker[wndx].pid = pid; diff --git a/sched/wqueue/kwork_process.c b/sched/wqueue/kwork_process.c index 80c7befca291423b937e27e60efaa42156fb9b11..2266949f5f730708a3d033079870ae1a235904ba 100644 --- a/sched/wqueue/kwork_process.c +++ b/sched/wqueue/kwork_process.c @@ -85,7 +85,7 @@ * part of the internal implementation of each work queue; it should not * be called from application level logic. * - * Input parameters: + * Input Parameters: * wqueue - Describes the work queue to be processed * * Returned Value: diff --git a/sched/wqueue/kwork_queue.c b/sched/wqueue/kwork_queue.c index 8b5a8e6f5a30341ee008daca89689f2ce783fcbd..483a7e55af3c6c00e83bf0f43ed9567c06265c9b 100644 --- a/sched/wqueue/kwork_queue.c +++ b/sched/wqueue/kwork_queue.c @@ -71,7 +71,7 @@ * from the queue, or (2) work_cancel() has been called to cancel the work * and remove it from the work queue. * - * Input parameters: + * Input Parameters: * qid - The work queue ID (index) * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked @@ -144,7 +144,7 @@ static void work_qqueue(FAR struct kwork_wqueue_s *wqueue, * previous work as been performed and removed from the queue, then any * pending work will be canceled and lost. * - * Input parameters: + * Input Parameters: * qid - The work queue ID (index) * work - The work structure to queue * worker - The worker callback to be invoked. The callback will invoked diff --git a/sched/wqueue/kwork_signal.c b/sched/wqueue/kwork_signal.c index 2efec2ea45961f9b15019ea4b9fbd6698cdf9a82..73ca066a6118beb95d680069b8e8fd43266f5f99 100644 --- a/sched/wqueue/kwork_signal.c +++ b/sched/wqueue/kwork_signal.c @@ -61,7 +61,7 @@ * is used internally by the work logic but could also be used by the * user to force an immediate re-assessment of pending work. * - * Input parameters: + * Input Parameters: * qid - The work queue ID * * Returned Value: diff --git a/sched/wqueue/wqueue.h b/sched/wqueue/wqueue.h index 701af9b300d43bbce6e6f606fcbceb3b5fc18bcd..7e7942ef02a3292a4d46f65633241549bc56476c 100644 --- a/sched/wqueue/wqueue.h +++ b/sched/wqueue/wqueue.h @@ -134,7 +134,7 @@ extern struct lp_wqueue_s g_lpwork; * Description: * Start the high-priority, kernel-mode work queue. * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -153,7 +153,7 @@ int work_hpstart(void); * Description: * Start the low-priority, kernel-mode worker thread(s) * - * Input parameters: + * Input Parameters: * None * * Returned Value: @@ -175,7 +175,7 @@ int work_lpstart(void); * part of the internal implementation of each work queue; it should not * be called from application level logic. * - * Input parameters: + * Input Parameters: * wqueue - Describes the work queue to be processed * period - The polling period in clock ticks * wndx - The worker thread index diff --git a/tools/Makefile.host b/tools/Makefile.host index 297470dc6eeca8e479275f7cdc077acb280794d2..c4fb6860d1fb33e8485de5d448a2d08ac065eae0 100644 --- a/tools/Makefile.host +++ b/tools/Makefile.host @@ -1,7 +1,8 @@ ############################################################################ # Makefile.host # -# Copyright (C) 2007, 2008, 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2008, 2011-2012, 2015, 2017-2018 Gregory Nutt. All +# rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -70,13 +71,15 @@ endif all: b16$(HOSTEXEEXT) bdf-converter$(HOSTEXEEXT) cmpconfig$(HOSTEXEEXT) \ configure$(HOSTEXEEXT) mkconfig$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT) \ mksymtab$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) mkversion$(HOSTEXEEXT) \ - cnvwindeps$(HOSTEXEEXT) nxstyle$(HOSTEXEEXT) initialconfig$(HOSTEXEEXT) + cnvwindeps$(HOSTEXEEXT) nxstyle$(HOSTEXEEXT) initialconfig$(HOSTEXEEXT) \ + logparser$(HOSTEXEEXT) default: mkconfig$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT) \ cnvwindeps$(HOSTEXEEXT) ifdef HOSTEXEEXT .PHONY: b16 bdf-converter cmpconfig clean configure kconfig2html mkconfig \ - mkdeps cnvwindeps mksymtab mksyscall mkversion + mkdeps mksymtab mksyscall mkversion cnvwindeps nxstyle initialconfig \ + logparser else .PHONY: clean endif @@ -182,6 +185,15 @@ ifdef HOSTEXEEXT initialconfig: initialconfig$(HOSTEXEEXT) endif +# logparser - Convert a git log to ChangeLog format. + +logparser$(HOSTEXEEXT): logparser.c + $(Q) $(HOSTCC) $(HOSTCFLAGS) -o logparser$(HOSTEXEEXT) logparser.c + +ifdef HOSTEXEEXT +logparser: logparser$(HOSTEXEEXT) +endif + # cnvwindeps - Convert dependences generated by a Windows native toolchain # for use in a Cygwin/POSIX build environment diff --git a/tools/README.txt b/tools/README.txt index b332d495a3ddd120ab11e8bdd2241be3a7579efd..2f678745ba0c42da5082ec67aaf978a19e5d21ed 100644 --- a/tools/README.txt +++ b/tools/README.txt @@ -655,6 +655,11 @@ kconfig.bat - option env="APPSDIR" + default "../apps" +logparser.c +----------- + + Convert a git log to ChangeLog format. + mkimage.sh ---------- diff --git a/tools/initialconfig.c b/tools/initialconfig.c index 90246dbe63537b6a53b7d9ba6f53454fa0fe8396..d9024bcf8acb1439835537b220a670c0e569b5bc 100644 --- a/tools/initialconfig.c +++ b/tools/initialconfig.c @@ -37,6 +37,7 @@ * Included Files ****************************************************************************/ +#define _GNU_SOURCE 1 #include #include #include diff --git a/tools/kconfig2html.c b/tools/kconfig2html.c index 1f7ab898476fa081c3e4b7e8eecebafbaa94f73b..37b4330da4b1fa5c62ab2cfa08a0b60ea4447a08 100644 --- a/tools/kconfig2html.c +++ b/tools/kconfig2html.c @@ -37,6 +37,7 @@ * Included Files ****************************************************************************/ +#define _GNU_SOURCE 1 #include #include #include diff --git a/tools/logparser.c b/tools/logparser.c new file mode 100644 index 0000000000000000000000000000000000000000..fe9def44d8452470efa2e80f60a3c908c7d0edc4 --- /dev/null +++ b/tools/logparser.c @@ -0,0 +1,576 @@ +/**************************************************************************** + * tools/logparser.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#define _GNU_SOURCE 1 +#include +#include +#include +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LINESIZE (PATH_MAX > 4096 ? PATH_MAX : 4096) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +enum parse_state_e +{ + STATE_IDLE = 0, /* Finished last, ready to start next */ + STATE_HEADER, /* Started next, parsing header */ + STATE_ENDHEADER, /* Finished the header looking for the start of the body */ + STATE_BODY, /* Parsing the body */ +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static char g_line[LINESIZE+1]; +static unsigned long g_lineno; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* Skip over any spaces */ + +static char *skip_space(char *ptr) +{ + while (*ptr && isspace((int)*ptr)) ptr++; + return ptr; +} + +/* Find the end of a variable string */ + +static void trim_end(char *startptr, char *endptr) +{ + while (endptr != startptr && isspace((int)*endptr)) + { + *endptr = '\0'; + endptr--; + } +} + +/* check for a blank line */ + +static bool blank_line(void) +{ + char *ptr = g_line; + + while (*ptr != '\0') + { + if (!isspace((int)*ptr)) + { + return false; + } + + ptr++; + } + + return true; +} + +/* Convert git log date string */ + +static char *parse_date(char *ptr) +{ + char *next; + char *endptr; + char *alloc; + unsigned int mon; + unsigned long date; + unsigned long year; + + /* Form: DOW MON DD HH:MM:SS YYYY GMT + * Eg. Mon Jan 29 07:17:17 2018 -0600 + */ + + /* Skip the day of the week */ + + next = strchr(ptr, ' '); + if (next == NULL) + { + fprintf(stderr, "ERROR line %ld: Did not find day of the week\n", g_lineno); + exit(EXIT_FAILURE); + } + + ptr = skip_space(next); + + /* Get the month */ + + next = strchr(ptr, ' '); + if (next == NULL) + { + fprintf(stderr, "ERROR line %ld: Did not find month\n", g_lineno); + exit(EXIT_FAILURE); + } + + endptr = next; + next = skip_space(next); + trim_end(ptr, endptr); + + if (strncmp(ptr, "Jan", 3) == 0) + { + mon = 1; + } + else if (strncmp(ptr, "Feb", 3) == 0) + { + mon = 2; + } + else if (strncmp(ptr, "Mar", 3) == 0) + { + mon = 3; + } + else if (strncmp(ptr, "Apr", 3) == 0) + { + mon = 4; + } + else if (strncmp(ptr, "May", 3) == 0) + { + mon = 5; + } + else if (strncmp(ptr, "Jun", 3) == 0) + { + mon = 6; + } + else if (strncmp(ptr, "Jul", 3) == 0) + { + mon = 7; + } + else if (strncmp(ptr, "Aug", 3) == 0) + { + mon = 8; + } + else if (strncmp(ptr, "Sep", 3) == 0) + { + mon = 9; + } + else if (strncmp(ptr, "Oct", 3) == 0) + { + mon = 10; + } + else if (strncmp(ptr, "Nov", 3) == 0) + { + mon = 11; + } + else if (strncmp(ptr, "Dec", 3) == 0) + { + mon = 12; + } + else + { + fprintf(stderr, "ERROR line %ld: Unrecognized month %s\n", g_lineno, ptr); + exit(EXIT_FAILURE); + } + + /* Get the day of the month */ + + ptr = next; + next = strchr(ptr, ' '); + if (next == NULL) + { + fprintf(stderr, "ERROR line %ld: Did not find day of the month\n", g_lineno); + exit(EXIT_FAILURE); + } + + endptr = next; + next = skip_space(next); + trim_end(ptr, endptr); + + date = strtoul(ptr, &endptr, 10); + if (*endptr != '\0' || date > 31) + { + fprintf(stderr, "ERROR line %ld: Invalid date\n", g_lineno); + exit(EXIT_FAILURE); + } + + /* Skip over the time */ + + ptr = next; + next = strchr(ptr, ' '); + if (next == NULL) + { + fprintf(stderr, "ERROR line %ld: Did not find day of the month\n", g_lineno); + exit(EXIT_FAILURE); + } + + /* Get the year */ + + ptr = skip_space(next); + next = strchr(ptr, ' '); + if (next == NULL) + { + fprintf(stderr, "ERROR line %ld: Did not find year\n", g_lineno); + exit(EXIT_FAILURE); + } + + trim_end(ptr, next); + year = strtoul(ptr, &endptr, 10); + if (*endptr != '\0' || year < 2007 || year >= 3000) + { + fprintf(stderr, "ERROR line %ld: Invalid year: %s\n", g_lineno, ptr); + exit(EXIT_FAILURE); + } + + /* Then create the final date string */ + + asprintf(&alloc, "(%04lu-%02u-%02lu)", year, mon, date); + if (alloc == NULL) + { + fprintf(stderr, "ERROR line %ld: asprintf failed\n", g_lineno); + exit(EXIT_FAILURE); + } + + return alloc; +} + +/* Parse the entire file */ + +static void parse_file(FILE *stream) +{ + enum parse_state_e state; + bool lastblank; + bool firstline; + bool consumed; + bool merge; + char *name; + char *date; + char *ptr; + + /* Loop until the entire file has been parsed. */ + + g_lineno = 0; + state = STATE_IDLE; + name = NULL; + date = NULL; + consumed = true; + firstline = true; + merge = false; + + for (; ; ) + { + /* Read the next line from the file (unless it was not consumed on the + * previous pass through the loop. + */ + + if (consumed) + { + g_line[LINESIZE] = '\0'; + if (!fgets(g_line, LINESIZE, stream)) + { + /* Check if the body was terminated with the end of file */ + + if (state == STATE_BODY) + { + /* End of body. Add author, date, and final newline */ + + printf(" From %s %s.\n", name, date); + free(name); + free(date); + } + else if (state != STATE_IDLE) + { + fprintf(stderr, "ERROR line %ld: Unexpected EOF in state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + return; + } + + g_lineno++; + consumed = false; + } + + ptr = g_line; + + /* Process the line depending upon the state of the parser */ + + switch (state) + { + case STATE_IDLE: /* Finished last, ready to start next */ + if (blank_line()) + { + consumed = true; + break; + } + + if (isspace(g_line[0])) + { + fprintf(stderr, "ERROR line %lu: Unexpected whitespace in state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + /* Change state and fall through */ + + state = STATE_HEADER; + + case STATE_HEADER: /* Started next, parsing header */ + if (!isspace(g_line[0])) + { + if (strncmp(g_line, "commit ", 7) == 0) + { + /* Skip commit line */ + } + else if (strncmp(g_line, "Merge: ", 6) == 0) + { + /* Skip merges */ + + merge = true; + } + else if (strncmp(g_line, "Author: ", 8) == 0) + { + char *endptr; + + /* Extract the name */ + + ptr += 7; + ptr = skip_space(ptr); + endptr = strchr(ptr, '<'); + if (endptr == NULL) + { + fprintf(stderr, "ERROR line %lu: No email address after name, state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + if (name != NULL) + { + fprintf(stderr, "ERROR line %lu: Duplicate name, state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + /* Copy and save the name string */ + + trim_end(ptr, endptr - 1); + name = strdup(ptr); + if (name == NULL) + { + fprintf(stderr, "ERROR line %lu: Failed to duplicate name, state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + } + else if (strncmp(g_line, "Date: ", 6) ==0) + { + if (date != NULL) + { + fprintf(stderr, "ERROR line %lu: Duplicate date, state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + /* Extract the date */ + + ptr += 6; + ptr = skip_space(ptr); + date = parse_date(ptr); + } + else + { + fprintf(stderr, "ERROR line %lu: Unrecognized header line in state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + consumed = true; + break; + } + + /* Change state and fall through */ + + if (name == NULL || date == NULL) + { + fprintf(stderr, "ERROR line %lu: name or date not found in header. State %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + state = STATE_ENDHEADER; + + case STATE_ENDHEADER: /* Finished the header looking for the start of the body */ + if (blank_line()) + { + consumed = true; + break; + } + + if (!isspace(g_line[0])) + { + fprintf(stderr, "ERROR line %lu: Unexpected in state %d\n", + g_lineno, state); + exit(EXIT_FAILURE); + } + + /* Change state and fall through */ + + state = STATE_BODY; + lastblank = false; + + case STATE_BODY: /* Parsing the body */ + if (blank_line()) + { + lastblank = true; + consumed = true; + break; + } + + if (isspace(g_line[0])) + { + char *endptr; + char *tmp; + + /* Remove the newline from the end */ + + ptr = skip_space(ptr); + endptr = &ptr[strlen(ptr) - 1]; + trim_end(ptr, endptr); + + /* Change leading "* " to "- " */ + + tmp = ptr; + if (ptr[0] == '*' && ptr[1] == ' ') + { + *ptr = '-'; + tmp = ptr + 2; + } + + /* Skip over certain crap body lines added by GIT; Skip over + * merge entries altogether. + */ + + if (strncmp(tmp, "Merged in ", 10) != 0 && + strncmp(tmp, "Approved-by: ", 13) != 0 && + strncmp(tmp, "Signed-off-by: ", 15) != 0 && + !merge) + { + /* Is this the first paragraph in the body? */ + + if (firstline) + { + printf("\t* %s", ptr); + } + else + { + /* This paragraph is not the first, was it separated + * from the previous paragraph by a blank line? + */ + + if (lastblank) + { + putchar('\n'); + } + + printf("\n\t %s", ptr); + } + + firstline = false; + lastblank = false; + } + + consumed = true; + break; + } + + /* End of body. Add author, date, and final newline */ + + if (!merge) + { + printf(" From %s %s.\n", name, date); + } + + /* Revert to IDLE state */ + + free(name); + name = NULL; + free(date); + date = NULL; + + state = STATE_IDLE; + firstline = true; + merge = false; + break; + + default: + fprintf(stderr, "ERROR line %lu: Bad state %d\n", g_lineno, state); + exit(EXIT_FAILURE); + } + } +} + +static void show_usage(const char *progname) +{ + fprintf(stderr, "USAGE: %s \n", progname); + exit(EXIT_FAILURE); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv, char **envp) +{ + FILE *stream; + + if (argc != 2) + { + fprintf(stderr, "Unexpected number of arguments\n"); + show_usage(argv[0]); + } + + stream = fopen(argv[1], "r"); + if (!stream) + { + fprintf(stderr, "open %s failed: %s\n", argv[1], strerror(errno)); + return EXIT_FAILURE; + } + + parse_file(stream); + fclose(stream); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/wireless/ieee802154/ieee802154_primitive.c b/wireless/ieee802154/ieee802154_primitive.c index 35db231fcd467e10497eabebc796630765b525e1..e13c4a31337affad34084d17d94663afe2704387 100644 --- a/wireless/ieee802154/ieee802154_primitive.c +++ b/wireless/ieee802154/ieee802154_primitive.c @@ -135,10 +135,10 @@ static bool g_poolinit = false; * be called early in the initialization sequence before any radios * begin operation. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -224,10 +224,10 @@ void ieee802154_primitivepool_initialize(void) * list. If that the list is empty, then the primitive structure will be * allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * A reference to the allocated primitive structure. All user fields in this * structure have been zeroed. On a failure to allocate, NULL is * returned. @@ -309,12 +309,17 @@ FAR struct ieee802154_primitive_s *ieee802154_primitive_allocate(void) /* Check if we allocated the primitive structure */ - if (prim != NULL) + if (prim == NULL) { - /* Yes... remember that this primitive structure was dynamically allocated */ + /* No.. memory not available */ - pool = POOL_PRIMITIVE_DYNAMIC; + wlerr("ERROR: Failed to allocate primitive.\n"); + return NULL; } + + /* Remember that this primitive structure was dynamically allocated */ + + pool = POOL_PRIMITIVE_DYNAMIC; } } @@ -341,10 +346,10 @@ FAR struct ieee802154_primitive_s *ieee802154_primitive_allocate(void) * structure. If the primitive structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * prim - primitive structure to free * - * Return Value: + * Returned Value: * None * ****************************************************************************/ diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 3ab60e4a08f1e85feaa5c8d57c2ed1db61af31aa..13dcc31a0f01a12c49d9375ab72994a700905662 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -846,7 +846,7 @@ static int mac802154dev_rxframe(FAR struct mac802154_chardevice_s *dev, * minor - The device minor number. The IEEE802.15.4 MAC character device * will be registered as /dev/ieeeN where N is the minor number * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * diff --git a/wireless/ieee802154/mac802154_loopback.c b/wireless/ieee802154/mac802154_loopback.c index 1eabcd1a786dfbeff99d35fcfc94ea3620c92d07..04dbd9139ec0c2f657c57bee7c9ae308d38f425c 100644 --- a/wireless/ieee802154/mac802154_loopback.c +++ b/wireless/ieee802154/mac802154_loopback.c @@ -888,7 +888,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd, * Description: * Calculate the MAC header length given the frame meta-data. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -911,7 +911,7 @@ static int lo_get_mhrlen(FAR struct radio_driver_s *netdev, * Description: * Requests the transfer of a list of frames to the MAC. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -983,7 +983,7 @@ static int lo_req_data(FAR struct radio_driver_s *netdev, * run time. This information is provided to the 6LoWPAN network via the * following structure. * - * Input parameters: + * Input Parameters: * netdev - The network device to be queried * properties - Location where radio properities will be returned. * diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 953c37f26da1c2caff354a68394600b58a9d7723..0a11caf0172d50f3508e1e115ce01f6d8d5435f9 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -664,7 +664,7 @@ static void macnet_txpoll_expiry(int argc, wdparm_t arg, ...) * Description: * Get the extended address of the PAN coordinator. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * eaddr - The location in which to return the extended address. * @@ -701,7 +701,7 @@ static int macnet_coord_eaddr(FAR struct radio_driver_s *radio, * Description: * Get the short address of the PAN coordinator. * - * Input parameters: + * Input Parameters: * radio - Reference to a radio network driver state instance. * saddr - The location in which to return the short address. * @@ -1169,7 +1169,7 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd, * Description: * Calculate the MAC header length given the frame meta-data. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -1198,7 +1198,7 @@ static int macnet_get_mhrlen(FAR struct radio_driver_s *netdev, * Description: * Requests the transfer of a list of frames to the MAC. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -1280,7 +1280,7 @@ static int macnet_req_data(FAR struct radio_driver_s *netdev, * run time. This information is provided to the 6LoWPAN network via the * following structure. * - * Input parameters: + * Input Parameters: * netdev - The network device to be queried * properties - Location where radio properities will be returned. * @@ -1357,7 +1357,7 @@ static int macnet_properties(FAR struct radio_driver_s *netdev, * Input Parameters: * mac - Pointer to the mac layer struct to be registered. * - * Returned Values: + * Returned Value: * Zero (OK) is returned on success. Otherwise a negated errno value is * returned to indicate the nature of the failure. * @@ -1400,7 +1400,7 @@ int mac802154netdev_register(MACHANDLE mac) #endif dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->md_mac = mac; /* Save the MAC interface instance */ priv->md_txpoll = wd_create(); /* Create periodic poll timer */ diff --git a/wireless/pktradio/pktradio_loopback.c b/wireless/pktradio/pktradio_loopback.c index c9e144eb4d7a72955ac7148758dc092928ded6a7..71c963126d43bf0715c4a81229d73b6a80436ed1 100644 --- a/wireless/pktradio/pktradio_loopback.c +++ b/wireless/pktradio/pktradio_loopback.c @@ -848,7 +848,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd, * Description: * Calculate the MAC header length given the frame meta-data. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -871,7 +871,7 @@ static int lo_get_mhrlen(FAR struct radio_driver_s *netdev, * Description: * Requests the transfer of a list of frames to the MAC. * - * Input parameters: + * Input Parameters: * netdev - The networkd device that will mediate the MAC interface * meta - Obfuscated metadata structure needed to create the radio * MAC header @@ -943,7 +943,7 @@ static int lo_req_data(FAR struct radio_driver_s *netdev, * run time. This information is provided to the 6LoWPAN network via the * following structure. * - * Input parameters: + * Input Parameters: * netdev - The network device to be queried * properties - Location where radio properities will be returned. * diff --git a/wireless/pktradio/pktradio_metadata.c b/wireless/pktradio/pktradio_metadata.c index 585b6bac23fcc28a188488a73b0b393c81597e9e..4dce2ec7562ae69b03f0fffe1915b48a4d0a664a 100644 --- a/wireless/pktradio/pktradio_metadata.c +++ b/wireless/pktradio/pktradio_metadata.c @@ -86,10 +86,10 @@ static struct pktradio_metadata_s g_metadata_pool[CONFIG_PKTRADIO_NRXMETA]; * be called early in the initialization sequence before any radios * begin operation. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * None * ****************************************************************************/ @@ -136,10 +136,10 @@ void pktradio_metadata_initialize(void) * list. If that the list is empty, then the meta-data structure will be * allocated from the dynamic memory pool. * - * Inputs: + * Input Parameters: * None * - * Return Value: + * Returned Value: * A reference to the allocated metadata structure. All user fields in this * structure have been zeroed. On a failure to allocate, NULL is * returned. @@ -216,10 +216,10 @@ FAR struct pktradio_metadata_s *pktradio_metadata_allocate(void) * structure. If the metadata structure was allocated dynamically it will * be deallocated. * - * Inputs: + * Input Parameters: * metadata - metadata structure to free * - * Return Value: + * Returned Value: * None * ****************************************************************************/