-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented UART in accordance with the API definition in softuart.h to allow the example code to access printf() functionality #18
base: linux-descriptors
Are you sure you want to change the base?
Conversation
This is starting down the right path, but there are a couple of big things which need to change. As I described in my email, there should be a function / macro something like This allows you to create two uarts on two different pins which can be used at the same time. Your comments about the API are misleading too. It very much does matter what you return for the queue count. When commenting your ASM, you should align things like cycle counts above each other. |
Please write your setup/testing instructions in the form of valid shell commands too. |
#include <stdio.h> | ||
#include <uart/api.h> | ||
|
||
//Used for setting the baud rate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't define things you are not using at the moment.
I am a little confused as to how you plan to achieve this. |
This is kind of hard but I have tried doing it |
01fcdd0
to
0803a71
Compare
Try taking a look at the following regarding cycle comments; |
|
||
BOOL uartX_set_baud(enum uart_baud rate) | ||
{ | ||
switch(rate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually didn't mean for you to implement all the baud rates, just to return an error when the baud rate was not BAUD_115200
. However, as you have already done it now we can leave it here.
4f4d855
to
5076805
Compare
@@ -0,0 +1,15 @@ | |||
#!/bin/bash -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This download script should probably be shared between all examples. Can you move it into the examples directory and send it as a separate pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could then have it as part of the common Makefile..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
void main(void) | ||
{ | ||
baud = BAUD_115200; | ||
uartX_init(baud); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be called "uart0_init" as we discussed? Are you waiting on something from me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have a question. If I call printf(), how does it know which uart to connect to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need a function in the firmware which maps puts to the correct uart function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putchar() can be mapped to one uart.How do we do this for more than 1 and dynamically? Once again I think things would be easier once I create and commit the macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit.
This still need a bunch of work before it can be merged. Couple of things which need to be done are;
As I mentioned previously, this UART is mainly for debugging -- so we want it to be fast and have minimal impact on the system. This probably means we are going to be okay with using a non-standard BAUD rate here. |
SETCPUFREQ(CLK_48M); | ||
while (TRUE) | ||
{ | ||
printf("Hello"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a \r\n
to the printed string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
7ce523c
to
82ae218
Compare
OEA = bitnum; \ | ||
uart_tx(c); \ | ||
} \ | ||
BOOL uartname##_set_baud(enum uart_baud rate) { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something funky. On gedit it is aligned(using tabs). Which editor do you want to use? Autoindenting in astyle is not able to align the \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't care what editor you use. I care that you set up your editor to produce the correct result. If you find it too hard to do that in gedit, you are welcome to try a different one.
I personally use vim, but it has a very steep learning curve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like only this diff view is showing this. The normal file here is https://github.com/RacingTornado/fx2lib/blob/9b86ebfe1bb807bdca802db8da0f271c2ed574e5/include/uart/soft_uart.h looks okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normal file is also showing the weird wrapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not showing it for me . I sent you an email with a picture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
82ae218
to
9b86ebf
Compare
DSCR_AREA= | ||
INT2JT= | ||
include $(FX2LIBDIR)/lib/fx2.mk | ||
fx2_download: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This target should be part of fx2.mk
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
This code still needs a whole bunch more work and I'm pretty sure if it does work, it is only by accident. |
Why do you say that ? I use this extensively for debugging all my other stuff and it seems very reliable. |
da356b1
to
614a4c3
Compare
* uart name . | ||
**/ | ||
#define CREATE_FAST_UART(uartname,port,pinname,bitnum,TX_BLOCKING,RX_ENABLED) \ | ||
unsigned char uartname##_load_delay; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last 2 are caps because they are TRUE or FALSE values
473cfb4
to
d0519f9
Compare
For fast_uart , git checkout branch_name
sudo minicom -H -w fastuart
You should have the parameters of fastuart set to 115200. You should see the values on the terminal.
The PA2 pin must be connected to the rx pin on the serial adaptor. In this situation , the ground must be the same also. Else you may get receiving errors.
The idea is to use this for debugging purposes. The baud rates is set to 115200 by setting the delay values.
Another important fact is that the console must be first opened up before loading the firmware onto the FX2. This is required for getting a lock on the start and the stop bits since there is no line break attached between the 2 bytes.
Code has been cleaned up and the firmware in the examples directory is extremely small(less than 5-6 lines)
Assembly has been extensively commented.
I would like to merge this with the linux-descriptors branch since this is what I used as a base