void loop() { IrRecv* irRecv = ir_rx_recv(); if(irRecv != NULL) { IrCode* code = ir_code_decode(irRecv->buffer, irRecv->bufferLength); debug_write("?rx: "); if(code != NULL) { debug_write_u16(code->brand, 16); debug_write_u16(code->key, 16); } else { debug_write("("); debug_write_u16(irRecv->bufferLength, 10); debug_write("): "); for(int i = 0; i < irRecv->bufferLength; i++) { debug_write_u16(irRecv->buffer[i], 10); debug_write(","); } } debug_write_line(""); } }
void em4x05_read(uint8_t addr) { debug_write("?BEGIN em4x05_read: 0x"); debug_write_u16(addr, 16); debug_write_line(""); debug_led_set(1); delay_ms(1); eeworkbench_begin_tx(); delay_us(US_PER_RF_TICK * 5); _em4x05_tx_first_stop(); _em4x05_tx(0); _em4x05_tx_command(COMMAND_READ); _em4x05_tx_addr(addr); debug_led_set(0); debug_write_line("?END em4x05_read"); }
int main( void ) { uint8_t d = 0x34,rxbuf = 0X23; mInit(); // I2C_config(); SPI_config(); debug_setup(); ADC_A_config(); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //M4 DIRECTION GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //M3 DIRECTION GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStructure); TIMA_config(100, 20,10); // timer1 channel 1 PA8 TIMB_config(100, 20,10); // timer2 channel 3 PA9 TIMC_config(100, 20,10); // timer15 channel 1 PB14 TIMD_config(100, 20,10); // timer2 channel 2 PA1 // first 2 numbers // // in this function are not doing anything while(1) { GPIO_ResetBits(GPIOA, GPIO_Pin_0); GPIO_ResetBits(GPIOB, GPIO_Pin_15); // debug_write_ch(0XAB); mBlueTOGGLE; mGreenTOGGLE; mRedTOGGLE; mWaitms(300); GPIO_SetBits(GPIOA, GPIO_Pin_0); GPIO_SetBits(GPIOB, GPIO_Pin_15); /* Test EOC flag */ while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); /* Get ADC1 converted data */ ADC1ConvertedValue =ADC_GetConversionValue(ADC1); debug_write_u16(ADC1ConvertedValue,10); debug_write_line(" "); // mWaitms(300); // I2C_write_1byte(SLAVE_ADDR2,254,22); // rxbuf = I2C_read_1byte(SLAVE_ADDR,254); // debug_write_ch(rxbuf); // rxbuf = I2C_read_1byte(SLAVE_ADDR1,254); // debug_write_ch(rxbuf); // rxbuf = I2C_read_1byte(SLAVE_ADDR2,254); // debug_write_ch(rxbuf); // TIM_SetCompare2 ( TIM2,1); // mWaitms(300); // TIM_SetCompare2 ( TIM2,0); // mWaitms(1000); // SPI_SendData8(SPI1, d); // while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); // while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); // rxbuf = SPI_ReceiveData8(SPI1); } }
PROCESS_THREAD(debug_process, ev, data) { char line[MAX_LINE_LENGTH]; uint16_t read; uint8_t b; uint32_t flashAddress = 0; uint32_t flashCount = 0; uint32_t t = 0; PROCESS_BEGIN(); while (1) { PROCESS_YIELD(); while (dma_ring_buffer_readline(&g_debugUsartDmaInputRingBuffer, line, MAX_LINE_LENGTH)) { if (strcmp(line, "!CONNECT\n") == 0) { debug_write_line("+OK"); debug_write_line("!clear"); debug_write_line("!set name,dc-electronic-load"); debug_write_line("!set description,'DC Electonic Load'"); } else if (strcmp(line, "!RESET\n") == 0) { debug_write_line("+OK"); NVIC_SystemReset(); } #ifdef ADC_ENABLE else if (strcmp(line, "!ADCLAST\n") == 0) { debug_write("+OK "); debug_write_u16(lastAdcValue[0], 10); debug_write(","); debug_write_u16(lastAdcValue[1], 10); debug_write(","); debug_write_u16(lastAdcValue[2], 10); debug_write(","); debug_write_u16(lastAdcValue[3], 10); debug_write(","); debug_write_u16(setCurrentMilliamps, 10); debug_write_line(""); } else if (strcmp(line, "!ADCRAW\n") == 0) { debug_write("+OK "); debug_write_u16(adc_sample(ADC_CH0_SINGLE), 10); debug_write(","); debug_write_u16(adc_sample(ADC_CH1_SINGLE), 10); debug_write(","); debug_write_u16(adc_sample(ADC_CH2_SINGLE), 10); debug_write(","); debug_write_u16(adc_sample(ADC_CH3_SINGLE), 10); debug_write_line(""); } #endif #ifdef FAN_ENABLE else if (strncmp(line, "!FANSET ", 8) == 0) { uint8_t fanSetOverride = atoi(line + 8); fan_set(fanSetOverride); debug_write_line("+OK"); } else if (strcmp(line, "!FANGET\n") == 0) { debug_write("+OK "); debug_write_u8(fan_get(), 10); debug_write_line(""); } #endif #ifdef DISP6800_ENABLE else if (strcmp(line, "!DISPON\n") == 0) { disp6800_set_display_onoff(DISP6800_DISPLAY_ON); debug_write_line("+OK"); } else if (strcmp(line, "!DISPOFF\n") == 0) { disp6800_set_display_onoff(DISP6800_DISPLAY_OFF); debug_write_line("+OK"); } #endif #ifdef FLASH_ENABLE else if (strcmp(line, "!FLASHCLEAR\n") == 0) { flashsst25_erase_chip(); debug_write_line("+OK"); } else if (strncmp(line, "!FLASHWRITE ", 12) == 0) { flashAddress = atoi(line + 12); flashCount = FLASH_BLOCK_SIZE; debug_write_line("+READY"); t = time_ms(); while (1) { if (flashCount <= 0) { debug_write("+OK "); debug_write_u32(flashAddress, 10); debug_write_line(""); break; } if ((time_ms() - t) > 5000) { debug_write_line("-FAIL"); break; } if ((read = dma_ring_buffer_read(&g_debugUsartDmaInputRingBuffer, (uint8_t*)line, MIN(flashCount, sizeof(line)))) <= 0) { continue; } flashsst25_write(flashAddress, (uint8_t*)line, read); flashAddress += read; flashCount -= read; t = time_ms(); } } else if (strncmp(line, "!FLASHREAD ", 11) == 0) { flashAddress = atoi(line + 11); flashCount = FLASH_BLOCK_SIZE; debug_write_line("+OK"); flashsst25_read_begin(flashAddress); while (flashCount > 0) { b = flashsst25_read(); debug_write_bytes(&b, 1); flashCount--; } flashsst25_read_end(); } #endif else { debug_write("?Unknown command: "); debug_write_line(line); } } } PROCESS_END(); }