Date   

[PATCH 0/2] Arc tickless idle issue

Desfarges, Simon <simon.desfarges@...>
 

From: Simon Desfarges <simon.desfarges(a)intel.com>

Hello,

I am trying to enable the tickless idle of ARC in our project. Here is my
problem.

OS: Zephyr 1.0.0
Processor: Quark_se

The ARC TICK timer contains 2 registers: limit register and count register.
Count register is automatically incremented and when is equal to limit
register, an ISR is fired and count wraps to 0.

Trying to enable the tickless idle on Arc, I found that in some corner case
the limit register ends up to be smaller than the count register. So then, the
count register will wrap to 0 at UINT32_MAX value (~133 seconds), leading to a
very long TICK.

I managed to fix this problem (patch 1) and added plenty of assertions (patch 2,
used to debug, validate and understand the code).

TL;DR:

I still have a remaining issue: the TICK is no more regular. I have a small
jitter when the tickless idle is interrupted by an external event. To check I
set a timer expiring every 1000 ms, and I compute the time between 2 ISR using
the AON counter and using the OS Timer.

Here are my results:
Working case:
4574464|ARC| MAIN| INFO| timer 32767k, 1000ms, os: 1000
4575464|ARC| MAIN| INFO| timer 32767k, 1000ms, os: 1000
4576464|ARC| MAIN| INFO| timer 32767k, 1000ms, os: 1000
4577464|ARC| MAIN| INFO| timer 32767k, 1000ms, os: 1000
4578464|ARC| MAIN| INFO| timer 32767k, 1000ms, os: 1000
4579464|ARC| MAIN| INFO| timer 32767k, 1000ms, os: 1000

Here, the time between 2 Interrupts is always 1000ms (32767 ticks of the AON
counter, counting at 32768Hz). The 'os' value actually counts the elapsed
TICKs.

Tickless idle case:
4745475|ARC| MAIN| INFO| timer 32786k, 1001ms, os: 1000
4746476|ARC| MAIN| INFO| timer 32780k, 1000ms, os: 1000
4747476|ARC| MAIN| INFO| timer 32786k, 1001ms, os: 1000
4748476|ARC| MAIN| INFO| timer 32780k, 1000ms, os: 1000
4749477|ARC| MAIN| INFO| timer 32786k, 1001ms, os: 1000

Here, the time between 2 ISR may vary up to 1ms for 1000 ticks.

The issue appears only when there are external ISR (I shake the board, accel
sensor does the rest). So in the exact path I just changed :(

I do not understand from where does the issue comes from (yes, from my patch I
guess), so if a tickless guru can give me some hints, I may have missed an
obvious stuff...

Thank you very much !
Simon.

Simon Desfarges (2):
arc_timer: fix tickless idle
arc_timer: assert that counter always lower than limit

drivers/timer/arcv2_timer0.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)

--
1.9.1


Re: STM32/STM32F1 patchset v10

Maciek Borzecki <maciek.borzecki@...>
 

Hi,

I've pushed another set of updates to the remaining STM32F1 patchset
(bboozzoo/stm32f10x-for-upstream-v11).

The aside from cosmetic cleanups and minor updates, the pinmux driver
was extended to address comments from Vinicius Costa Gomes. The pin
function configuration is currently declared upfront by the board
integration glue, and applied during pinmux driver
initialization. Board integrator is expected to provide implementation
of stm32_board_get_pinconf(), retuning an array of
(pin, alternate-function) tuples.

