일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- YMODEM
- 홈어시스턴트
- homeassistant
- thread
- everon
- 에버온
- AWS
- IOT Core
- lambda
- 안드로이드
- esp8266
- 파이썬
- Android
- 전기차충전
- flask
- 디자인패턴
- 완속충전기
- 펌웨어
- STM32
- dynamodb
- 전기차
- 충전기
- 서버리스
- 급속충전기
- 보안
- 라즈베리파이
- OCPP
- raspberry
- 플라스크
- 전기차충전기
Archives
- Today
- Total
Louie NRT Story
[Firmware] M058 - gpio_output/input 본문
반응형
[설명]
- P3.2의 pin에 switch를 연결하고 P0.3에 LED를 연결함
- switch를 On/Off에 따라 LED가 켜지고 꺼짐
[기본코드]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <stdio.h>
#include "M051Series.h"
#define PLL_CLOCK 50000000
void SYS_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Enable Internal RC 22.1184MHz clock */
CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk);
/* Waiting for Internal RC clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk);
/* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1));
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK);
/* Enable UART module clock */
CLK_EnableModuleClock(UART0_MODULE);
/* Select UART module clock source */
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_PLL, CLK_CLKDIV_UART(1));
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set P3 multi-function pins for UART0 RXD and TXD */
SYS->P3_MFP &= ~(SYS_MFP_P30_Msk | SYS_MFP_P31_Msk);
SYS->P3_MFP |= (SYS_MFP_P30_RXD;
}
int main(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Init System, peripheral clock and multi-function I/O */
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
/* Init UART0 for printf */
UART0_Init();
GPIO_SetMode(P0, BIT3, GPIO_PMD_OUTPUT); //Water LED
P03 = 0;
GPIO_SetMode(P3, BIT2, GPIO_PMD_INPUT); //Timer Switch
while(1)
{
if(P32 != 1)
{
P03 = 1;
}
else
{
P03 = 0;
}
}
}
|
반응형
'스마트홈' 카테고리의 다른 글
[Firmware] M058 - PWM (0) | 2019.05.03 |
---|---|
[Firmware] M058 - gpio_timer_delay (0) | 2019.05.03 |
[인공지능] Recurrent Neural Network (0) | 2017.12.04 |
[인공지능] Convolutional Neural Network (0) | 2017.12.04 |
[python] py파일 exe 실행 파일 만들기 (0) | 2017.11.08 |
Comments