Exemple #1
0
void waitTX(void)
{
	unsigned char status;
	unsigned char x;
	
	x=1;
	while (x) {
		status = cc1100_strobe(SNOP);
		switch ( 0xf0 & status) {
			case 0x70:
					cc1100_strobe(SFTX);
			case  0x10:
			case  0x00:
				if (RFstatus & WORsend) {
					switch_to_idle();
				}
				else if (RFstatus & WORenabled)
					cc1100_strobe(SWOR);
				else if (RFstatus & WORrxon)
					cc1100_strobe(SRX);
				else if (RFstatus & RXenabled)
					cc1100_strobe(SRX);
				else {
					switch_to_idle();
				}					
				x=0;
				break;
		}	
	}
}
Exemple #2
0
INLINE void ipc_switch_to_idle(tcb_t * current)
{
#if defined(CONFIG_DEBUG_TRACE_MISC)
    //printf("ipc_switch_to_idle: curr: %x\n", current);
#endif
    switch_to_idle(current);
}
Exemple #3
0
void RF_sendWOR(unsigned char addr) {

	unsigned char b[2];
	unsigned int WOR_cb;
	
	b[0]=0x01;
	b[1]=addr;
	
	VICIntEnClr = INT_EINT0;
	switch_to_idle();
	RFstatus |= WORsend;
	cc1100_write1(0x18,conf[0x18] & 0xCF);
	
	cc1100_strobe(SCAL);
	waitTX();
	WOR_cb = addTimerCB(WORsend_timeout, 101);
	startCB(WOR_cb);
	
	while (RFstatus & WORsend) {
		cc1100_write(TX_fifo | BURST,b,2);
		cc1100_strobe(STX);
		waitTX();
	}
	
	stopCB(WOR_cb);
	removeTimerCB(WOR_cb);
	
	cc1100_write1(0x18,conf[0x18]);
	waitTX();
	VICIntEnable = INT_EINT0;	
}
Exemple #4
0
void cc1100IRQ (void) {
		
	if (cc1100_read1(0x3B | READ | BURST) > 0) {
		RF_getfifo(RFbuf);
		cc1100_strobe(SIDLE);
		cc1100_strobe(SFRX);
				
		struct cc1100frame_ *RXframe;
		RXframe = (struct cc1100frame_ *)&RFbuf[0];
		
		if ((RXframe->len == 1) && ((RXframe->destAddr == cc1100Addr)  || (RXframe->destAddr == 0x00))) {
			switch_WOR_RX();
		}
		
		if(RFstatus & WORenabled)
			cc1100_strobe(SWOR);
		else
			cc1100_strobe(SRX);
			
		if (RXframe->len > 3) {
			setCBIntervall(WORrx_cb,WORrx_time);
			switch ( RXframe->packetType) {
				case 0x01:
					draw_block(0,50,128,10,3,DRAW_ERASE);
					draw_string(0, 50, (char*)&RFbuf[headerLen], 3, DRAW_PUT);
				break;
				case 0x02:
					if (RXframe->data[0] == 0x01) {
						RXframe->destAddr = RXframe->srcAddr;
						RXframe->srcAddr = cc1100Addr;
						RXframe->data[0] = 0x02;
						RXframe->len = 0x04;
						switch_to_idle();
						RF_send(RFbuf);
					}
					else if (RFbuf[headerLen] == 0x02) {
						RFstatus |= Received;
					}
				break;
				case 0x03:
					if ((RXframe->data[0] == 0x01) && (timeInfo & time_accurate)) {
						send_time(RXframe->srcAddr);
					}
					else if (RFbuf[headerLen] == 0x02) {
						memcpy((unsigned char *)&time,(unsigned char *)&RXframe->data[1],3);
						memcpy((unsigned char *)&date,(unsigned char *)&RXframe->data[4],4);
						timeInfo |=0x02;
						VICSoftInt = INT_EINT2;
					}
			}
		}
	}
	
	waitTX();
	EXTINT = 0x01;
}
Exemple #5
0
/*TODO: move into guest-vcpu module */
static void enter_guest_mode(uint16_t pcpu_id)
{
	vmx_on();

	(void)launch_vms(pcpu_id);

	switch_to_idle(default_idle);

	/* Control should not come here */
	cpu_dead();
}
Exemple #6
0
void RF_send(unsigned char* b) {
	
	VICIntEnClr = INT_EINT0;
	if(RFstatus & WORenabled) {
		switch_to_idle();
	}
	cc1100_write(TX_fifo | BURST,b,b[0]+1);
	cc1100_strobe(STX);
	waitTX();
	VICIntEnable = INT_EINT0;
}
Exemple #7
0
dword_t smp_start_receive_ipc(tcb_t * from_tcb, tcb_t * current)
{
    cpu_mailbox_t * mailbox = get_mailbox();
    mailbox->tcb = from_tcb;
    mailbox->param[0] = (dword_t)current;
    dword_t status = mailbox->send_command(from_tcb->cpu, SMP_CMD_IPC_RECEIVE);

    if (status == MAILBOX_ERROR) {
	//enter_kdebug("smp_start_receive_ipc failed");
	return 0;
    }

    switch_to_idle(current);
    
    return 1;
}
Exemple #8
0
void dispatch_thread(tcb_t * tcb)
{
    tcb_t * current = get_current_tcb();

    if (tcb == current)
	return;

    if (tcb == get_idle_tcb()) {
	printf("dispatch: switch to idle, current=%x, state=%x\n", 
	       current, current->thread_state);
	enter_kdebug("dispatch: switch to idle");
	switch_to_idle(current);
	return;
    }

    //printf("dispatch: %p -> %p\n", current, tcb);
    /* Do not insert TCBS not in the ready queue into the prio_queue */
    if (tcb->queue_state & TS_QUEUE_READY)
	prio_queue[tcb->priority] = tcb;

    //printf("switch_to %x->%x (%x)\n", current, tcb, tcb->thread_state);
    switch_to_thread(tcb, current);
}
Exemple #9
0
/** 
 *  @brief Idle state switcher helper.
 *
 *  Called if the program has to close after an unexpected error occured.
 */
void switch_to_idle_state() {
    switch_to_idle(chanData);
}