Updated Changes:
https://gerrit.zephyrproject.org/r/649 pinmux/stm32: add common
driver for STM32 pinmux
https://gerrit.zephyrproject.org/r/650 serial/stm32: add driver for
STM32 UART
https://gerrit.zephyrproject.org/r/651 gpio/stm32: add common driver
for STM32 GPIO
https://gerrit.zephyrproject.org/r/652 boards/stm32_mini_a15: add
new board
https://gerrit.zephyrproject.org/r/653 samples/drivers/disco: add
'disco' sample program
https://gerrit.zephyrproject.org/r/713 soc/stm32f1/gpio: implement
GPIO support
https://gerrit.zephyrproject.org/r/714 soc/stm32f1/pinmux: implement
STM32 pinmux integration
https://gerrit.zephyrproject.org/r/715 boards/nucleo_f103rb: add new
board
https://gerrit.zephyrproject.org/r/915 soc/stm32f1: add IRQ numbers
listing
https://gerrit.zephyrproject.org/r/916 serial/stm32: add support for
IRQ APIs
https://gerrit.zephyrproject.org/r/917
interupt_controller/stm32_exti: driver for STM32 EXTI controller
https://gerrit.zephyrproject.org/r/918 gpio/stm32: GPIO input with
interrupts
https://gerrit.zephyrproject.org/r/919 soc/stm32f1: AFIO registers
mapping
https://gerrit.zephyrproject.org/r/920 soc/stm32f1/gpio: implement
MCU specific GPIO input interrupt integration
https://gerrit.zephyrproject.org/r/921 watchdog/iwdg_stm32: add
driver for STM32 Independent Watchdog (IWDG)
https://gerrit.zephyrproject.org/r/922 samples/button: button input
example

Cheers,
--
Maciek Borzecki


Re: Lost access to Zephyr git and gerrit

Pawel Wodnicki <root@...>
 

Hi Yannis,

It worked!
Looks like I have followed instructions a little too close :-)
Thanks for pointing the problem.

Pawel


Re: Lost access to Zephyr git and gerrit

Yannis Damigos
 

Hi Pawel,

Adding my username before the gerrit.zephyrproject.org worked for me.
The command should be like this (where 'username' your username):
~$ scp -p -P 29418 username(a)gerrit.zephyrproject.org:hooks/commit-msg
.git/hooks/

Yannis

On Thu, Mar 17, 2016 at 8:21 AM, Pawel Wodnicki <root(a)32bitmicro.com> wrote:
Hi,

I am experiencing problems with access to Zephyr sites.
I can no longer login into Zephyr gerrit :-(
I have checked my linuxfoundation.org login and it only works from Firefox, I can not login from Chrome, strange.

I can clone and pull from git but when I try to setup hooks using scp I get Permission denied (publickey) see below.

pawel(a)dell-pw:/usr/local/src/zephyr/zephyr-project$ scp -p -P 29418 gerrit.zephyrproject.org:hooks/commit-msg .git/hooks/
Permission denied (publickey).


Is this a known problem?

Pawel


Lost access to Zephyr git and gerrit

Pawel Wodnicki <root@...>
 

Hi,

I am experiencing problems with access to Zephyr sites.
I can no longer login into Zephyr gerrit :-(
I have checked my linuxfoundation.org login and it only works from Firefox, I can not login from Chrome, strange.

I can clone and pull from git but when I try to setup hooks using scp I get Permission denied (publickey) see below.

pawel(a)dell-pw:/usr/local/src/zephyr/zephyr-project$ scp -p -P 29418 gerrit.zephyrproject.org:hooks/commit-msg .git/hooks/
Permission denied (publickey).


Is this a known problem?

Pawel


Re: Some emails from devel mailing list does arrive to my inbox

Yannis Damigos
 

On 03/16/2016 10:51 PM, Maciek Borzecki wrote:
On Wed, Mar 16, 2016 at 9:49 PM, Yannis Damigos
<giannis.damigos(a)gmail.com> wrote:
On 03/15/2016 03:48 PM, Yannis Damigos wrote:
Hi everyone,

is it just me or everyone does not receive some emails to their inbox
from the devel mailing list?

For example I did not receive any email for the threads:
[RFC] GPIO API changes
FRDM-K64 GPIO driver name
Zephyr SDK v0.7.2 - "rm -rf /"

If someone posts something to the devel mailing list using the web
GUI, do you receive an email?

Best regards,
Yannis
Could someone, please, help me to find out if I am the only one,
who does not receive emails from the devel mailing list.

I did not receive anything to my inbox for threads which were
created the last 6 hours:

STM32/STM32F1 patchset v10
This one was sent using gmail web client.

SPI on the FRDM-K64F
FRDM-K64 PRINT not working

Did the authors of these threads used the web GUI to post them?

Best regards,
Yannis

Cheers,
Thank you Maciek for your reply.
The mail delivery option of the devel list in my account was disabled.
I just enabled it and I will wait to see if this will fix the issue.

Yannis


Re: Some emails from devel mailing list does arrive to my inbox

Maciek Borzecki <maciek.borzecki@...>
 

On Wed, Mar 16, 2016 at 9:49 PM, Yannis Damigos
<giannis.damigos(a)gmail.com> wrote:
On 03/15/2016 03:48 PM, Yannis Damigos wrote:
Hi everyone,

is it just me or everyone does not receive some emails to their inbox
from the devel mailing list?

For example I did not receive any email for the threads:
[RFC] GPIO API changes
FRDM-K64 GPIO driver name
Zephyr SDK v0.7.2 - "rm -rf /"

If someone posts something to the devel mailing list using the web
GUI, do you receive an email?

Best regards,
Yannis
Could someone, please, help me to find out if I am the only one,
who does not receive emails from the devel mailing list.

I did not receive anything to my inbox for threads which were
created the last 6 hours:

STM32/STM32F1 patchset v10
This one was sent using gmail web client.

SPI on the FRDM-K64F
FRDM-K64 PRINT not working

Did the authors of these threads used the web GUI to post them?

Best regards,
Yannis

Cheers,
--
Maciek Borzecki


Re: Some emails from devel mailing list does arrive to my inbox

Yannis Damigos
 

On 03/15/2016 03:48 PM, Yannis Damigos wrote:
Hi everyone,

is it just me or everyone does not receive some emails to their inbox
from the devel mailing list?

For example I did not receive any email for the threads:
[RFC] GPIO API changes
FRDM-K64 GPIO driver name
Zephyr SDK v0.7.2 - "rm -rf /"

If someone posts something to the devel mailing list using the web
GUI, do you receive an email?

Best regards,
Yannis
Could someone, please, help me to find out if I am the only one,
who does not receive emails from the devel mailing list.

I did not receive anything to my inbox for threads which were
created the last 6 hours:

STM32/STM32F1 patchset v10
SPI on the FRDM-K64F
FRDM-K64 PRINT not working

Did the authors of these threads used the web GUI to post them?

Best regards,
Yannis


Re: FRDM-K64 PRINT not working

Anders Dam Kofoed <adk@...>
 

Does anyone have a working working zephyr.bin for the FRDM-K64 board where printf/k is working? I'd like to see if it would work on mine.
Kind regards
Anders


SPI on the FRDM-K64F

Corey Williamson <corey.bailey.williamson@...>
 

Hi,

I'm looking to use the spi interface on the FRDM-K64f board, is there a
driver for that? Or alternatively, is it all right for for me to change
and mess with the clock settings for the board? Will that interfere with
the timing of the RTOS?

Thanks,

Corey Williamson


STM32/STM32F1 patchset v10

Maciek Borzecki <maciek.borzecki@...>
 

Hi all,

I've published version 10 of the patchset adding STM32/STM32F1
support. I will update the series once Anas merges his arch/arm/soc
tree layout changes.

The code is also available here in branch
bboozzoo/stm32f10x-for-upstream-v10 in github repo:

https://github.com/bboozzoo/zephyr/

Changelog
=========

- added a common STM32 driver for Independent Watchdog (IWDG)

- added a common STM32 driver for External Interupt/Event Controller
(EXTI). This is particularly useful as it enables support for
interrupts on input GPIO lines. Having this, it is possible to start
working on drivers for I2C and SPI devices.

- updated initla GPIO patches with support for GPIO input

- added GPIO input interrupt triggers

- support for interrupt driven UART communication. This way we can
finally run the 'shell' sample demo

- updated board configs to match current master

- updated Nucleo-F103RB board config to enable UART console on USART1
port. This allows for using the serial console avaialble on the
STLink v2-1 USB connector (usually /dev/ttyACMx in the host system)

- a sample 'button' demo for showcasing GPIO input with interrupts

Other
=====

The following patches are independent and can be directly merged to
master:

clock_control: extend API with clock rate query operation
clock_control/Kconfig: move quark_se entries to separate file


Gerrit log
==========

New Changes:
https://gerrit.zephyrproject.org/r/915 soc/stm32f1: add IRQ numbers
listing
https://gerrit.zephyrproject.org/r/916 serial/stm32: add support for
IRQ APIs
https://gerrit.zephyrproject.org/r/917
interupt_controller/stm32_exti: driver for STM32 EXTI controller
https://gerrit.zephyrproject.org/r/918 gpio/stm32: GPIO input with
interrupts
https://gerrit.zephyrproject.org/r/919 soc/stm32f1: AFIO registers
mapping
https://gerrit.zephyrproject.org/r/920 soc/stm32f1/gpio: implement
MCU specific GPIO input interrupt integration
https://gerrit.zephyrproject.org/r/921 watchdog/iwdg_stm32: add
driver for STM32 Independent Watchdog (IWDG)
https://gerrit.zephyrproject.org/r/922 samples/button: button input
example

Updated Changes:
https://gerrit.zephyrproject.org/r/645 st_stm32/stm32f1: introduce
STM32F1x SoC family
https://gerrit.zephyrproject.org/r/647 clock_control/stm32f10x:
introduce driver for STM32F10x RCC
https://gerrit.zephyrproject.org/r/649 pinmux/stm32: add common
driver for STM32 pinmux
https://gerrit.zephyrproject.org/r/650 serial/stm32: add new driver
for STM32 UART
https://gerrit.zephyrproject.org/r/651 gpio/stm32: add common driver
for STM32 GPIO
https://gerrit.zephyrproject.org/r/652 boards/stm32_mini_a15: add
new board
https://gerrit.zephyrproject.org/r/653 samples/drivers/disco: add
'disco' sample program
https://gerrit.zephyrproject.org/r/711 clock_control/Kconfig: move
quark_se entries to separate file
https://gerrit.zephyrproject.org/r/712 clock_control: extend API
with clock rate query operation
https://gerrit.zephyrproject.org/r/713 soc/stm32f1/gpio: implement
GPIO support
https://gerrit.zephyrproject.org/r/714 soc/stm32f1/pinmux: implement
STM32 pinmux integration
https://gerrit.zephyrproject.org/r/715 boards/nucleo_f103rb: add new
board



Cheers,
--
Maciek Borzecki


Re: [RFC] GPIO API changes

Tomasz Bursztyka
 

Hi,

I sent a draft on gerrit:

https://gerrit.zephyrproject.org/r/#/c/914/

I kept enable/disable pin/port functions but the actual code in the driver
is slightly different.

So basically the real change are:
- gpio_callback_t is meant to be deprecated
- struct gpio_callback is the new way of providing a callback

- gpio_set_callback() is meant to be deprecated
- gpio_register_callback()/gpio_unregister_callback() are new ways of
handling callbacks

The thing I am not too found about is _gpio_compat_register_instance().
If there is another way, and seamless one even, would be nice.

Tomasz


Re: Zephyr SDK v0.7.2 - "rm -rf /"

Poussa, Sakari
 

Hi,

I had the same issue earlier. I filed the bug which wasn’t able to save you, Mads.

https://jira.zephyrproject.org/browse/ZEP-88

I was lucky enough not to run it under root.

Sakari

From: Mads Kristiansen <mkristian(a)outlook.com<mailto:mkristian(a)outlook.com>>
Date: To: "Nashif, Anas" <anas.nashif(a)intel.com<mailto:anas.nashif(a)intel.com>>
Cc: "devel(a)lists.zephyrproject.org<mailto:devel(a)lists.zephyrproject.org>" <devel(a)lists.zephyrproject.org<mailto:devel(a)lists.zephyrproject.org>>
Subject: [devel] Re: Re: Zephyr SDK v0.7.2 - "rm -rf /"

Hi Anas,

Yes, that is correct. I was installing it on OSX. Cannot really give more details about what happened except that I pressed ctrl-C during the installation. It was the only shell I had open at that moment, so I am pretty sure it was caused by the SDK.

Best regards, Mads

From: anas.nashif(a)intel.com<mailto:anas.nashif(a)intel.com>
To: mkristian(a)outlook.com<mailto:mkristian(a)outlook.com>
Date: Tue, 15 Mar 2016 15:13:12 +0000
CC: devel(a)lists.zephyrproject.org<mailto:devel(a)lists.zephyrproject.org>
Subject: [devel] Re: Zephyr SDK v0.7.2 - "rm -rf /"

Mads,

Were you trying to install the SDK on Mac OS?
If yes, this issue will be addressed in the latest SDK drop which will be released today.


Anas

On 14 Mar 2016, at 22:15, Mads Kristiansen <mkristian(a)outlook.com<mailto:mkristian(a)outlook.com>> wrote:

I downloaded the Zephyr SDK v0.7.2 last night and tried to install it this morning on my MacBook.

During the installation, I cancelled with ctrl-C and somehow it seems to have executed a "rm -rf /" (as root).

Obviously my system wont boot now, so I cannot examine this further until I have it up and running again. Just a heads up and maybe someone should have a glance at the SDK to make sure noone else gets into the same situation.

/ Mads


Re: Zephyr SDK v0.7.2 - "rm -rf /"

Mads Kristiansen <mads.kristiansen@...>
 

Yes, this is probably what happened :)

On 15/03/16 23:05, "Anderson Lizardo" <anderson.lizardo(a)gmail.com> wrote:

Hi Mads,

On Mon, Mar 14, 2016 at 10:15 PM, Mads Kristiansen
<mkristian(a)outlook.com> wrote:
I downloaded the Zephyr SDK v0.7.2 last night and tried to install it this
morning on my MacBook.

During the installation, I cancelled with ctrl-C and somehow it seems to
have executed a "rm -rf /" (as root).
I was curious on how this could happen. So I unpacked the installer
script (using "--noexec --target somedir --keep options") and looked
at setup.sh. This seems the most relevant snippet:

...
if [ -d $target_sdk_dir ]; then
# If the directory exists, test for write permission
if [ ! -w $target_sdk_dir ] ; then
echo "No permission, please run as 'sudo'"
exit 1
else
# wipe the directory first
read_confirm
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
rm -rf $target_sdk_dir/*
else
# Abort the installation
echo "SDK installation aborted!"
exit 1
fi
fi
else
...

The "read_confirm" function should have warned you that the directory
you provided (which I assume was some important directory such as /usr
or even /) was about to be removed:

...
# Read the input "y"
read_confirm () {
echo "The existing directory $target_sdk_dir will be removed! "
if [ "$confirm" != "y" ]; then
echo "Do you want to continue (y/n)? "
while read confirm; do
[ "$confirm" = "Y" -o "$confirm" = "y" -o "$confirm" = "n" \
-o "$confirm" = "N" ] && break
echo "Invalid input \"$confirm\", please input 'y' or 'n': "
done
else
echo
fi
}
...

My opinion is that given the installation script requires wiping the
existing target directory, it would be wise to either blacklist
important directories (/ /usr etc.) or simply exit with failure if the
target directory exists (safest option in my opinion, due to the point
below).

There is the possibility that the read bash function captures buffered
input data prior to the prompt (e.g. if the user unknowingly typed "y"
while the script was unpacking), which is very dangerous in this case.

Obviously my system wont boot now, so I cannot examine this further until I
have it up and running again. Just a heads up and maybe someone should have
a glance at the SDK to make sure noone else gets into the same situation.
Best Regards,
--
Anderson Lizardo


Re: FRDM-K64 GPIO driver name

Anders Dam Kofoed <adk@...>
 

Hi idups

Yes, I do see flashing tx lights on the board when typing something in the "screen /dev/ttyACM0". I have also tried all possible options in the "make menuconfig" but with no luck.
Regarding the pinmix driver. I see that there's an entry for the K20 but nothing for the K6x? Even in the include/drivers/k6x_ files. This is the pcr for K20:
zephyr-project/include/drivers/k20_pcr.h

Kind regards
Anders


Re: FRDM-K64 GPIO driver name

Anders Dam Kofoed <adk@...>
 

Hi Maureen,

Thanks for taking the time.

I am not sure how I would set the PORTB_PCR[22] as an output (red led). I have tried a few things including looking at outdir/.config and changing the driver to
#define GPIO_DRV_NAME CONFIG_PINMUX_K64_GPIO_B_NAME

Also including setting CONFIG_PINMUX_K64=y and CONFIG_PINMUX=y in prj.conf. Still; no output on the console. I've been through all the settings in the "make menuconfig" and nothing seems to help. And yes, I do see flashing tx lights on the board when typing something in the "screen /dev/ttyACM0".
Kind regards
Anders


Re: RFC: Change returning type from Pinmux APIs

Kalowsky, Daniel <daniel.kalowsky@...>
 

Short version +1

-----Original Message-----
From: Andre Guedes [mailto:andre.guedes(a)intel.com]
Sent: Tuesday, March 15, 2016 2:58 PM
To: devel(a)lists.zephyrproject.org
Subject: [devel] RFC: Change returning type from Pinmux APIs

Hi all,

While I was working on the errno transition patchset, I realized all driver
APIs (i2c, spi, gpio, etc.) return 'int' type, but pinmux APIs. For the sake
of consistency, I think we should change the returning type from 'uint32_t'
to 'int' in include/pinmux.h APIs.
Another case of history and not properly updating the API after it has changed. Nice find.

Besides keeping consistency between all drivers APIs, this change would also
be aligned with the errno.h code transition we're discussing in the other
thread. Pinmux drivers will return negative errno.h codes in case of error
so returning 'int' is more suitable than 'uint32_t'.

I sent a patch [1] as draft so you can have a idea of the changes required
(basically, API and drivers).

This change conflicts with the pinmux patchset from Vinicius. We talked
offline and we are both fine to whatever patch gets merged first.
Good.


Regards,

Andre

[1] https://gerrit.zephyrproject.org/r/#/c/881/


RFC: Change returning type from Pinmux APIs

Andre Guedes <andre.guedes@...>
 

Hi all,

While I was working on the errno transition patchset, I realized all driver
APIs (i2c, spi, gpio, etc.) return 'int' type, but pinmux APIs. For the sake
of consistency, I think we should change the returning type from 'uint32_t'
to 'int' in include/pinmux.h APIs.

Besides keeping consistency between all drivers APIs, this change would also
be aligned with the errno.h code transition we're discussing in the other
thread. Pinmux drivers will return negative errno.h codes in case of error
so returning 'int' is more suitable than 'uint32_t'.

I sent a patch [1] as draft so you can have a idea of the changes required
(basically, API and drivers).

This change conflicts with the pinmux patchset from Vinicius. We talked
offline and we are both fine to whatever patch gets merged first.

Regards,

Andre

[1] https://gerrit.zephyrproject.org/r/#/c/881/


Re: FRDM-K64 GPIO driver name

Idupsle <idupsle@...>
 

Hey Marueen,
I'm wondering now, because I've searched for the multiplex-lib for the K64
and found nothing (But for the arduinos). So I thought: only the first
function of every pin/port is accessable. And configuring single Pins
impossible as long as some kernel defined global Variable for set_by_pins =
0. (Can't remember the exact name).
Where is the source code for the K64? Thanks :)

On Tue, Mar 15, 2016 at 9:57 PM, Maureen Helm <maureen.helm(a)nxp.com> wrote:

Hi Anders,
I took a quick look and ran your code, and it appears that the pinmux for
PTB22 is not configured correctly. The register field PORTB_PCR[MUX] is set
to 0 when it should be set to 1. You should be able to fix this by pulling
in the pinmux driver and changing the pin to function 1.
Maureen

-----Original Message-----
From: Anders Dam Kofoed [mailto:adk(a)accipio.dk]
Sent: Tuesday, March 15, 2016 5:20 AM
To: devel(a)lists.zephyrproject.org
Subject: [devel] Re: Re: FRDM-K64 GPIO driver name

Hi Thomasz,

Yesterday I tried with the following source code - but nothing happens :(
Nothing blinks. I programming it by copying the outdir/zephyr.bin onto
the
MBED folder. The board seems to "eat" it as it should but nothing
happens -
even after a reset.

GPIO out pin is Port B pin 22. Input is port B pin 9.
What puzzels me the most is that I do not get ANY debug output on the
console (screen /dev/ttyACM0 in Linux). I'd really like it to just show
a sign of
life...

--- prj.conf ---
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_NANO_TIMERS=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_GPIO=y

---------------
--- main.c ---
#include <zephyr.h>
#include <device.h>
#include <gpio.h>
#include <sys_clock.h>


#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif

#define SLEEPTICKS SECONDS(1)

#define GPIO_OUT_PIN 22
#define GPIO_INT_PIN 9
#define GPIO_NAME "GPIO_"
#define GPIO_DRV_NAME CONFIG_GPIO_K64_B_DEV_NAME

void gpio_callback(struct device *port, uint32_t pin) {
PRINT(GPIO_NAME "%d triggered\n", pin); }


void main(void)
{
PRINT("Hello World!\n");
printf("Hello World!\n");

struct nano_timer timer;
void *timer_data[1];
struct device *gpio_dev;
int ret;
int toggle = 0;

nano_timer_init(&timer, timer_data);

gpio_dev = device_get_binding(GPIO_DRV_NAME);
if (!gpio_dev) {
PRINT("Cannot find %s!\n", GPIO_DRV_NAME);
}

/* Setup GPIO output */
ret = gpio_pin_configure(gpio_dev, GPIO_OUT_PIN,
(GPIO_DIR_OUT));
if (ret) {
PRINT("Error configuring " GPIO_NAME "%d!\n",
GPIO_OUT_PIN);
}

/* Setup GPIO input, and triggers on rising edge. */
ret = gpio_pin_configure(gpio_dev, GPIO_INT_PIN,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
| GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE));
if (ret) {
PRINT("Error configuring " GPIO_NAME "%d!\n",
GPIO_INT_PIN);
}

