Commit graph

86 commits

Author SHA1 Message Date
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Johann Fischer 6da7e41592 drivers: console: fix USB initialization
Initialize USB even if USB_UART_DTR_WAIT is not enabled.

Fixes: #25811

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-06-02 18:02:16 +02:00
Erwan Gouriou 2716cbcaa6 drivers: susbsys: Check errors on devices selected using dt macro
Some Kconfig defined devices may be defined using dt_chosen_label
function. Since there is no way to ensure a device enabled in dts
is also defined in Kconfig, it may happen that instance is not
actually defined.
In this case device_get_binding might return 0, leading to undefined
behavior in the function that calls it.
When not already done, systematically check return of function
device_get_binding on devices defined through dt_chosen_label macro.
Trigger ASSERT when required and return error when possible.

Fixes #20068

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-05-25 11:43:14 +02:00
Andrei Emeltchenko caa95fc10d console: uart_console: Use static for static functions
Use static keyword for static functions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2020-03-11 09:17:38 -04:00
Flavio Ceolin d507574864 console: uart: Ifdef an include
usb-device.h must be included only if CONFIG_USB_UART_CONSOLE is
defined, otherwise it is not used and will pull a lot of usb code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-01-28 14:02:54 -05:00
Emil Obalski 2128750138 usb: api: Add user device status callback
By this commit user gets possibility to register USB
device satutus callback. This callback represents device state
and is added so user could know what happend to USB device.

Callback is registered by providing it to usb_enable()
USB api is extended by this callback handler.

Samples using using USB are by default provide no callback
and the usb_enable() is called with NULL parameter.

Status callback registered by hid class is deleted as now
USB device has global callback for all classes within device.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Emil Obalski d65027d8c0 usb: samples: Application calling usb_enable by itself
User app is reponsible for issuing usb_enable and
making USB hardware operative.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Peter A. Bigot a58d8ebaa6 driver: uart: make deprecation effective
Several macros were documented as deprecated but lacked the
infrastructure to produce deprecation warnings.  Add the deprecation
marker, and fix the in-tree references to the deprecated spellings.

Note that one non-deprecated macro should have been deprecated, and
is, referring to a newly added line control bit.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-07 12:44:15 -06:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif d1b2718687 cleanup: include/: move uart.h to drivers/uart.h
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif e1e05a2eac cleanup: include/: move atomic.h to sys/atomic.h
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 1034c5e398 drivers: uart_console: removed commented code
Remove all commented and unused code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-25 15:27:00 -04:00
Anas Nashif 7635cf80ab drivers: uart_console: do not include arch/cpu.h directly
No need tp include arch/cpu.h directly here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-25 15:27:00 -04:00
Anas Nashif e8a182ce26 drivers: uart_console: include correct path
include console.h from include/drivers/console

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-25 15:27:00 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
qianfan Zhao 13e1c3c2f8 uart_console: delete char using BS(08H) or DEL(7FH)
Some serial tools such as 'minicom' send BS when press backspace,
not DEL, so delete char using BS or DEL.

Fixes: #7959

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-05-29 16:21:55 -04:00
Ruslan Mstoi ca94b86b3d drivers: console: Fix crash in shell
Shell crashes when enter is pressed. This commit reverts relevant
changes from 14735116d1 that cause
this issue.

Fixes #6322

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2018-02-22 15:29:08 -05:00
Christopher Collins 14735116d1 subsys: mgmt: UART transport for SMP (mcumgr).
Add a UART driver dedicated to transporting mcumgr SMP requests and
responses.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-20 22:07:52 +01:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Adithya Baglody 23d946f4c0 drivers: console: Do not wait on the DTR signal from the host USB controller.
Jira: ZEP-1993
Change-Id: I4834d630f245f81381887af56e2d6ccd811094b4
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-04-25 02:33:01 +00:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
Tomasz Bursztyka 2f1af492ee console/shell: Switch to generic console input
Let's use the generic console input type now. This will be useful for
other console input drivers such as telnet.

Change-Id: I787a1e9d86481d5f8c4803453726d9042a89dea4
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Tomasz Bursztyka fb9810978f drivers/uart_console: Fix tiny style issues
Basically missing {} on if statements.
Taking the opportunity to remove a useless switch.

Change-Id: Ic6b3951dfc257cb46d858ebcd12bdf1b4e7ff997
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Baohong Liu fa2d38e395 drivers: console: use unified kernel API
Change-Id: I2184f0565a9a4f2ebfdff1f57afc22ce36fe0646
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-30 23:49:04 +00:00
Vincenzo Frascino f3a9241045 console: Fix unreachable code condition
This patch fixes an unreachable code condition in the uart_console
driver.

If UART_CONSOLE_DEBUG_SERVER_HOOKS was not defined
handled_by_debug_server in console_out was always 0.

This issue was reported by Coverity (CID 131627).

