-
Notifications
You must be signed in to change notification settings - Fork 1
fixed typo #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wassti
wants to merge
4
commits into
mdhardenburgh:main
Choose a base branch
from
wassti:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fixed typo #3
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # To cross compile on x86 use the following flags | ||
| #include ../../peripheralController/peripheralController.mk | ||
| #ARM_GCC_PATH = ../../../gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin/ | ||
| #CXX = $(ARM_GCC_PATH)aarch64-none-linux-gnu-g++ | ||
| #ARCH_FLAGS = -march=armv8-a | ||
| #STARTUP_DEFS = | ||
| #CXX_FLAGS = $(ARCH_FLAGS) $(STARTUP_DEFS) -c -g -std=c++11 -Wall -W -Werror -pedantic | ||
|
|
||
| # To Compile on the Jetson use the following flags | ||
| #include ../../peripheralController/peripheralController.mk | ||
| ARM_GCC_PATH = ../../../gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin/ | ||
| CXX = g++ | ||
| ARCH_FLAGS = -march=armv8-a | ||
| STARTUP_DEFS = | ||
| CXX_FLAGS = $(STARTUP_DEFS) -c -g -std=c++11 -Wall -W -Werror -pedantic | ||
|
|
||
| keyboard_emu: keyboard_emu.o peripheralController.o | ||
| $(CXX) $^ -o $@ | ||
|
|
||
| keyboard_emu.o: keyboard_emu.cpp | ||
| $(CXX) $^ $(CXX_FLAGS) -o $@ | ||
|
|
||
| peripheralController.o: ../../peripheralController/peripheralController.cpp | ||
| $(CXX) $^ $(CXX_FLAGS) -o $@ | ||
|
|
||
| clean: | ||
| rm -f keyboard_emu | ||
| rm -r keyboard_emu.o | ||
| rm -f ../../peripheralController/peripheralController.o |
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,189 @@ | ||
| //This example uses pin 40, 38, and 37. | ||
| //GND -> Switch | ||
| //3.3v -> Resistor -> other side of switch + Pin 40/38/37 | ||
| //It is assumed pins are held high when the switch is open | ||
| //When a pin goes low from a switch closing, it will be passed as keyboard input. | ||
| //pin40==keyboard_1 | ||
| //pin39==keyboard_2 | ||
| //pin37==keyboard_3 | ||
|
|
||
| #include <iostream> | ||
| #include <string> | ||
| #include <cassert> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <unistd.h> | ||
| #include <sys/fcntl.h> | ||
| #include <cstring> | ||
| #include <linux/uinput.h> | ||
|
|
||
| #include "../../peripheralController/peripheralController.h" | ||
| #include "../../gpioController/gpio.h" | ||
| #include "../../pinmuxController/pinmuxController.h" | ||
|
|
||
| //for emitting keyboard events to the OS | ||
| //https://www.kernel.org/doc/html/v4.12/input/uinput.html | ||
| void emit(int fk, int type, int code, int val) | ||
| { | ||
| struct input_event ie; | ||
|
|
||
| ie.type = type; | ||
| ie.code = code; | ||
| ie.value = val; | ||
| /* timestamp values below are ignored */ | ||
| ie.time.tv_sec = 0; | ||
| ie.time.tv_usec = 0; | ||
|
|
||
| write(fk, &ie, sizeof(ie)); | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| PeripheralController myGpioController1(gpioController::gpioController1BaseAddress); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The style I use is indent of 4 spaces for every scope. Can you change it to that? |
||
| PeripheralController myGpioController2(gpioController::gpioController2BaseAddress); | ||
| PeripheralController myGpioController3(gpioController::gpioController3BaseAddress); | ||
| PeripheralController myGpioController4(gpioController::gpioController4BaseAddress); | ||
| PeripheralController myGpioController5(gpioController::gpioController5BaseAddress); | ||
| PeripheralController myGpioController6(gpioController::gpioController6BaseAddress); | ||
| PeripheralController myGpioController7(gpioController::gpioController7BaseAddress); | ||
| PeripheralController myGpioController8(gpioController::gpioController8BaseAddress); | ||
| PeripheralController myPinMuxController(pinmuxController::baseAddress); | ||
|
|
||
| // set up our emulated keyboard | ||
| struct uinput_setup usetup; | ||
| int fk = open("/dev/uinput", O_WRONLY | O_NONBLOCK); | ||
|
|
||
| ioctl(fk, UI_SET_EVBIT, EV_KEY); | ||
|
|
||
| // You must define each key that should exist in our emulated keyboard. | ||
| // A list of common input event codes can be found at: | ||
| // https://code.woboq.org/qt5/include/linux/input-event-codes.h.html | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_SPACE); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_ENTER); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_ESC); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_BACKSPACE); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_TAB); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_LEFT); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_RIGHT); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_UP); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_DOWN); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_1); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_2); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_3); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_4); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_5); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_6); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_7); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_8); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_9); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_0); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_A); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_B); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_C); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_D); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_E); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_F); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_G); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_H); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_I); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_J); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_K); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_L); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_M); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_N); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_O); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_P); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_Q); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_R); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_S); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_T); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_U); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_V); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_W); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_X); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_Y); | ||
| ioctl(fk, UI_SET_KEYBIT, KEY_Z); | ||
|
|
||
|
|
||
| memset(&usetup, 0, sizeof(usetup)); | ||
| usetup.id.bustype = BUS_USB; | ||
| usetup.id.vendor = 0x1234; /* sample vendor */ | ||
| usetup.id.product = 0x5678; /* sample product */ | ||
| strcpy(usetup.name, "Jetson GPIO"); | ||
|
|
||
| //actually initalizes/"plugs in" the keyboard | ||
| ioctl(fk, UI_DEV_SETUP, &usetup); | ||
| ioctl(fk, UI_DEV_CREATE); | ||
|
|
||
| //Force J41-pin40 to input mode | ||
| myGpioController3.setRegisterField(GPIO_CNF_1_RMW::addressOffset, gpioController::BIT_N_GPIO, GPIO_CNF_1_RMW::BIT_6_baseBit, GPIO_CNF_1_RMW::BIT_6_bitWidth); | ||
| myPinMuxController.setRegisterField(PINMUX_AUX_DAP4_DOUT_0::addressOffset, pinmuxController::PUPD_BIT_PULL_UP, PINMUX_AUX_DAP4_DOUT_0::PUPD_bit, PINMUX_AUX_DAP4_DOUT_0::PUPD_bitWidth); | ||
| myPinMuxController.setRegisterField(PINMUX_AUX_DAP4_DOUT_0::addressOffset, pinmuxController::E_INPUT_BIT_ENABLE, PINMUX_AUX_DAP4_DOUT_0::E_INPUT_bit, PINMUX_AUX_DAP4_DOUT_0::E_INPUT_bitWidth); | ||
|
|
||
| //Force J41-pin38 to input mode | ||
| myGpioController3.setRegisterField(GPIO_CNF_1_RMW::addressOffset, gpioController::BIT_N_GPIO, GPIO_CNF_1_RMW::BIT_5_baseBit, GPIO_CNF_1_RMW::BIT_5_bitWidth); | ||
| myPinMuxController.setRegisterField(PINMUX_AUX_DAP4_DIN_0::addressOffset, pinmuxController::PUPD_BIT_PULL_UP, PINMUX_AUX_DAP4_DIN_0::PUPD_bit, PINMUX_AUX_DAP4_DIN_0::PUPD_bitWidth); | ||
| myPinMuxController.setRegisterField(PINMUX_AUX_DAP4_DIN_0::addressOffset, pinmuxController::E_INPUT_BIT_ENABLE, PINMUX_AUX_DAP4_DIN_0::E_INPUT_bit, PINMUX_AUX_DAP4_DIN_0::E_INPUT_bitWidth); | ||
|
|
||
| //Force J41-pin37 to input mode | ||
| myGpioController1.setRegisterField(GPIO_CNF_1_RMW::addressOffset, gpioController::BIT_N_GPIO, GPIO_CNF_1_RMW::BIT_4_baseBit, GPIO_CNF_1_RMW::BIT_4_bitWidth); | ||
| myPinMuxController.setRegisterField(PINMUX_AUX_SPI2_MOSI_0::addressOffset, pinmuxController::PUPD_BIT_PULL_UP, PINMUX_AUX_SPI2_MOSI_0::PUPD_bit, PINMUX_AUX_SPI2_MOSI_0::PUPD_bitWidth); | ||
| myPinMuxController.setRegisterField(PINMUX_AUX_SPI2_MOSI_0::addressOffset, pinmuxController::E_INPUT_BIT_ENABLE, PINMUX_AUX_SPI2_MOSI_0::E_INPUT_bit, PINMUX_AUX_SPI2_MOSI_0::E_INPUT_bitWidth); | ||
|
|
||
| uint32_t readGPIOINPUT = gpioController::BIT_N_HIGH; | ||
| bool pin40val = 0; | ||
| bool pin39val = 0; | ||
| bool pin37val = 0; | ||
|
|
||
| while(true) | ||
| { | ||
| readGPIOINPUT = myGpioController3.getRegisterField(GPIO_IN_1_RMW::addressOffset, GPIO_IN_1_RMW::BIT_6_baseBit, GPIO_IN_1_RMW::BIT_6_bitWidth); | ||
| //std::cout<<"pin 40 INPUT bit: "<<readGPIOINPUT<<std::endl; | ||
| if(readGPIOINPUT == 0) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The style I use is } |
||
| if(!pin40val) { | ||
| emit(fk, EV_KEY, KEY_1, 1); | ||
| emit(fk, EV_SYN, SYN_REPORT, 0); | ||
| pin40val = 1; | ||
| } | ||
| } else { | ||
| if(pin40val) { | ||
| emit(fk, EV_KEY, KEY_1, 0); | ||
| emit(fk, EV_SYN, SYN_REPORT, 0); | ||
| pin40val = 0; | ||
| } | ||
| } | ||
|
|
||
| readGPIOINPUT = myGpioController3.getRegisterField(GPIO_IN_1_RMW::addressOffset, GPIO_IN_1_RMW::BIT_5_baseBit, GPIO_IN_1_RMW::BIT_5_bitWidth); | ||
| //std::cout<<"pin 38 INPUT bit: "<<readGPIOINPUT<<std::endl; | ||
| if(readGPIOINPUT == 0) { | ||
| if(!pin39val) { | ||
| emit(fk, EV_KEY, KEY_2, 1); | ||
| emit(fk, EV_SYN, SYN_REPORT, 0); | ||
| pin39val = 1; | ||
| } | ||
| } else { | ||
| if(pin39val) { | ||
| emit(fk, EV_KEY, KEY_2, 0); | ||
| emit(fk, EV_SYN, SYN_REPORT, 0); | ||
| pin39val = 0; | ||
| } | ||
| } | ||
|
|
||
| readGPIOINPUT = myGpioController1.getRegisterField(GPIO_IN_1_RMW::addressOffset, GPIO_IN_1_RMW::BIT_4_baseBit, GPIO_IN_1_RMW::BIT_4_bitWidth); | ||
| //std::cout<<"pin 37 INPUT bit: "<<readGPIOINPUT<<std::endl; | ||
| if(readGPIOINPUT == 0) { | ||
| if(!pin37val) { | ||
| emit(fk, EV_KEY, KEY_3, 1); | ||
| emit(fk, EV_SYN, SYN_REPORT, 0); | ||
| pin37val = 1; | ||
| } | ||
| } else { | ||
| if(pin37val) { | ||
| emit(fk, EV_KEY, KEY_3, 0); | ||
| emit(fk, EV_SYN, SYN_REPORT, 0); | ||
| pin37val = 0; | ||
| } | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
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,29 @@ | ||
| # To cross compile on x86 use the following flags | ||
| #include ../../peripheralController/peripheralController.mk | ||
| #ARM_GCC_PATH = ../../../gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin/ | ||
| #CXX = $(ARM_GCC_PATH)aarch64-none-linux-gnu-g++ | ||
| #ARCH_FLAGS = -march=armv8-a | ||
| #STARTUP_DEFS = | ||
| #CXX_FLAGS = $(ARCH_FLAGS) $(STARTUP_DEFS) -c -g -std=c++11 -Wall -W -Werror -pedantic | ||
|
|
||
| # To Compile on the Jetson use the following flags | ||
| #include ../../peripheralController/peripheralController.mk | ||
| ARM_GCC_PATH = ../../../gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin/ | ||
| CXX = g++ | ||
| ARCH_FLAGS = -march=armv8-a | ||
| STARTUP_DEFS = | ||
| CXX_FLAGS = $(STARTUP_DEFS) -c -g -std=c++11 -Wall -W -Werror -pedantic | ||
|
|
||
| read_all_inputs: read_all_inputs.o peripheralController.o | ||
| $(CXX) $^ -o $@ | ||
|
|
||
| read_all_inputs.o: read_all_inputs.cpp | ||
| $(CXX) $^ $(CXX_FLAGS) -o $@ | ||
|
|
||
| peripheralController.o: ../../peripheralController/peripheralController.cpp | ||
| $(CXX) $^ $(CXX_FLAGS) -o $@ | ||
|
|
||
| clean: | ||
| rm -f read_all_inputs | ||
| rm -r read_all_inputs.o | ||
| rm -f ../../peripheralController/peripheralController.o |
Oops, something went wrong.
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.
Maybe add a short comment that elaborates about the example program. I also use following block comments style for header comments
/*
*
*/
I would like to keep the style the same, can you change it to that style?.