-
Notifications
You must be signed in to change notification settings - Fork 3
Stm32f1 v0 #13
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
base: master
Are you sure you want to change the base?
Stm32f1 v0 #13
Changes from all commits
03d825b
5b53410
5446436
32f413f
308fadc
99ace19
fba8ed1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,7 @@ void usb_configure(uint8_t numEndpoints) | |
|
|
||
| #ifdef USB | ||
| __HAL_RCC_USB_CLK_ENABLE(); | ||
| irqn = USB_IRQn; | ||
| irqn = USB_HP_CAN1_TX_IRQn; | ||
| pcd.Init.speed = PCD_SPEED_FULL; | ||
| #else /* USB_OTG_FS */ | ||
| __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); | ||
|
|
@@ -112,8 +112,14 @@ void usb_configure(uint8_t numEndpoints) | |
| HAL_PCDEx_SetTxFiFo(&pcd, i, FIFO_EP_WORDS); | ||
| #endif /* USB */ | ||
|
|
||
| // USB_HP_CAN1_TX_IRQn | ||
| // USB_LP_CAN1_RX_IRQn | ||
|
|
||
| NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 5); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix indent
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and ifdef |
||
| NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); | ||
| NVIC_SetPriority(irqn, 5); | ||
| NVIC_EnableIRQ(irqn); | ||
|
|
||
| } | ||
|
|
||
| #if 0 | ||
|
|
@@ -150,6 +156,8 @@ static UsbEndpointOut *findOutEp(int ep) | |
|
|
||
| extern "C" | ||
| { | ||
| void USB_LP_IRQHandler(void) { HAL_PCD_IRQHandler(&pcd); } | ||
| void USB_HP_IRQHandler(void) { HAL_PCD_IRQHandler(&pcd); } | ||
|
|
||
| void OTG_FS_IRQHandler(void) { HAL_PCD_IRQHandler(&pcd); } | ||
|
|
||
|
|
@@ -337,25 +345,33 @@ static void writeEP(uint8_t *data, uint8_t ep, int len) | |
| { | ||
| usb_assert(len <= USB_MAX_PKT_SIZE); | ||
| uint32_t len32b = (len + 3) / 4; | ||
|
|
||
| #ifndef USB | ||
| DBG("%d write space: %d words", (int)codal::system_timer_current_time_us(), | ||
| USBx_INEP(ep)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV); | ||
|
|
||
| while ((USBx_INEP(ep)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) < len32b) | ||
| ; | ||
|
|
||
| DBG("write: %p len=%d at IN %d", data, len, ep); | ||
| DBG("write: %p len=%d at IN %d", data, len, ep); | ||
| CHK(HAL_PCD_EP_Transmit(&pcd, ep | 0x80, data, len)); | ||
|
|
||
| if (len) | ||
| CHK(USB_WritePacket(pcd.Instance, data, ep, len, 0)); | ||
| #else | ||
| DBG("write: %p len=%d at IN %d", data, len, ep); | ||
| CHK(HAL_PCD_EP_Transmit(&pcd, ep | 0x80, data, len)); | ||
|
|
||
| if (len) | ||
| CHK(USB_WritePacket(pcd.Instance, data, ep, len)); | ||
| #endif | ||
|
|
||
| #ifndef USB | ||
| USBx_DEVICE->DIEPEMPMSK &= ~0x1U << ep; | ||
|
|
||
| while (!(USB_ReadDevInEPInterrupt(pcd.Instance, ep) & USB_OTG_DIEPINT_XFRC)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check usb works overall |
||
| ; | ||
| CLEAR_IN_EP_INTR(ep, USB_OTG_DIEPINT_XFRC); | ||
|
|
||
| #endif | ||
| DBG("%d write done, ctl=%p", (int)codal::system_timer_current_time_us(), | ||
| USBx_OUTEP(0)->DOEPCTL); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ static ZSingleWireSerial *instances[4]; | |
|
|
||
| static int enable_clock(uint32_t instance) | ||
| { | ||
| DMESG("CLK EN"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to remove |
||
| switch (instance) | ||
| { | ||
| case USART1_BASE: | ||
|
|
@@ -42,6 +43,11 @@ static int enable_clock(uint32_t instance) | |
| NVIC_SetPriority(USART2_IRQn, 2); | ||
| NVIC_EnableIRQ(USART2_IRQn); | ||
| return HAL_RCC_GetPCLK1Freq(); | ||
| case USART3_BASE: | ||
| __HAL_RCC_USART3_CLK_ENABLE(); | ||
| DMESG("PCLK1 %d", HAL_RCC_GetPCLK1Freq()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove dmesg |
||
| NVIC_EnableIRQ(USART3_IRQn); | ||
| return HAL_RCC_GetPCLK1Freq(); | ||
| #ifdef USART6_BASE | ||
| case USART6_BASE: | ||
| __HAL_RCC_USART6_CLK_ENABLE(); | ||
|
|
@@ -116,6 +122,7 @@ extern "C" void HAL_UART_ErrorCallback(UART_HandleTypeDef *hspi) | |
|
|
||
| DEFIRQ(USART1_IRQHandler, USART1_BASE) | ||
| DEFIRQ(USART2_IRQHandler, USART2_BASE) | ||
| DEFIRQ(USART3_IRQHandler, USART3_BASE) | ||
| #ifdef USART6_BASE | ||
| DEFIRQ(USART6_IRQHandler, USART6_BASE) | ||
| #endif | ||
|
|
@@ -197,8 +204,9 @@ int ZSingleWireSerial::configureTx(int enable) | |
| if (enable && !(status & TX_CONFIGURED)) | ||
| { | ||
| uint8_t pin = (uint8_t)p.name; | ||
| pin_mode(pin, PullNone); | ||
| // pin_mode(pin, PullNone); | ||
| pin_function(pin, pinmap_function(pin, PinMap_UART_TX)); | ||
| pin_mode(pin,PullUp); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check this pin mode business |
||
| uart.Init.Mode = UART_MODE_TX; | ||
| HAL_HalfDuplex_Init(&uart); | ||
| status |= TX_CONFIGURED; | ||
|
|
@@ -291,6 +299,7 @@ int ZSingleWireSerial::sendDMA(uint8_t* data, int len) | |
| this->bufLen = len; | ||
|
|
||
| int res = HAL_UART_Transmit_DMA(&uart, data, len); | ||
| DMESG("TXDMA RES %d ",res); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
|
|
||
| CODAL_ASSERT(res == HAL_OK, DEVICE_HARDWARE_CONFIGURATION_ERROR); | ||
|
|
||
|
|
@@ -326,16 +335,23 @@ int ZSingleWireSerial::getBytesReceived() | |
| { | ||
| if (!(status & RX_CONFIGURED)) | ||
| return DEVICE_INVALID_PARAMETER; | ||
|
|
||
| #ifdef STM32F1 | ||
| return hdma_rx.Instance->CNDTR; | ||
| #else | ||
| return hdma_rx.Instance->NDTR; | ||
| #endif | ||
| } | ||
|
|
||
| int ZSingleWireSerial::getBytesTransmitted() | ||
| { | ||
| if (!(status & TX_CONFIGURED)) | ||
| return DEVICE_INVALID_PARAMETER; | ||
|
|
||
| #ifdef STM32F1 | ||
| return hdma_tx.Instance->CNDTR; | ||
| #else | ||
| return hdma_tx.Instance->NDTR; | ||
| #endif | ||
| } | ||
|
|
||
| int ZSingleWireSerial::sendBreak() | ||
|
|
||
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.
to remove