ret = gpio_set_callback(gpio_dev, gpio_callback);
if (ret) {
PRINT("Cannot setup callback!\n");
}

ret = gpio_pin_enable_callback(gpio_dev, GPIO_INT_PIN);
if (ret) {
PRINT("Error enabling callback!\n");
}

while (1) {
PRINT("Toggling " GPIO_NAME "%d\n", GPIO_OUT_PIN);

ret = gpio_pin_write(gpio_dev, GPIO_OUT_PIN, toggle);
if (ret) {
PRINT("Error set " GPIO_NAME "%d!\n",
GPIO_OUT_PIN);
}

if (toggle) {
toggle = 0;
} else {
toggle = 1;
}

nano_timer_start(&timer, SLEEPTICKS);
nano_timer_test(&timer, TICKS_UNLIMITED);
}


}


Re: FRDM-K64 GPIO driver name

Maureen Helm
 

Hi Anders,
I took a quick look and ran your code, and it appears that the pinmux for PTB22 is not configured correctly. The register field PORTB_PCR[MUX] is set to 0 when it should be set to 1. You should be able to fix this by pulling in the pinmux driver and changing the pin to function 1.
Maureen

-----Original Message-----
From: Anders Dam Kofoed [mailto:adk(a)accipio.dk]
Sent: Tuesday, March 15, 2016 5:20 AM
To: devel(a)lists.zephyrproject.org
Subject: [devel] Re: Re: FRDM-K64 GPIO driver name

