
헤더/Include
#include "main.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
- main.h - CubeMXX가 생성한 핀/핸들/프로토타입 포함 헤더파일
- stdio.h - snprintf
- string.h - strlen, strcmp. strncmp
- stdlib.h - atoi
전역변수(PV 영역)
static uint8_t rx_xh;
static char cli_buf[64];
static uint32_t cli_len;
static volatile uint8_t cli_line_ready;
static uint8_t stream_on;
static uint32_t stream_period_ms;
static uint32_t last_stream_ms;
- rx_xh : UART로 들어오는 1byte 수신 버퍼
- cli_buf : 한 줄 명령을 저장하는 버퍼
- cli_len : 현재까지 입력된 글자 수
- cli_line_ready : 엔터를 쳐서 한 줄이 완성되었는지 표시하는 플래그
- volatile인 이유 : 인터럽트(콜백)에서 바뀌고 메인루프에서 읽기 때문
- stream_on / stream_period_ms / last_stream_ms : 주기 출력(스트리밍) 제어
ADC 읽기 함수 read_vref_raw()
HAL_ADC_Start();
HAL_ADC_PollForConversion();
v = HAL_ADC_GetValue();
HAL_ADC_Stop();
- VREFINT 채널을 한 번 변환해서 RAW 값을 가져옴