Change-Id: I4376c3e5b3e68220218df6aabd91b6a8900ca31f
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2016-11-16 13:30:11 +00:00
Johan Hedberg 488f72dd80 drivers: console: Fix compilation error in uart_console.c
Fix compilation error when CONFIG_USB_UART_CONSOLE is not enabled:

drivers/console/uart_console.c: In function 'uart_console_init':
drivers/console/uart_console.c:497:12: error: unused variable 'dtr' [-Werror=unused-variable]
  uint32_t  dtr = 0;

Change-Id: I592724150f86199f6a57354c3246197db2ac7a01
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-12 12:49:53 +02:00
Jithu Joseph fca0add22b console : usb: USB UART console output support
Add support for console output via the USB UART.
Note that console input via the USB UART doesnt work.

Adds a simulated poll method for UART interface exposed by USB.

Jira : ZEP-775

Change-Id: I357827ea52c027eb000baed80225f422df1f3358
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-11-12 01:39:30 +00:00
Luiz Augusto von Dentz 6b2443e99b console: Fix warnings related to the use of deprecated APIs
This fixes the warnings related to the use of deprecated APIs
converting them to use the unified version.

Change-Id: I76d076de27ecdae4af46abf4baac68e2cc1313c0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-11-11 14:50:58 +02:00
Andrew Boie 0b474eef9c kernel: deprecate old init levels
PRIMARY, SECONDARY, NANOKERNEL, MICROKERNEL init levels are now
deprecated.

New init levels introduced: PRE_KERNEL_1, PRE_KERNEL_2, POST_KERNEL
to replace them.

Most existing code has instances of PRIMARY replaced with PRE_KERNEL_1,
SECONDARY with POST_KERNEL as SECONDARY has had a longstanding bug
where the documentation specified SECONDARY ran before the kernel started
up, but actually ran afterwards.

Change-Id: I771bc634e9caf7f17dbf214a270bc9967eed7d32
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-09 17:59:44 +00:00
Szymon Janc a037316bb5 console: Add support for DEL key
This allows to delete character after cursor.

Change-Id: I9acc5e1edeb688ea4ec36e91aef69ecb5f5f6354
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-01 23:37:37 +00:00
Szymon Janc 6b0cf54c60 console: Add support for HOME and END keys
This allows to navigate to begining and end of the line easily.

Change-Id: I3a839a0499961d55574a310c65811dd2fe048703
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-01 23:37:36 +00:00
Marcus Shawcroft 1bc999cb8d drivers/uart: Refactor UART input hook.
This refactor is in preparation for making driver API structures
const.

The console driver provides a mechanism to install an input and an
output hook function.  These are primarily used by the onboard
gdb-server.  The output hook is entirely implemented within the
console driver.

The input hook is partially implemented in the top of the uart driver
and within the console driver.  The hook function itself is installed
in the uart API structure, but is invoked only by the console driver.

Installing the hook function directly into the uart API structure
prevents the API structure being const.  There are two approaches to
fixing this:

1) Implement setting of the input hook in the same way as
uart_irq_callback_set().

2) Move the input hook entirely to the console driver.

We implement the latter.  This approach has two benefits, first it
removes the need for every uart driver to implement the behaviour and
second, the current placement of the callback function in the uart API
seems odd given that the callback is only invoked by the console
driver, never by a uart driver.

Change-Id: I258b312d3055df1c2bdeb896bd4f4f39c40838f7
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 11:31:08 +00:00
Andy Ross 425145da08 uart_console: Fix line endings
Overwhelming industry practice when using two-byte line termination is
to end the line with "\r\n" and not "\n\r".

Also remove needless casts.  GCC does not warn on int-to-char
conversions.

Change-Id: If01a2e5ca327aacebcbcaf384af9c7131119689b
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-09-09 21:37:55 +00:00
Szymon Janc d7e8fd0446 console: Add support for commands completion
This allows to register callback that will be called to
perform command completion.

Change-Id: Ide7a0427d9b8bb4dd8cfc0995ef2567b32e89632
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-05-26 12:02:51 +00:00
Chuck Jordan 12e29fe653 console: fix spelling error in comment
consloe changed to console

Change-Id: Ie6d6bd7762f1ab1dae64a1f5ccbe7dbc651e8c0f
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-09 20:56:51 +00:00
Benjamin Walsh 0ff5d37a4a console: add hook for debug server to handle outgoing characters
A debug server might want to redirect outgoing characters on the console
to another output if it piggybacks on the serial line normally reserved
for the console.

Change-Id: I534f5b35456306940a3926f52fe5cce2d5c94da4
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-04-16 05:29:20 +00:00
Daniel Leung 546b8ade37 refactor common driver initialization priorities
Most of the SoC and board Kconfig use the same values for
driver initialization priorities. So refactor them, and
discard duplicate ones.

The shared IRQ init priority was changed so that the kernel
default init and device init priorities can be standardized
across all SoC/boards. Same goes for DesignWare SPI driver.

