void put_char(unsigned char ch) { _DBC(ch); }
void _ttywrch(int c) { //sendchar(c); _DBC(c); }
/*********************************************************************//** * @brief c_entry: Main program body * @param[in] None * @return int **********************************************************************/ int c_entry(void) { PINSEL_CFG_Type PinCfg; uint8_t idx,i; /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); //print menu screen print_menu(); /* I2C block ------------------------------------------------------------------- */ /* * Init I2C pin connect */ PinCfg.OpenDrain = 0; PinCfg.Pinmode = 0; PinCfg.Funcnum = 1; PinCfg.Pinnum = 27; PinCfg.Portnum = 0; PINSEL_ConfigPin(&PinCfg);//SDA0 PinCfg.Pinnum = 28; PINSEL_ConfigPin(&PinCfg);//SCL0 // Initialize I2C peripheral I2C_Init(I2CDEV, 100000); /* Configure interrupt for I2C in NVIC of ARM core */ /* Disable I2C0 interrupt */ NVIC_DisableIRQ(I2C0_IRQn); /* preemption = 1, sub-priority = 0 */ NVIC_SetPriority(I2C0_IRQn, ((0x01<<3)|0x01)); //enable I2C interrupt I2C_IntCmd(LPC_I2C0, ENABLE); /* Enable I2C operation */ I2C_Cmd(I2CDEV, ENABLE); while(1) { idx=0;count=0; while(idx<2) { if(idx==0) { _DBG_("\n\rEnter monitor buffer size: "); } idx++; switch(_DG) { case '0': count=(count<<4)|0x00;break; case '1': count=(count<<4)|0x01;break; case '2': count=(count<<4)|0x02;break; case '3': count=(count<<4)|0x03;break; case '4': count=(count<<4)|0x04;break; case '5': count=(count<<4)|0x05;break; case '6': count=(count<<4)|0x06;break; case '7': count=(count<<4)|0x07;break; case '8': count=(count<<4)|0x08;break; case '9': count=(count<<4)|0x09;break; case 'a': count=(count<<4)|0x0A;break; case 'A': count=(count<<4)|0x0A;break; case 'b': count=(count<<4)|0x0B;break; case 'B': count=(count<<4)|0x0B;break; case 'c': count=(count<<4)|0x0C;break; case 'C': count=(count<<4)|0x0C;break; case 'd': count=(count<<4)|0x0D;break; case 'D': count=(count<<4)|0x0D;break; case 'e': count=(count<<4)|0x0E;break; case 'E': count=(count<<4)|0x0E;break; case 'f': count=(count<<4)|0x0F;break; case 'F': count=(count<<4)|0x0F;break; default: idx=0;count=0;break; } if(idx==2) { if(count>BUFFER_SIZE) { _DBG_("invalid! The size is bigger than ");_DBH(BUFFER_SIZE); idx=0;count=0; } else _DBH(count); } } //Configure I2C in monitor mode I2C_MonitorModeConfig(I2CDEV,(uint32_t)I2C_MONITOR_CFG_MATCHALL, ENABLE); I2C_MonitorModeCmd(I2CDEV, ENABLE); _DBG_("\n\rStart monitoring I2C bus..."); while(done==FALSE); done=FALSE; _DBG_("done!"); for(i=0;i<count;i++) { if((i%16)==0) _DBG_(""); _DBH(buffer[i]);_DBC(0x20); buffer[i]=0; } } return 1; }
int fputc(int c, FILE *f) { //return (sendchar(c)); _DBC(c); return 1; }