* Hal lfrfid: add read timer pulse and period config fns * New debug application for lfrfid subsystem * New lfrfid: app, fix naming * App lfrfid: assets * Container view module * App ibutton: remove unused header * App lfrfid scenes * App notification, add yield to blocking operations, add speaker volume control * App lfrfid: reading key scene * Assets: placeholder icon * App lfrfid: reworked container view module * App lfrfid: new scenes * App lfrfid: write scene * App lfrfid: write hid * App lfrfid: emulate scene * App lfrfid: save name scene * App lfrfid: add missing file
		
			
				
	
	
		
			35 lines
		
	
	
		
			966 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			966 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include "manchester-decoder.h"
 | 
						|
#include <stdint.h>
 | 
						|
 | 
						|
static const uint8_t transitions[] = {0b00000001, 0b10010001, 0b10011011, 0b11111011};
 | 
						|
static const ManchesterState manchester_reset_state = ManchesterStateMid1;
 | 
						|
 | 
						|
bool manchester_advance(
 | 
						|
    ManchesterState state,
 | 
						|
    ManchesterEvent event,
 | 
						|
    ManchesterState* next_state,
 | 
						|
    bool* data) {
 | 
						|
    bool result = false;
 | 
						|
    ManchesterState new_state;
 | 
						|
 | 
						|
    if(event == ManchesterEventReset) {
 | 
						|
        new_state = manchester_reset_state;
 | 
						|
    } else {
 | 
						|
        new_state = transitions[state] >> event & 0x3;
 | 
						|
        if(new_state == state) {
 | 
						|
            new_state = manchester_reset_state;
 | 
						|
        } else {
 | 
						|
            if(new_state == ManchesterStateMid0) {
 | 
						|
                *data = false;
 | 
						|
                result = true;
 | 
						|
            } else if(new_state == ManchesterStateMid1) {
 | 
						|
                *data = true;
 | 
						|
                result = true;
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    *next_state = new_state;
 | 
						|
    return result;
 | 
						|
}
 |