Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( ( I need help in this code to modify it to send data value to uart2 or uart3 to send them via Bluetooth module?

( ( I need help in this code to modify it to send data value to uart2 or uart3 to send them via Bluetooth module? ) )

/*****************************************************************//** * * * * * * io 0: uart2 rx (into fpga) * * io 1: uart2 tx * * io 2: uart3 rx * * io 3: uart3 tx * *********************************************************************/ // #define _DEBUG #include "chu_init.h" #include "gpio_cores.h" #include "xadc_arty_core.h" #include "spi_core.h" #include "i2c_core.h" /** * blink once per second for 5 times. * provide a sanity check for timer (based on SYS_CLK_FREQ) * @param led_p pointer to led instance */ void timer_check(GpoCore *led_p) { int i; for (i = 0; i < 5; i++) { led_p->write(0xffff); sleep_ms(500); led_p->write(0x0000); sleep_ms(500); debug("timer check - (loop #)/now: ", i, now_ms()); } } /** * check individual led * @param led_p pointer to led instance * @param n number of led */ void led_check(GpoCore *led_p, int n) { int i; for (i = 0; i < n; i++) { led_p->write(1, i); sleep_ms(100); led_p->write(0, i); sleep_ms(100); } } /** * uart transmits test line. * @note uart instance is declared as global variable in chu_io_basic.h */ void disp_header() { static int loop = 0; uart.disp(" ********************************* "); uart.disp("measurement #"); uart.disp(loop); uart.disp(" ********************************* "); loop++; } /** * read FPGA internal voltage temperature * @param adc_p pointer to xadc instance */ void arty_adc_check(XadcArtyCore *adc_p) { double reading; // display die temperature uart.disp("FPGA die temp (C): "); reading = adc_p->read_fpga_temp(); uart.disp(reading, 3); uart.disp(" "); // display core voltage/current uart.disp("FPGA Vcc/Icc: "); reading = adc_p->read_fpga_vcc(); uart.disp(reading, 3); uart.disp(" / "); reading = adc_p->read_fpga_icc(); uart.disp(reading, 3); uart.disp(" "); // display power supply voltage uart.disp("Supplied board voltage: "); reading = adc_p->read_board_v(); uart.disp(reading, 3); uart.disp(" "); // display 5V regulator voltage/current uart.disp("5V power V/I: "); reading = adc_p->read_5v_v(); uart.disp(reading, 3); uart.disp(" / "); reading = adc_p->read_5v_i(); uart.disp(reading, 3); uart.disp(" "); } /* * read temperature from adt7420 * @param adt7420_p pointer to i2c adt7420 instance */ void adt7420_check(I2cCore *adt7420_p) { const uint8_t DEV_ADDR = 0x4b; uint8_t wbytes[2], bytes[2]; //int ack; uint16_t tmp; float tmpC; /* read adt7420 temperature */ wbytes[0] = 0x00; adt7420_p->write_transaction(DEV_ADDR, wbytes, 1, 1); adt7420_p->read_transaction(DEV_ADDR, bytes, 2, 0); /* temperature conversion */ tmp = (uint16_t) bytes[0]; tmp = (tmp << 8) + (uint16_t) bytes[1]; if (tmp & 0x8000) { tmp = tmp >> 3; tmpC = (float) ((int) tmp - 8192) / 16; } else { tmp = tmp >> 3; tmpC = (float) tmp / 16; } uart.disp("ambient temp (C): "); uart.disp(tmpC); uart.disp(" "); } GpoCore led(get_slot_addr(BRIDGE_BASE, S2_LED)); GpiCore sw(get_slot_addr(BRIDGE_BASE, S3_SW)); XadcArtyCore adc(get_slot_addr(BRIDGE_BASE, S5_XDAC)); PwmCore pwm(get_slot_addr(BRIDGE_BASE, S6_PWM)); SpiCore spi(get_slot_addr(BRIDGE_BASE, S9_SPI)); I2cCore adt7420(get_slot_addr(BRIDGE_BASE, S10_I2C)); // 2 extra uarts UartCore uart2(get_slot_addr(BRIDGE_BASE, 14)); UartCore uart3(get_slot_addr(BRIDGE_BASE, 15)); int main() { uint8_t test_byte=0x20; // set uart2/uart3 baud rate uart2.set_baud_rate(9600); uart3.set_baud_rate(9600); uart2.disp("uart 2 is alive "); uart3.disp("uart 3 is alive "); // check timer/led timer_check(&led); led_check(&led, 4); while (1) { disp_header(); arty_adc_check(&adc); adt7420_check(&adt7420); // uart 2 & 3 test uart2.disp(test_byte); uart3.disp(test_byte); test_byte = (test_byte==0x7e) ? 0x20 : test_byte+1; // wait for 0.5 second sleep_ms(500); } //while } //main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions