This repository was archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
[k64f] Restore GPIO functionality by enabling pins via pinmux #954
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_PINMUX_MCUX_PORTD=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2017, Intel Corporation. | ||
|
||
// Test code for FRDM-K64F that listens on pins D1-D15 as inputs and prints a | ||
// message whenever one changes. Blinks D0 indefinitely, so you connect a | ||
// jumper wire from D0 to each of the other pins (one at a time) and see which | ||
// ones generate a console message. | ||
|
||
console.log("Test external GPIOs as inputs..."); | ||
|
||
console.log("\nWire D0 to each of D1-D15 in turn!"); | ||
console.log("(D14-D15 are at the end of the 10-pin header)\n"); | ||
|
||
// Expected results: All pins but D8 currently show up with input events | ||
|
||
// import gpio module | ||
var gpio = require("gpio"); | ||
var pins = require("k64f_pins"); | ||
|
||
// blink D0 forever | ||
var tick = 250, toggle = false; | ||
var output = gpio.open({pin: pins.D0}); | ||
setInterval(function () { | ||
output.write(toggle); | ||
toggle = !toggle; | ||
}, tick); | ||
|
||
// test all pins but D0 | ||
var testpins = [pins.D1, pins.D2, pins.D3, pins.D4, pins.D5, pins.D6, pins.D7, | ||
pins.D8, pins.D9, pins.D10, pins.D11, pins.D12, pins.D13, | ||
pins.D14, pins.D15]; | ||
var pincount = testpins.length; | ||
|
||
var count = 1; | ||
var gpios = []; | ||
for (var i = 0; i < pincount; i++) { | ||
gpios[i] = gpio.open({pin: testpins[i], direction: 'in', edge: 'rising'}); | ||
gpios[i].onchange = function(event) { | ||
console.log("Input event", count); | ||
count++; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2017, Intel Corporation. | ||
|
||
// Test code for FRDM-K64F that toggles each of pins D1-D15 as outputs | ||
// indefinitely. Configures D0 as an input and prints a message whenever it | ||
// changes, so you connect a jumper wire from D0 to each of the other pins (one | ||
// at a time) and see which ones generate a console message. | ||
|
||
console.log("Test external GPIOs as outputs..."); | ||
|
||
console.log("\nWire D0 to each of D1-D15 in turn!"); | ||
console.log("(D14-D15 are at the end of the 10-pin header)\n"); | ||
|
||
// Expected results: All pins but D8 currently show up with output events | ||
|
||
// import gpio module | ||
var gpio = require("gpio"); | ||
var pins = require("k64f_pins"); | ||
|
||
// blink D0 forever | ||
var input = gpio.open({pin: pins.D0, direction: 'in', edge: 'rising'}); | ||
var count = 1; | ||
input.onchange = function(event) { | ||
console.log("Output event", count); | ||
count++; | ||
} | ||
|
||
// test all pins but D0 | ||
var testpins = [pins.D1, pins.D2, pins.D3, pins.D4, pins.D5, pins.D6, pins.D7, | ||
pins.D8, pins.D9, pins.D10, pins.D11, pins.D12, pins.D13, | ||
pins.D14, pins.D15]; | ||
var pincount = testpins.length; | ||
var gpios = []; | ||
for (var i = 0; i < pincount; i++) { | ||
gpios[i] = gpio.open({pin: testpins[i]}); | ||
} | ||
|
||
var tick = 250, toggle = false; | ||
setInterval(function () { | ||
for (var i = 0; i < pincount; i++) { | ||
gpios[i].write(toggle); | ||
} | ||
toggle = !toggle; | ||
}, tick); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2017, Intel Corporation. | ||
|
||
// This file is currently meant only for FRDM_K64F board | ||
|
||
// C includes | ||
#include <stdio.h> | ||
|
||
// Zephyr includes | ||
#include <kernel.h> | ||
#include <init.h> | ||
#include <pinmux.h> | ||
#include <pinmux/pinmux.h> | ||
#include <fsl_port.h> | ||
|
||
// CONFIG_INIT_PINMUX_PRIORITY + 1 to override default pinmux settings | ||
#define CONFIG_K64F_PINMUX_PRIORITY 46 | ||
|
||
int frdm_k64f_pinmux_setup(struct device *unused) | ||
{ | ||
// NOTE: Here we enable all the controllers but in a real design you would | ||
// probably try to optimize for the minimum number of GPIO controllers | ||
// turned on to save power. See zephyr/boards/arm/frdm_k64f/pinmux.c for | ||
// defaults. | ||
|
||
// TODO: eventually we maybe need to analyze script to decide how to do | ||
// pinmux, or have user provide a static configuration | ||
struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); | ||
pinmux_pin_set(porta, 0, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
|
||
struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); | ||
pinmux_pin_set(portb, 9, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portb, 23, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
|
||
struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); | ||
pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portc, 3, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portc, 4, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
|
||
struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); | ||
pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
|
||
struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); | ||
pinmux_pin_set(porte, 25, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAsGpio)); | ||
return 0; | ||
} | ||
|
||
SYS_INIT(frdm_k64f_pinmux_setup, POST_KERNEL, CONFIG_K64F_PINMUX_PRIORITY); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you put the \n in the end of the print above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I think this is better - this is an 'extra' newline for a blank line; console.log already puts a newline. If I put it at the end it would look more like a normal newline.