Created
April 12, 2017 10:53
-
-
Save tnishinaga/84a670fd5ef0b50b6e3d7616f70bb946 to your computer and use it in GitHub Desktop.
マイコンのレジスタをよくあるdefine文以外の方法でレジスタの設定するコードのイメージ。
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
typedef struct { | |
const struct { | |
uint32_t CTSEN; | |
uint32_t RTSEN; | |
uint32_t RTS; | |
uint32_t DTR; | |
uint32_t RXE; | |
uint32_t TXE; | |
uint32_t LBE; | |
uint32_t SIRLP; | |
uint32_t SIREN; | |
uint32_t UARTEN; | |
} CR; | |
} uart_bit_t; | |
const uart_bit_t u = { | |
.CR = { | |
.CTSEN = 1 << 15, | |
.RTSEN = 1 << 14, | |
.RTS = 1 << 11, | |
.DTR = 1 << 10, | |
.RXE = 1 << 9, | |
.TXE = 1 << 8, | |
.LBE = 1 << 7, | |
.SIRLP = 1 << 2, | |
.SIREN = 1 << 1, | |
.UARTEN = 1 << 0, | |
} | |
}; | |
*UART_CR = u.CR.UARTEN | u.CR.TXE | u.CR.RXE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment