Esempio n. 1
0
static inline void IRQ()
{
    Stack_Push_Address(CPU.PC);
    Stack_Push(Status_Read());
    CPU.I = 1;
    CPU.PC = (Memory_CPU_Read(0xFFFF) << 8) | Memory_CPU_Read(0xFFFE);
}
Esempio n. 2
0
File: t1.c Progetto: AE9RB/peaberry
void T1_Main(void) {
    static uint8 state = 0, timer, band, send, bits, band_request, band_request_timer;
    static uint16 tune_timer; 
    
    if (tune_timer) {
        tune_timer--;
        if (!tune_timer) {
            Control_Write(Control_Read() & ~CONTROL_ATU_1);
        }
    }

    if (band_request_timer) band_request_timer--;
    else if (T1_Band_Number != band) {
        band_request = 1;
        band_request_timer = 200;
    }

    switch(state) {
    case 0: // idle
        if (Status_Read() & STATUS_ATU_0) timer++;
        else {
            if (timer >= 85 && timer <= 115) {
                state = 1;
                timer = 20;
                send = band = T1_Band_Number;
                bits = 4;
                Control_Write(Control_Read() & ~CONTROL_ATU_0 | CONTROL_ATU_0_OE);
            }
            else {
                timer = 0;
                if (band_request || T1_Tune_Request) {
                    Control_Write(Control_Read() | CONTROL_ATU_1);
                    if (T1_Tune_Request) tune_timer = 1000;
                    else tune_timer = 10;
                    band_request = T1_Tune_Request = 0;
                }
            }
        }
        break;
    case 1: // data low
        timer--;
        if (!timer) {
            if (bits) {
                Control_Write(Control_Read() | CONTROL_ATU_0);
                if (send & 0x08) timer = 8;
                else timer = 3;
                send <<= 1;
                bits--;
                state = 2;
            } else {
                Control_Write(Control_Read() & ~(CONTROL_ATU_0 | CONTROL_ATU_0_OE));
                state = 0;
            }
        }
        break;
    case 2: // data high
        timer--;
        if (!timer) {
            if (bits) timer = 3;
            else timer = 10;
            Control_Write(Control_Read() & ~CONTROL_ATU_0);
            state = 1;
        }
        break;
    }   

}