Exemplo n.º 1
0
// define for what the timer should be used right now
void timer_set_mode(int mode)
{
	// I guess we should stop the timer first... (FPB)
//	and_b(~0x10, &TSTR);

    TCNT4 = 0; // start counting at 0
    gTimer.mode = mode; // store the mode

    if (mode == TM_RX_TIMEOUT)
    {
        GRA4 = gTimer.gra_timeout;
        TCR4 = 0x00; // no clear at GRA match, sysclock/1
        IPRD = (IPRD & 0xFF0F) | 0x00B0; // interrupt priority 11
        or_b(0x10, &TSTR); // start timer 4
    }
    else if (mode == TM_TRANSMIT)
    {
        GRA4 = gTimer.gra_transmit;
        TCR4 = 0x20; // clear at GRA match, sysclock/1
        //IPRD = (IPRD & 0xFF0F) | 0x0020; // interrupt priority 14
        IPRD = (IPRD & 0xFF0F) | 0x00F0; // interrupt priority 14
        or_b(0x10, &TSTR); // start timer 4
    }
    else
    {
        and_b(~0x10, &TSTR); // stop the timer 4
        IPRD = (IPRD & 0xFF0F); // disable interrupt
    }
}
void ide_power_enable(bool on)
{
    bool touched = false;

    if(on)
    {
        or_b(0x10, &PBDRL);
        touched = true;
    }
#ifdef HAVE_ATA_POWER_OFF
    if(!on)
    {
        and_b(~0x10, &PBDRL);
        touched = true;
    }
#endif /* HAVE_ATA_POWER_OFF */

/* late port preparation, else problems with read/modify/write 
   of other bits on same port, while input and floating high */
    if (touched)
    {
        or_b(0x10, &PBIORL); /* PB4 is an output */
        PBCR2 &= ~0x0300; /* GPIO for PB4 */
    }
}
void power_off(void)
{
    disable_irq();
    and_b(~0x08, &PADRH);
    or_b(0x08, &PAIORH);
    while(1);
}
Exemplo n.º 4
0
void usb_enable(bool on)
{
    if(on)
        and_b(~0x04, &PADRH);
    else
        or_b(0x04, &PADRH);
}
Exemplo n.º 5
0
static void deselect_card(void)
{
    while (!(SSR1 & SCI_TEND));   /* wait for end of transfer */
    or_b(0x06, &PADRH);           /* deassert CS (both cards) */

    led(false);
    mutex_unlock(&mmc_mutex);
    last_disk_activity = current_tick;
}
Exemplo n.º 6
0
void mmc_enable_int_flash_clock(bool on)
{
    /* Internal flash clock is enabled by setting PA12 high with the new
     * clock circuit, and by setting it low with the old clock circuit */
    if (on ^ new_mmc_circuit)
        and_b(~0x10, &PADRH);     /* clear clock gate PA12 */
    else
        or_b(0x10, &PADRH);       /* set clock gate PA12 */
}
Exemplo n.º 7
0
void usb_enable(bool on)
{
    if(HW_MASK & USB_ACTIVE_HIGH)
        on = !on;

    if(on)
        and_b(~0x04, &PADRH); /* enable USB */
    else
        or_b(0x04, &PADRH);
}
Exemplo n.º 8
0
void usb_init_device(void)
{
    or_b(0x04, &PADRH);
    or_b(0x04, &PAIORH);
}
Exemplo n.º 9
0
void usb_init_device(void)
{
    usb_enable(false);
    or_b(0x04, &PAIORH);
}
Exemplo n.º 10
0
// 2nd level ISR for I-Bus transmission
void transmit_isr(void)
{
    bool exit = false;
    TSR4 &= ~0x01; // clear the interrupt

    switch(gSendIRQ.step++)
    {	
	case -3:
		// We are at the beggining of transmission
		// we need to make sure the line is free for 1.5 bits long
		and_b(~TXMASK, &PBIORH); // float PB10/PB11 (input);
/*	case -8:
	case -7:
	case -6:
	case -5:
	case -4:
	case -3:
*/	case -2:
	case -1:
        if ((PBDR & PB10) == 0)
            gSendIRQ.collision = true;
		break;

 	case 0:
		// we are at the beggining of a new bit
		// Let's see what we need to send

		if(gSendIRQ.bitmask == 0x001) {
			// we need to send a startbit = 0
			gSendIRQ.bit = false;
		}

		else if(gSendIRQ.bitmask == 0x200 ) {
			// we need to send the parity bit
			if(gSendIRQ.parity) gSendIRQ.bit = compute_even(gSendIRQ.byte);
			else // we don't need to send a parity bit after all...
				gSendIRQ.bitmask <<= 1; // Let's shift to the stopbit instead
		}

		if(gSendIRQ.bitmask == 0x400) {
			// stopbit is always one ('high')
			gSendIRQ.bit = true;
		}

		// This is where we really send the bits...

        if (gSendIRQ.bit) {// sending "one"? 
			and_b(~TXMASK, &PBIORH); // float PB10/PB11 (input);

		}
		else {
			and_b(~TXMASK, &PBDRH); // low on PB10/PB11
			or_b(TXMASK, &PBIORH); // drive PB10/PB11 low (output)
		}
       break;
//  case 1: 
// 	case 2:
//  case 3: 
//	case 4:
//	case 5:
//	case 6:
//	case 7:
//	case 8:
//          if (gSendIRQ.bit && ((PBDR & PB10) == 0))
//              gSendIRQ.collision = true;
//  		break;
	default:
        if (gSendIRQ.bit && ((PBDR & PB10) == 0))
            gSendIRQ.collision = true;

          // prepare next round
        gSendIRQ.step = 0;

		gSendIRQ.bitmask <<= 1;

		if (gSendIRQ.bitmask > 0x001 && gSendIRQ.bitmask < 0x200)
		{   // new bit of the current byte
			gSendIRQ.bit = (gSendIRQ.byte & (gSendIRQ.bitmask>>1));
		}
		else if(gSendIRQ.bitmask == 0x800)