//! Character-plot for objects. void obj_drawg(uint gid) { // PONDER: no obj for ' ' ? TTC *tc= tte_get_context(); TFont *font= tc->font; uint x0= tc->cursorX, y0= tc->cursorY; uint id= tc->dst.pitch; OBJ_ATTR *obj= &((OBJ_ATTR*)tc->dst.data)[-id]; tc->dst.pitch= (id+1 < tc->dst.width ? id+1 : 0); obj->attr0= tc->cattr[0] | BFN_PREP(y0, ATTR0_Y); obj->attr1= tc->cattr[1] | BFN_PREP(x0, ATTR1_X); obj->attr2= tc->cattr[2] + gid*font->cellW*font->cellH/64; }
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) { uint16_t i; // Find first free message object if(handle == 0) { uint32_t msgval = LPC_CAN->MSGV1 | (LPC_CAN->MSGV2 << 16); // Find first free messagebox for(i = 0; i < 32; i++) { if((msgval & (1 << i)) == 0) { handle = i+1; break; } } } if(handle > 0 && handle < 32) { if(format == CANExtended) { // Mark message valid, Direction = TX, Extended Frame, Set Identifier and mask everything LPC_CAN->IF1_ARB1 = BFN_PREP(id, CANIFn_ARB1_ID); LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | BFN_PREP(id >> 16, CANIFn_ARB2_ID); LPC_CAN->IF1_MSK1 = BFN_PREP(mask, CANIFn_MSK1_MSK); LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD | CANIFn_MSK2_MDIR | BFN_PREP(mask >> 16, CANIFn_MSK2_MSK); } else {
break; } } } if(handle > 0 && handle < 32) { if(format == CANExtended) { // Mark message valid, Direction = TX, Extended Frame, Set Identifier and mask everything LPC_CAN->IF1_ARB1 = BFN_PREP(id, CANIFn_ARB1_ID); LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | BFN_PREP(id >> 16, CANIFn_ARB2_ID); LPC_CAN->IF1_MSK1 = BFN_PREP(mask, CANIFn_MSK1_MSK); LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD | CANIFn_MSK2_MDIR | BFN_PREP(mask >> 16, CANIFn_MSK2_MSK); } else { // Mark message valid, Direction = TX, Set Identifier and mask everything LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | BFN_PREP(id << 2, CANIFn_ARB2_ID); LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MDIR | BFN_PREP(mask << 2, CANIFn_MSK2_MSK); } // Use mask, single message object and set DLC LPC_CAN->IF1_MCTRL = CANIFn_MCTRL_UMASK | CANIFn_MCTRL_EOB | CANIFn_MCTRL_RXIE | BFN_PREP(DLC_MAX, CANIFn_MCTRL_DLC); // Transfer all fields to message object LPC_CAN->IF1_CMDMSK = CANIFn_CMDMSK_WR | CANIFn_CMDMSK_MASK | CANIFn_CMDMSK_ARB | CANIFn_CMDMSK_CTRL; // Start Transfer to given message number LPC_CAN->IF1_CMDREQ = BFN_PREP(handle, CANIFn_CMDREQ_MN); // Wait until transfer to message ram complete - TODO: maybe not block?? while( LPC_CAN->IF1_CMDREQ & CANIFn_CMDREQ_BUSY ); }