int main(int argc, char *argv[]) { //uint8_t buf[32]; //int i = 0; hal_disable_ints(); // In case we got here via jmp 0x0 // delay(10000000); //before anything else you might want to blinkenlights just to indicate code startup to the user. hal_uart_init(); spif_init(); // i2c_init(); //for EEPROM puts("USRP2+ UART firmware loader"); // puts("Debug: loading production image, 10 bytes."); // spi_flash_read(PROD_FW_IMAGE_LOCATION_ADDR, 10, buf); // for(i=0; i < 10; i++) { // puthex8(buf[i]); // } uart_flash_loader(); //shouldn't get here. should reboot. puts("shit happened.\n"); return 0; }
void uart_init(void){ debug("uart: init\n"); debug_flush(); uart_rx_callback = 0; hal_uart_init(); }
void main(void) { // Configure TXD pin as output. // P0.5, P0.3 and P1.0 are configured as outputs to make the example run on // either 24-pin, 32-pin or 48-pin nRF24LE1 variants. P0DIR = 0xD7; P1DIR = 0xFE; // Initializes the UART hal_uart_init(UART_BAUD_9K6); // Wait for XOSC to start to ensure proper UART baudrate while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M) {} // Enable global interrupts EA = 1; // Print "Hello World" at start-up putstring("\r\nHello World!\r\n"); for(;;) { // If any characters received if( hal_uart_chars_available() ) { P3 = 0x11; // Echo received characters putchar(getchar()); } } }
static void gprs_uart_init(void) { hal_uart_init(HAL_UART_4, 115200, 0); #if 0 serial_reg_t gprs_serial_reg; gprs_serial_reg.sd.valid = FALSE; // 起始域是否有效 gprs_serial_reg.sd.len = 2; // 起始域的长度 gprs_serial_reg.sd.pos = 0; // 起始域的偏移 gprs_serial_reg.sd.data[0] = 'A'; // 起始域的值 gprs_serial_reg.sd.data[1] = 'T'; gprs_serial_reg.ld.valid = TRUE; // 长度域是否有效 gprs_serial_reg.argu.len_max = GPRS_SERIAL_LEN_MAX; // 整条帧的长度限制 gprs_serial_reg.argu.len_min = GPRS_SERIAL_LEN_MIN; gprs_serial_reg.ed.valid = FALSE; // 结尾域是否存在 gprs_serial_reg.ed.len = 1; gprs_serial_reg.ed.data[0] = 0x0D; // 'CR', enter gprs_serial_reg.echo_en = FALSE; // 回显 // 不需要回调函数,定时器时间,判断是否收到数据 gprs_serial_reg.func_ptr = NULL; serial_fsm_init(SERIAL_4); // 初始化serial serial_reg(SERIAL_4, gprs_serial_reg); // 注册serial #endif }
/* Sysytem initilize */ void mxchipWNet_HA_init(void) { network_InitTypeDef_st wNetConfig; network_InitTypeDef_adv_st wNetConfigAdv; int err = MXCHIP_FAILED; net_para_st para; device_info = (mxchipWNet_HA_st *)malloc(sizeof(mxchipWNet_HA_st)); memset(device_info, 0, sizeof(mxchipWNet_HA_st)); SystemCoreClockUpdate(); mxchipInit(); hal_uart_init(); getNetPara(¶, Station); formatMACAddr((void *)device_info->status.mac, ¶.mac); strcpy((char *)device_info->status.ip, (char *)¶.ip); strcpy((char *)device_info->status.mask, (char *)¶.mask); strcpy((char *)device_info->status.gw, (char *)¶.gate); strcpy((char *)device_info->status.dns, (char *)¶.dns); readConfiguration(device_info); device_info->tcpServer_fd = -1; device_info->tcpClient_fd = (int *)malloc(4 * MAX_CLIENT); device_info->cloud_fd = -1; device_info->udpSearch_fd = -1; memset(device_info->tcpClient_fd, -1, sizeof(4 * MAX_CLIENT)); if(device_info->conf.fastLinkConf.availableRecord){ //Try fast link memcpy(&wNetConfigAdv.ap_info, &device_info->conf.fastLinkConf.ap_info, sizeof(ApList_adv_t)); memcpy(&wNetConfigAdv.key, &device_info->conf.fastLinkConf.key, device_info->conf.fastLinkConf.key_len); wNetConfigAdv.key_len = device_info->conf.fastLinkConf.key_len; wNetConfigAdv.dhcpMode = DHCP_Client; strcpy(wNetConfigAdv.local_ip_addr, (char*)device_info->conf.ip); strcpy(wNetConfigAdv.net_mask, (char*)device_info->conf.mask); strcpy(wNetConfigAdv.gateway_ip_addr, (char*)device_info->conf.gw); strcpy(wNetConfigAdv.dnsServer_ip_addr, (char*)device_info->conf.dns); wNetConfigAdv.wifi_retry_interval = 100; err = StartAdvNetwork(&wNetConfigAdv); } if(err == MXCHIP_FAILED){ wNetConfig.wifi_mode = Station; strcpy(wNetConfig.wifi_ssid, device_info->conf.sta_ssid); strcpy(wNetConfig.wifi_key, device_info->conf.sta_key); wNetConfig.dhcpMode = DHCP_Client; strcpy(wNetConfig.local_ip_addr, (char*)device_info->conf.ip); strcpy(wNetConfig.net_mask, (char*)device_info->conf.mask); strcpy(wNetConfig.gateway_ip_addr, (char*)device_info->conf.gw); strcpy(wNetConfig.dnsServer_ip_addr, (char*)device_info->conf.dns); wNetConfig.wifi_retry_interval = 500; StartNetwork(&wNetConfig); } ps_enable(); }
void hal_uart_init_send(char *p_msg) { bool previous_ea; previous_ea = ARE_INTERRUPTS_ENABLED(); DISABLE_INTERRUPTS(); hal_uart_init(); hal_uart_send_msg(p_msg); if (previous_ea) { ENABLE_INTERRUPTS(); } }
static void stduart_init(void) { uart_0.port = STDIO_UART; uart_0.config.baud_rate = 115200; uart_0.config.data_width = DATA_WIDTH_8BIT; uart_0.config.flow_control = FLOW_CONTROL_DISABLED; uart_0.config.mode = MODE_TX_RX; uart_0.config.parity = NO_PARITY; uart_0.config.stop_bits = STOP_BITS_1; hal_uart_init(&uart_0); }
static be_jse_symbol_t * uart_open(void){ int32_t len = -1; char * data = NULL; int8_t ret = -1; int8_t result = -1; item_handle_t uart_handle; uart_handle.handle = 0xFFFFFFFF; be_jse_symbol_t * arg0 = NULL; uart_dev_t * uart_device = NULL; be_jse_handle_function(0,&arg0,NULL,NULL,NULL); if(!arg0 || !symbol_is_string(arg0)){ goto out; } len = symbol_str_len(arg0); data = calloc(1,sizeof(char)*(len+1)); if(NULL==data){ goto out; } symbol_to_str(arg0,data,len); ret = board_attach_item(MODULE_UART,data,&uart_handle); if(0 != ret){ be_error("uart","board_attach_item fail!\n"); goto out; } be_debug("uart","uart handle:%u\n",uart_handle.handle); uart_device = board_get_node_by_handle(MODULE_UART,&uart_handle); if(NULL == uart_device){ be_error("uart","board_get_node_by_handle fail!\n"); goto out; } ret = hal_uart_init(uart_device); if(0 != ret){ be_error("uart","hal_uart_init fail!\n"); goto out; } result = 0; out: if(NULL != data){ free(data); data = NULL; } symbol_unlock(arg0); if(0 != result){ board_disattach_item(MODULE_UART,&uart_handle); return new_int_symbol(-1); } return new_int_symbol(uart_handle.handle); }
/* * We ought to arrange for this to be called before main, but for now, * we require that the user's main call u2_init as the first thing... */ bool u2_init(void) { hal_disable_ints(); hal_io_init(); // init spi, so that we can switch over to the high-speed clock spi_init(); // set up the default clocks clocks_init(); hal_uart_init(); // init i2c so we can read our rev pic_init(); // progammable interrupt controller i2c_init(); hal_enable_ints(); // flash all leds to let us know board is alive hal_set_led_src(0x0, 0x1f); /* software ctrl */ hal_set_leds(0x0, 0x1f); mdelay(300); hal_set_leds(LED_E, LED_E); mdelay(300); hal_set_leds(LED_C, LED_C); mdelay(300); hal_set_leds(LED_A, LED_A); mdelay(300); for (int i = 0; i < 3; i++){ //blink all static const int blinks = LED_E | LED_C | LED_A; hal_set_leds(0x0, 0x1f); mdelay(100); hal_set_leds(blinks, 0x1f); mdelay(100); } hal_set_led_src(0x1f & ~LED_D, 0x1f); /* hardware ctrl */ hal_set_leds(LED_D, 0x1f); // Leave one on #if 0 // test register readback int rr, vv; vv = ad9777_read_reg(0); printf("ad9777 reg[0] = 0x%x\n", vv); for (rr = 0x04; rr <= 0x0d; rr++){ vv = ad9510_read_reg(rr); printf("ad9510 reg[0x%x] = 0x%x\n", rr, vv); } #endif output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN); return true; }
int main(int argc, char *argv[]) { pic_init(); hal_uart_init(); puts("\nStarting delay...\n"); output_regs->leds = 0xFF; delay(4000000); output_regs->leds = 0x00; delay(4000000); puts("Rebooting FPGA to 0x00000000\n"); icap_reload_fpga((uint32_t)0x00000000); return 0; }
//extern hal_wifi_module_t sim_aos_wifi_stm23l475; //extern struct hal_ota_module_s stm32l475_ota_module; void hw_start_hal(void) { //hal_wifi_register_module(&sim_aos_wifi_stm23l475); //hal_ota_register_module(&stm32l475_ota_module); uart_0.port = STDIO_UART; uart_0.config.baud_rate = STDIO_UART_BUADRATE; uart_0.config.data_width = DATA_WIDTH_8BIT; uart_0.config.parity = NO_PARITY; uart_0.config.stop_bits = STOP_BITS_1; uart_0.config.flow_control = FLOW_CONTROL_DISABLED; hal_uart_init(&uart_0); printf("start-----------hal\n"); hal_wifi_register_module(&sim_aos_wifi_mico); hal_wifi_init(); }
int main(int argc, char *argv[]) { uint16_t i, t; uint8_t buf[260]; const uint8_t testdata[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C}; hal_disable_ints(); // In case we got here via jmp 0x0 // spi_init(); hal_uart_init(); // clocks_init(); //set up AD9510, enable FPGA clock @ 1x divisor puts("SPI Flash test\n"); puts("Initializing SPI\n"); spif_init(); delay(800000); puts("Erasing sector 1\n"); spi_flash_erase(0x00010000, 256); delay(800000); puts("Reading back data\n"); spi_flash_read(0x00010000, 256, buf); delay(800000); t=1; for(i=4; i<250; i++) { if(buf[i] != 0xFF) t=0; } if(!t) puts("Data was not initialized to 0xFF. Unsuccessful erase or read\n"); else puts("Data initialized to 0xFF, erase confirmed\n"); puts("Writing test buffer\n"); spi_flash_program(0x00010000, 16, testdata); //memset(buf, 0, 256); delay(800000); puts("Wrote data, reading back\n"); spi_flash_read(0x00010000, 16, buf); if(memcmp(testdata, buf, 16)) puts("Data is not the same between read and write. Unsuccessful write or read\n"); else puts("Successful write! Flash write correct\n"); return 0; }
void main(void) { halMcuInit(); hal_led_init(); hal_uart_init(); //Uart0Init(0, 0); printf("s rssi: d\r\n"); //Uart0Init(unsigned char StopBits,unsigned char Parity) if (FAILED == halRfInit()) { HAL_ASSERT(FALSE); } // Config basicRF basicRfConfig.panId = PAN_ID; basicRfConfig.channel = RF_CHANNEL; basicRfConfig.ackRequest = TRUE; #ifdef SECURITY_CCM basicRfConfig.securityKey = key; #endif // Initialize BasicRF #if NODE_TYPE basicRfConfig.myAddr = SEND_ADDR; #else basicRfConfig.myAddr = RECV_ADDR; #endif if(basicRfInit(&basicRfConfig)==FAILED) { HAL_ASSERT(FALSE); } #if NODE_TYPE //uWaveInit(); dht11_io_init(); rfSendData(); #else rfRecvData(); #endif }
static int at_init_uart() { at_uart_configure(&at_uart); if (hal_uart_init(&at_uart) != 0) { return -1; } #ifdef HDLC_UART if (hdlc_encode_context_init(&hdlc_encode_ctx) != 0 || hdlc_decode_context_init(&hdlc_decode_ctx, &at_uart) != 0) { return -1; } #endif at._pstuart = &at_uart; return 0; }
void hal_uart_init_send_packet(uint8_t *p_msg_to_send) { bool previous_ea; uint8_t byte_idx; previous_ea = ARE_INTERRUPTS_ENABLED(); DISABLE_INTERRUPTS(); hal_uart_init(); for (byte_idx = 0; byte_idx < HAL_UART_PACKET_SIZE; byte_idx++) { TI0 = 0; S0BUF = (uint8_t)(p_msg_to_send[byte_idx]); while (TI0 == 0); } TI0 = 0; RI0 = 0; if (previous_ea) { ENABLE_INTERRUPTS(); } }
void main(void) { halMcuInit(); hal_led_init(); hal_uart_init(); printf("你知道串口是正常的.....\r\n"); if (FAILED == halRfInit()) { HAL_ASSERT(FALSE); } // Config basicRF basicRfConfig.panId = PAN_ID; basicRfConfig.channel = RF_CHANNEL; basicRfConfig.ackRequest = TRUE; #ifdef SECURITY_CCM basicRfConfig.securityKey = key; #endif // Initialize BasicRF #if NODE_TYPE basicRfConfig.myAddr = SEND_ADDR; #else basicRfConfig.myAddr = RECV_ADDR; #endif if(basicRfInit(&basicRfConfig)==FAILED) { HAL_ASSERT(FALSE); } #if NODE_TYPE dht11_io_init(); InitialT1test(); rfSendData(); #else printf("接收数据\r\n"); rfRecvData(); #endif }
int main(int argc, char *argv[]) { hal_disable_ints(); hal_uart_init(); spi_init(); puts("Hardware testbed. Init clocks..."); clocks_init(); //now, hopefully, we should be running at 100MHz instead of 50MHz, meaning our UART is twice as fast and we're talking at 230400. while(1) { delay(500000); puts("Eat at Joe's."); } return 0; }
void console_init(void) { hal_uart_init(UART_BAUD_19K2); m_console = CONSOLE_AVAILABLE; }
static int at_init_uart(uart_dev_t *u) { at._uart = *u; if (hal_uart_init(u) != 0) return -1; else return 0; }
void hal_io_init(void) { hal_uart_init(); }