Hi Thomasz,

Yesterday I tried with the following source code - but nothing happens :(
Nothing blinks. I programming it by copying the outdir/zephyr.bin onto the
MBED folder. The board seems to "eat" it as it should but nothing happens -
even after a reset.

GPIO out pin is Port B pin 22. Input is port B pin 9.
What puzzels me the most is that I do not get ANY debug output on the
console (screen /dev/ttyACM0 in Linux). I'd really like it to just show a sign of
life...

--- prj.conf ---
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_NANO_TIMERS=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_GPIO=y

---------------
--- main.c ---
#include <zephyr.h>
#include <device.h>
#include <gpio.h>
#include <sys_clock.h>


#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif

#define SLEEPTICKS SECONDS(1)

#define GPIO_OUT_PIN 22
#define GPIO_INT_PIN 9
#define GPIO_NAME "GPIO_"
#define GPIO_DRV_NAME CONFIG_GPIO_K64_B_DEV_NAME

void gpio_callback(struct device *port, uint32_t pin) {
PRINT(GPIO_NAME "%d triggered\n", pin); }


void main(void)
{
PRINT("Hello World!\n");
printf("Hello World!\n");

struct nano_timer timer;
void *timer_data[1];
struct device *gpio_dev;
int ret;
int toggle = 0;

nano_timer_init(&timer, timer_data);

gpio_dev = device_get_binding(GPIO_DRV_NAME);
if (!gpio_dev) {
PRINT("Cannot find %s!\n", GPIO_DRV_NAME);
}

/* Setup GPIO output */
ret = gpio_pin_configure(gpio_dev, GPIO_OUT_PIN,
(GPIO_DIR_OUT));
if (ret) {
PRINT("Error configuring " GPIO_NAME "%d!\n",
GPIO_OUT_PIN);
}

/* Setup GPIO input, and triggers on rising edge. */
ret = gpio_pin_configure(gpio_dev, GPIO_INT_PIN,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
| GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE));
if (ret) {
PRINT("Error configuring " GPIO_NAME "%d!\n",
GPIO_INT_PIN);
}

ret = gpio_set_callback(gpio_dev, gpio_callback);
if (ret) {
PRINT("Cannot setup callback!\n");
}

ret = gpio_pin_enable_callback(gpio_dev, GPIO_INT_PIN);
if (ret) {
PRINT("Error enabling callback!\n");
}

while (1) {
PRINT("Toggling " GPIO_NAME "%d\n", GPIO_OUT_PIN);

ret = gpio_pin_write(gpio_dev, GPIO_OUT_PIN, toggle);
if (ret) {
PRINT("Error set " GPIO_NAME "%d!\n",
GPIO_OUT_PIN);
}

if (toggle) {
toggle = 0;
} else {
toggle = 1;
}

nano_timer_start(&timer, SLEEPTICKS);
nano_timer_test(&timer, TICKS_UNLIMITED);
}


}

8321 - 8340 of 8692