Bruno Allaire-Lemay
/
APP1test
df
Fork of APP1 by
Diff: UARTDisplayer.cpp
- Revision:
- 15:b38d9d210e32
- Parent:
- 14:2f89279586cb
- Child:
- 16:c77e34bc69bc
--- a/UARTDisplayer.cpp Mon Jan 16 02:28:40 2017 +0000 +++ b/UARTDisplayer.cpp Tue Jan 17 00:06:38 2017 +0000 @@ -63,53 +63,20 @@ void HomemadeUART::write(const unsigned char value) { homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C000), 0, 7, value); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x40098000), 0, 7, value); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C000), 0, 7, value); + /*homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x40098000), 0, 7, value); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C000), 0, 7, value);*/ } void HomemadeUART::init() { - printf("HomemadeUART::init()\r\n"); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x400FC0C4), 22, 23, 0x03); - assert(0x03 == homemade_mbed::read_bits(reinterpret_cast<unsigned int*>(0x400FC0C4), 22, 23)); - - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C00C), 7, 7, 0x01); - - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009800C), 7, 7, 0x01); - assert(false); - - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C00C), 7, 7, 0x01); - assert(false); - - /* - int* register_address1 = reinterpret_cast<int*>(0x400FC0C4); - const int previous_register_value1 = *register_address1; - int new_register_value1 = previous_register_value1; - new_register_value1 = utility::update_bit(new_register_value1, 22, 1); - new_register_value1 = utility::update_bit(new_register_value1, 23, 1); - *register_address1 = new_register_value1; - - int* register_address2 = reinterpret_cast<int*>(0x4000C00C); - const int previous_register_value2 = *register_address2; - int new_register_value2 = previous_register_value2; - new_register_value2 = utility::update_bit(new_register_value2, 7, 1); - *register_address2 = new_register_value2; - - int* register_address3 = reinterpret_cast<int*>(0x4009800C); - const int previous_register_value3 = *register_address3; - int new_register_value3 = previous_register_value3; - new_register_value3 = utility::update_bit(new_register_value3, 7, 1); - *register_address3 = new_register_value3; - - int* register_address4 = reinterpret_cast<int*>(0x4009C00C); - const int previous_register_value4 = *register_address4; - int new_register_value4 = previous_register_value4; - new_register_value4 = utility::update_bit(new_register_value4, 7, 1); - *register_address4 = new_register_value4; - */ - + //printf("set_baud_rate\r\n"); + //printf("set_baud_rate\rmarde"); set_baud_rate(9600); + //printf("fifo\r\n"); + set_fifo(); + //printf("lcr\r\n"); + set_lcr(); } void HomemadeUART::set_baud_rate(const unsigned int baud_rate) @@ -118,29 +85,40 @@ const unsigned int n_value = homemade_mbed::read_bits(reinterpret_cast<unsigned int*>(0x400FC088), 16, 23) + 1; const unsigned int in_frequency = 4000000; //Hz const unsigned int fcco = (2 * m_value * in_frequency) / n_value; + const unsigned int x = fcco / (baud_rate * 16 * 4); - const unsigned int x = fcco / (baud_rate * 16 * 4); - printf("m_value: %d\r\n", m_value); - printf("n_value: %d\r\n", n_value); - printf("in_frequency: %d\r\n", in_frequency); - printf("fcco: %d\r\n", fcco); - printf("x: %d\r\n", x); - + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C00C), 7, 7, 0x01); homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C000), 0, 7, x); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C00C), 7, 7, 0x00); + + /*homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009800C), 7, 7, 0x01); homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x40098000), 0, 7, x); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009800C), 7, 7, 0x00); + + utility::blink(); + + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C00C), 7, 7, 0x01); homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C000), 0, 7, x); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C00C), 7, 7, 0x00);*/ + + + //const unsigned char x_char = x; + //assert(x == x_char); + //printf("allo\r\n"); + + // utility::blink(); } void HomemadeUART::set_fifo() { - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C008), 0, 0, 1); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x40098008), 0, 0, 1); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4007C008), 0, 0, 1); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C008), 0, 0, 0x01); + /*homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x40098008), 0, 0, 0x01); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4007C008), 0, 0, 0x01);*/ } void HomemadeUART::set_lcr() { - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C00C), 0, 1, 1); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009800C), 0, 1, 1); - homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C00C), 0, 1, 1); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4000C00C), 0, 1, 0x03); + /* homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009800C), 0, 1, 0x03); + homemade_mbed::write_bits(reinterpret_cast<unsigned int*>(0x4009C00C), 0, 1, 0x03);*/ } \ No newline at end of file