Date
1 - 14 of 14
FRDM-K64 GPIO driver name
Anders Dam Kofoed <adk@...>
Hi,
I am trying to use GPIO on my Freescale FRDM-K64 board. However, I cannot seem to find the driver name. It from this page that the driver name should be something like CONFIG_GPIO_<VENDOR_<MCU>_PORTn_DEV_NAME but nothing matches the FRDM-K64. https://www.zephyrproject.org/doc/reference/kconfig/index.html This is the code I'm trying to use (where GPIO_DRV_NAME should be what I need): gpio_dev = device_get_binding(GPIO_DRV_NAME); if (!gpio_dev) { PRINT("Cannot find %s!\n", GPIO_DRV_NAME); } Got it from the GPIO example. Any hints? /Anders |
|
Tomasz Bursztyka
Hi Anders,
toggle quoted message
Show quoted text
According to arch/arm/soc/fsl_frdm_k64f/Kconfig GPIO and GPIO_K64 are set by default. Verify you get these in your output/.config The name you should use is GPIO_K64_<X>_DEV_NAME (where X can be A, B, C, D or E) (so you should set #define GPIO_DRV_NAME CONFIG_K64_<X>_DEV_NAME in your code I guess) Tomasz Hi, |
|
Anders Dam Kofoed <adk@...>
Thanks Tomasz,
It compiles :) I will try lator today with a real GPIO test. Thanks again. /Anders |
|
Anders Dam Kofoed <adk@...>
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); } } |
|
Idupsle <idupsle@...>
Hi, Reffering to my post in users, I wasn't successfully activating the
LEDs, but I got the debug output. See below --- prj.conf ---I've following settings: CONFIG_ARM=y CONFIG_SOC_FSL_FRDM_K64F=y CONFIG_BOARD_FRDM_K64F=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_UART_K20=y Now the printk/f should be to uart. Nevertheless, I tried NXP's MQX. There I found, that activating the LED was done by setting the output of the Pin to one and then to zero. Maybe thats the way it is done since the cathode is, reffering to the manual, on the processor side. |
|
Anders Dam Kofoed <adk@...>
Hi,
I have tried your settings above and also with the following - but it still does not work: CONFIG_STDOUT_CONSOLE=y CONFIG_PRINTK=y I am using the latest firmware 226 and programming the board using the "copy" method. Programming seems to work fine judging from the way it usually reacts. How are you programming the board? |
|
Idupsle <idupsle@...>
I did copy it to the MBED Mount Point (Actual Firmware)...
toggle quoted message
Show quoted text
Besides, I forgot that I played a little bit with the kernel-config, which isn't present in my prj.conf... but I'm sorry to say that I'm away from home until saturday. But I think if you look at the other examples in the Zephyr Project you'll get it to run. (Thats the way i fiddled it out) Does the orange led on the usb-connection blink, if you type something in the tty-session? On Tue, Mar 15, 2016 at 8:25 PM, Anders Dam Kofoed <adk(a)accipio.dk> wrote:
Hi, |
|
Carlos Carrizosa <c.carrizosa@...>
Hi,
toggle quoted message
Show quoted text
I don't know what's happening with your UART but regarding the GPIO, I think the problem is K64 gpio driver doesn't configure the pin as GPIO when you call the gpio_pin_configure function. I got the same problem and applying the next patch solve it to me: diff --git a/drivers/gpio/gpio_k64.c b/drivers/gpio/gpio_k64.c index 2d6a355..011eb52 100644 --- a/drivers/gpio/gpio_k64.c +++ b/drivers/gpio/gpio_k64.c @@ -111,6 +111,9 @@ static int gpio_k64_config(struct device *dev, int access_op, } } + /* Ensure pin is configured as GPIO */ + setting |= K64_PINMUX_FUNC_GPIO; + /* write pull-up/-down and, if set, interrupt configuration settings */ if (access_op == GPIO_ACCESS_BY_PIN) { Regards, Carlos Carrizosa 2016-03-15 20:43 GMT+01:00 idups idups <idupsle(a)gmail.com>:
|
|
Maureen Helm
Hi Anders,
toggle quoted message
Show quoted text
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----- |
|
Idupsle <idupsle@...>
Hey Marueen,
toggle quoted message
Show quoted text
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, |
|
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 |
|
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 |
|
Anders Dam Kofoed <adk@...>
Hi Maureen and Idups
I got UART output (printf) working using minicom. Don't know what the difference between screen and minicom is but using minicom I set it to not use flowcontrol 115200 8N1 and it worked... ## GPIO Also, GPIO interrupt is working just fine. However, as @Maureen writes above, the PCR has not setup PTB22 as default. The pins are configured in an arduino style configuration as default: zephyr-project/arch/arm/soc/fsl_frdm_k64f/soc_config.c So using these pins as input or output GPIO works just fine. Thanks for your inputs. Kind regards Anders |
|
Idupsle <idupsle@...>
diff --git a/drivers/gpio/gpio_k64.c b/drivers/gpio/gpio_k64.cHi, quite well, with your patch, I got the output! Now I'm wondering how I can manually set the pins to FUNC_GPIO = K64_PINMUX_ALT_1 = (0x1 << 8). If I write something like #include <device.h> #include <gpio.h> #include <sys_io.h> #include <pinmux.h> #include <zephyr.h> #define GPIO_1 CONFIG_PINMUX_K64_GPIO_B_NAME void main(void) { struct device *gpio_dev_1; gpio_dev_1 = device_get_binding(GPIO_1); uint32_t set = (0x1<<8); pinmux_pin_set(gpio_dev_1,22, set); int set_res = 0; int* set_res_ptr = 0; pinmux_pin_get(gpio_dev_1, 22, set_res_ptr); printk("Pin 22 is set to: %u \n",set_res); while(1){} } Nothing happens. Debugging tells me, that the command pinmux_pin_set(gpio_dev_1,22, set) is not executed at all. It should call: static int _fsl_k64_set_pin(struct device *dev, uint32_t pin_id, uint32_t func) but doesn't. pinmux_pin_get() Executes as excepted. Any clue, why? |
|