Created
March 20, 2017 04:30
-
-
Save xiupos/22555fbf6353c3e1dca014f46c6a6f6b to your computer and use it in GitHub Desktop.
LPC810についていろいろメモ(4)GPIO入力関連
This file contains 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
// LPC810についていろいろメモ(4)GPIO入力関連 | |
// ha2zakura | |
// 参考: | |
// http://www.nxp.com/documents/user_manual/UM10601.pdf | |
// 省略部分はメモ(1) | |
// ___ ___ | |
// PIO0_5 [1|O U |8] PIO0_0 | |
// PIO0_4 [2| |7] GND | |
// PIO0_3 [3| |6] 3.3V | |
// PIO0_2 [4|_______|5] PIO0_1 | |
#include "LPC8xx.h" | |
// CMSISライブラリをinclude | |
int main(void) { | |
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7); | |
// clock有効化の設定...? | |
// 省略 | |
LPC_SWM->PINENABLE0 = 0xffffffbfUL; | |
// 有効化するピンの設定...? | |
// 省略 | |
LPC_GPIO_PORT->DIR0 |= (1<<2); | |
// GPIOの設定 | |
// 省略 | |
while(1){ | |
if(LPC_GPIO_PORT->PIN0 & (1<<1)) | |
// GPIO入力 | |
// UM10601 7.6.5 Table 86. | |
// 0:LOW 1:HIGH | |
// 0 => PIO0_0 | |
//>1 => PIO0_1 | |
// 2 => PIO0_2 | |
// ... | |
// 17 => PIO0_17 | |
// 注:LPC810は5(PIO0_5)まで | |
{ | |
LPC_GPIO_PORT->CLR0 |= (1<<2); | |
}else{ | |
LPC_GPIO_PORT->SET0 |= (1<<2); | |
} | |
} | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment