====== FILO() ====== ''FILO()''는 나중에 저장한 16비트 데이터를 먼저 출력합니다. {{:commands:reference:filo.svg?900|FILO 명령어 동작 흐름}} ''bool FILO(uint8_t filo_id, bool IN, bool OUT, uint16_t input, uint16_t &output, uint8_t size, bool reset = false)'' ===== 명령어 ===== ^ 명령어 ^ 인수 ^ 반환값 ^ 동작 ^ | ''FILO(filo_id, IN, OUT, input, output, size, reset)'' | ''uint8_t filo_id''\\ ''bool IN'' — 상승 엣지에서 입력 저장\\ ''bool OUT'' — 상승 엣지에서 출력\\ ''uint16_t input'' — 저장할 워드\\ ''uint16_t &output'' — 출력값을 받을 참조 변수\\ ''uint8_t size'' — 버퍼 크기\\ ''bool reset = false'' — 버퍼 초기화 | ''bool'' | 나중에 저장한 16비트 데이터를 먼저 출력합니다. | ===== 예제 ===== 시리얼 모니터에서 ''a''를 보내면 번호를 저장하고, ''p''를 보내면 가장 나중에 저장한 번호를 꺼냅니다. ''c''는 버퍼를 비웁니다. 각 문자를 한 번씩 전송해 동작을 확인할 수 있습니다. uint16_t nextNumber = 0; uint16_t lastNumber = 0; void setup() { Serial.begin(115200); } void loop() { if (!Serial.available()) return; const char action = Serial.read(); const bool store = action == 'a'; const bool retrieve = action == 'p'; const bool clearBuffer = action == 'c'; if (store) ++nextNumber; const bool ok = FILO(0, store, retrieve, nextNumber, lastNumber, 16, clearBuffer); // 번호를 버퍼에 저장하고, 꺼내기 신호가 오면 마지막 번호를 읽습니다. FILO(0, false, false, nextNumber, lastNumber, 16, false); // 다음 문자도 상승 신호로 처리할 수 있도록 입력 신호를 LOW로 되돌립니다. if (retrieve && ok) Serial.println(lastNumber); if (retrieve && !ok) Serial.println(F("Buffer empty")); } ===== 주의사항 ===== ''IN'', ''OUT'', ''CU'', ''CD''는 상승 순간에 동작합니다. 각 카운터·버퍼에 고유한 ''id''를 사용하고 ''size''는 필요한 범위로 작게 설정하십시오. ===== 같은 카테고리의 내장 명령어 ===== * [[commands:reference:fifo|FIFO() 상세 설명 보기]] [[commands:builtin|← 내장 명령어 리스트]]