This also changes the UART_CONSOLE_PRIORITY and
IPM_CONSOLE_PRIORITY to UART_CONSOLE_INIT_PRIORITY and
IPM_CONSOLE_INIT_PRIORITY, to standardize across all drivers.

Note that this does not take away the ability to override
those values. This just provides reasonable defaults such
that there is virtually no need to override.

Change-Id: Ibbd95d802c637df06f9a2fd48763ee1e6f4ff627
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-28 15:58:29 -07:00
Andre Guedes 024cfe754e drivers: Replace DEV_OK by 0
This patch replaces all occurences of the macro DEV_OK by the actual
value 0 at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I69980ecb9755f2fb026de5668ae9c21a4ae62d1e
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Daniel Leung e643cede3a uart: add ISR callback mechanism for UART drivers
The peripherals utilizing UART were required to register their own
ISR rountines. This means that all those peripherals drivers need
to know which IRQ line is attached to a UART controller, and all
the other config values required to register a ISR. This causes
scalibility issue as every board and peripherals have to define
those values.

Another reason for this patch is to support virtual serial ports.
Virtual serial ports do not have physical interrupt lines to
attach, and thus would not work.

This patch adds a simple callback mechanism, which calls a function
when UART interrupts are triggered. The low level plumbing still needs
to be done by the peripheral drivers, as these drivers may need to
access low level capability of UART to function correctly. This simply
moves the interrupt setup into the UART drivers themselves. By doing
this, the peripheral drivers do not need to know all the config values
to properly setup the interrupts and attaching the ISR. One drawback
is that this adds to the interrupt latency.

Note that this patch breaks backward compatibility in terms of
setting up interrupt for UART controller. How to use UART is still
the same.

This also addresses the following issues:

() UART driver for Atmel SAM3 currently does not support interrupts.
   So remove the code from vector table. This will be updated when
   there is interrupt support for the driver.
() Corrected some config options for Stellaris UART driver.

This was tested with samples/shell on Arduino 101, and on QEMU
(Cortex-M3 and x86).

Origin: original code
Change-Id: Ib4593d8ccd711f4e97d388c7293205d213be1aec
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-05 13:37:57 +00:00
Johan Hedberg 6543318194 drivers/console: Fix writing out carriage return on all terminals
Some terminals (e.g. screen) don't seem to propagate carriage returns
through, creating the following kind of results when pressing enter in
a shell:

btshell>
         btshell>
                  btshell>
                           btshell>

Fix this by always printing out '\r' when receiving a carriage return.

Change-Id: Ia5ce5612c9b830edc84619538dc17a654b6e805b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-10 18:52:29 -05:00
Andrew Boie 897ffaeb2c irq: rename irq_connect() to IRQ_CONNECT()
It's not a function and requires all its arguments to be build-time
constants. Make this more obvious to the end user to ease confusion.

Change-Id: I64107cf4d9db9f0e853026ce78e477060570fe6f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh a4ec963138 init: use SYS_INIT() where it makes sense
Mostly SoC initialization and some kernel subsystems, but also some
device drivers like the interrupt controllers.

Change-Id: I8dc1844c33acd877c075b6b03558fdca6f87500b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh d340d4cb3f device: use DEVICE_INIT everwhere
This is the last step before obsoleting DEVICE_DEFINE() and
DEVICE_INIT_CONFIG_DEFINE().

Change-Id: Ica4257662969048083ab9839872b4b437b8b351b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh 0303d8cab9 device: rename SYS_DEFINE_DEVICE()
Rename it to DEVICE_DEFINE() so that it fits in the 'device' namespace.

Change-Id: I3af3a39cf9154359b31d22729d0db9f710cd202b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh bfc27206b2 device: rename DECLARE_DEVICE_INIT_CONFIG()
Rename it to DEVICE_INIT_CONFIG_DEFINE(), because (a) it was not fitting
in any namespace and (b) it is not used to declare, but rather define a
object.

Change-Id: I1da5822f06b85a9fb024b5b184afd0ccc01012ec
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Andrew Boie d9cfbd5a61 interrupts: new static IRQ API
The interrupt API has been redesigned:

- irq_connect() for dynamic interrupts renamed to irq_connect_dynamic().
  It will be used in situations where the new static irq_connect()
  won't work, i.e. the value of arguments can't be computed at build time
- a new API for static interrupts replaces irq_connect(). it is used
  exactly the same way as its dynamic counterpart. The old static irq
  macros will be removed
- Separate stub assembly files are no longer needed as the stubs are now
  generated inline with irq_connect()

ReST documentation updated for the changed API. Some detail about the
IDT in ROM added, and an oblique reference to the internal-only
_irq_handler_set() API removed; we don't talk about internal APIs in
the official documentation.

Change-Id: I280519993da0e0fe671eb537a876f67de33d3cd4
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:17 -05:00