Skip to content

Ambiq apollo3 serial fix #31

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

Merged
merged 6 commits into from
Sep 9, 2020
Merged

Conversation

Wenn0101
Copy link

@Wenn0101 Wenn0101 commented Sep 4, 2020

Major changes:

-made certain parts of the init only happen on the first init
-comment out (is this the best option) part of ambiq hal that "sets up buffer" and disables interrupts if we arent using hal buffer
-change hal to use AM_HAL_UART_FIFO_DISABLE because i couldn't find a threshold that would allow the interrupt to fire on each byte otherwise
-serial_irq_set fixed to enable and disable individual interrupts
-remove fluff, TODO's, and temp code.

outstanding questions
-add FC or remove TODO's?

@Wenn0101 Wenn0101 requested a review from oclyke September 4, 2020 12:08
Comment on lines 439 to 443
// buffer_configure(pHandle,
// psConfig->pui8TxBuffer,
// psConfig->ui32TxBufferSize,
// psConfig->pui8RxBuffer,
// psConfig->ui32RxBufferSize);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it necessary to change the HAL here? is it not enough to simply set these 4 buffers as NULL? (i figure the HAL would not do anything with them if they were not provided)

@@ -420,7 +420,7 @@ am_hal_uart_configure(void *pHandle, const am_hal_uart_config_t *psConfig)
UARTn(ui32Module)->LCRH = (psConfig->ui32DataBits |
psConfig->ui32Parity |
psConfig->ui32StopBits |
AM_HAL_UART_FIFO_ENABLE);
AM_HAL_UART_FIFO_DISABLE);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does / should this HAL change go through our AmbiqSuiteSDK mirror branch?

is there really no way to change this setting via HAL calls w/ proper configuration?

// set default baud rate and format
serial_baud(obj, 9600);
serial_format(obj, 8, ParityNone, 1);
if(!obj->serial.uart_control->handle)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see you using the handle as an initialized flag here... just commenting b/c i have recently doubted whether this method worked for the IOM modules

serial_format(obj, 8, ParityNone, 1);
if(!obj->serial.uart_control->handle)
{
//printf("setting up UART first time?\r\n");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prolly don' need this printf... a comment or nothing would suffice

}

void serial_free(serial_t *obj)
{
//serialinitialized = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is no longer used (opting for use of the handle as this flag) so we can remove

}

NVIC_EnableIRQ((IRQn_Type)(UART0_IRQn + obj->serial.uart_control->inst));

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need (style nit)

// memset(obj->serial.uart_control->cfg, 0x00, sizeof(am_hal_uart_config_t)); // ensure config begins zeroed

// config uart pins
// config uart pins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get a line break above this? (style nit)

@oclyke
Copy link

oclyke commented Sep 4, 2020

@Wenn0101 just requested some changes mostly b/c I had questions. The only actual changes would be style nits and possibly another way of configuring the HAL to do what we need. Otherwise looks real good

oclyke added 2 commits September 8, 2020 13:36
removes unused comments, consistent brace style
missed one
this adds a new am_hal_uart_configure_fifo function which takes a boolean option whether to enable or disable FIFO operation
oclyke pushed a commit that referenced this pull request Sep 8, 2020
trying to match #31. it is too bad we have to do this manually...
@oclyke oclyke merged commit 24e5f0a into ambiq-apollo3-dev Sep 9, 2020
@oclyke oclyke deleted the ambiq-apollo3-serial-fix branch September 9, 2020 03:13
@oclyke oclyke restored the ambiq-apollo3-serial-fix branch September 9, 2020 03:13
@Wenn0101 Wenn0101 deleted the ambiq-apollo3-serial-fix branch December 9, 2020 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants