able to build with pca10056 & feather52832
This commit is contained in:
		| @@ -44,7 +44,9 @@ | |||||||
| #include "app_uart.h" | #include "app_uart.h" | ||||||
| #include "nrf_error.h" | #include "nrf_error.h" | ||||||
|  |  | ||||||
|  | #ifdef NRF52840_XXAA | ||||||
| #include "tusb.h" | #include "tusb.h" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #define APP_SLIP_END        0xC0                            /**< SLIP code for identifying the beginning and end of a packet frame.. */ | #define APP_SLIP_END        0xC0                            /**< SLIP code for identifying the beginning and end of a packet frame.. */ | ||||||
| #define APP_SLIP_ESC        0xDB                            /**< SLIP escape code. This code is used to specify that the following character is specially encoded. */ | #define APP_SLIP_ESC        0xDB                            /**< SLIP escape code. This code is used to specify that the following character is specially encoded. */ | ||||||
| @@ -119,14 +121,21 @@ static uint32_t send_tx_byte_end(void); | |||||||
|  */ |  */ | ||||||
| uint32_t (*send_tx_byte) (void) = send_tx_byte_default; | uint32_t (*send_tx_byte) (void) = send_tx_byte_default; | ||||||
|  |  | ||||||
| static uint32_t usb_uart_put(char ch) | #ifdef NRF52840_XXAA | ||||||
|  |  | ||||||
|  | static uint32_t serial_put(char ch) | ||||||
| { | { | ||||||
|   return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM; |   return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM; | ||||||
| } | } | ||||||
|  | #else | ||||||
|  |  | ||||||
|  | #define serial_put    app_uart_put   | ||||||
|  |  | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static uint32_t send_tx_byte_end(void) | static uint32_t send_tx_byte_end(void) | ||||||
| { | { | ||||||
|     uint32_t err_code = usb_uart_put(APP_SLIP_END); |     uint32_t err_code = serial_put(APP_SLIP_END); | ||||||
|  |  | ||||||
|     if ((err_code == NRF_SUCCESS) && (m_tx_buffer_index == 0)) |     if ((err_code == NRF_SUCCESS) && (m_tx_buffer_index == 0)) | ||||||
|     { |     { | ||||||
| @@ -140,7 +149,7 @@ static uint32_t send_tx_byte_end(void) | |||||||
|  |  | ||||||
| static uint32_t send_tx_byte_default(void) | static uint32_t send_tx_byte_default(void) | ||||||
| { | { | ||||||
|     uint32_t err_code = usb_uart_put(mp_tx_buffer[m_tx_buffer_index]); |     uint32_t err_code = serial_put(mp_tx_buffer[m_tx_buffer_index]); | ||||||
|  |  | ||||||
|     if (err_code == NRF_SUCCESS) |     if (err_code == NRF_SUCCESS) | ||||||
|     { |     { | ||||||
| @@ -158,11 +167,11 @@ static uint32_t send_tx_byte_encoded(void) | |||||||
|     switch (mp_tx_buffer[m_tx_buffer_index]) |     switch (mp_tx_buffer[m_tx_buffer_index]) | ||||||
|     { |     { | ||||||
|         case APP_SLIP_END: |         case APP_SLIP_END: | ||||||
|             err_code = usb_uart_put(APP_SLIP_ESC_END); |             err_code = serial_put(APP_SLIP_ESC_END); | ||||||
|             break; |             break; | ||||||
|  |  | ||||||
|         case APP_SLIP_ESC: |         case APP_SLIP_ESC: | ||||||
|             err_code = usb_uart_put(APP_SLIP_ESC_ESC); |             err_code = serial_put(APP_SLIP_ESC_ESC); | ||||||
|             break; |             break; | ||||||
|  |  | ||||||
|         default: |         default: | ||||||
| @@ -182,7 +191,7 @@ static uint32_t send_tx_byte_encoded(void) | |||||||
|  |  | ||||||
| static uint32_t send_tx_byte_esc(void) | static uint32_t send_tx_byte_esc(void) | ||||||
| { | { | ||||||
|     uint32_t err_code = usb_uart_put(APP_SLIP_ESC); |     uint32_t err_code = serial_put(APP_SLIP_ESC); | ||||||
|  |  | ||||||
|     if (err_code == NRF_SUCCESS) |     if (err_code == NRF_SUCCESS) | ||||||
|     { |     { | ||||||
| @@ -339,7 +348,25 @@ static bool rx_buffer_overflowed(void) | |||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
|  |  | ||||||
| #if 0 | #ifdef NRF52840_XXAA | ||||||
|  |  | ||||||
|  | static uint32_t slip_uart_open(void) | ||||||
|  | { | ||||||
|  |   m_current_state = SLIP_READY; | ||||||
|  |   return NRF_SUCCESS; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void tud_cdc_rx_cb(uint8_t port) | ||||||
|  | { | ||||||
|  |   while ( tud_cdc_available() && !rx_buffer_overflowed() ) | ||||||
|  |   { | ||||||
|  |     int8_t ch = tud_cdc_read_char(); | ||||||
|  |     handle_rx_byte((uint8_t) ch); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #else | ||||||
|  |  | ||||||
| /** @brief Function for handling the UART module event. It parses events from the UART when | /** @brief Function for handling the UART module event. It parses events from the UART when | ||||||
|  *         bytes are received/transmitted. |  *         bytes are received/transmitted. | ||||||
|  * |  * | ||||||
| @@ -371,7 +398,7 @@ static uint32_t slip_uart_open(void) | |||||||
|         HCI_UART_TX_PIN, |         HCI_UART_TX_PIN, | ||||||
|         HCI_UART_RTS_PIN, |         HCI_UART_RTS_PIN, | ||||||
|         HCI_UART_CTS_PIN, |         HCI_UART_CTS_PIN, | ||||||
|         (app_uart_flow_control_t)HCI_UART_FLOW_CONTROL, |         HCI_UART_FLOW_CONTROL, | ||||||
|         false, |         false, | ||||||
|         HCI_UART_BAUDRATE |         HCI_UART_BAUDRATE | ||||||
|     }; |     }; | ||||||
| @@ -387,22 +414,6 @@ static uint32_t slip_uart_open(void) | |||||||
|     } |     } | ||||||
|     return err_code; |     return err_code; | ||||||
| } | } | ||||||
| #else |  | ||||||
|  |  | ||||||
| static uint32_t slip_uart_open(void) |  | ||||||
| { |  | ||||||
|   m_current_state = SLIP_READY; |  | ||||||
|   return NRF_SUCCESS; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void tud_cdc_rx_cb(uint8_t port) |  | ||||||
| { |  | ||||||
|   while ( tud_cdc_available() && !rx_buffer_overflowed() ) |  | ||||||
|   { |  | ||||||
|     int8_t ch = tud_cdc_read_char(); |  | ||||||
|     handle_rx_byte((uint8_t) ch); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -433,11 +444,11 @@ uint32_t hci_slip_open() | |||||||
| uint32_t hci_slip_close() | uint32_t hci_slip_close() | ||||||
| { | { | ||||||
|     m_current_state   = SLIP_OFF; |     m_current_state   = SLIP_OFF; | ||||||
| #if 0 | #ifdef NRF52840_XXAA | ||||||
|  |     return NRF_SUCCESS; | ||||||
|  | #else | ||||||
|     uint32_t err_code = app_uart_close(); |     uint32_t err_code = app_uart_close(); | ||||||
|     return err_code; |     return err_code; | ||||||
| #else |  | ||||||
|     return NRF_SUCCESS; |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -25,11 +25,13 @@ | |||||||
| #include "crc16.h" | #include "crc16.h" | ||||||
| #include "pstorage.h" | #include "pstorage.h" | ||||||
| #include "app_scheduler.h" | #include "app_scheduler.h" | ||||||
| #include "nrf_delay.h" |  | ||||||
|  |  | ||||||
|  | #include "nrfx.h" | ||||||
| #include "app_timer.h" | #include "app_timer.h" | ||||||
|  |  | ||||||
|  | #ifdef NRF52840_XXAA | ||||||
| #include "tusb.h" | #include "tusb.h" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #define APP_TIMER_PRESCALER    0 | #define APP_TIMER_PRESCALER    0 | ||||||
|  |  | ||||||
| @@ -125,11 +127,10 @@ static void wait_for_events(void) | |||||||
|         // Event received. Process it from the scheduler. |         // Event received. Process it from the scheduler. | ||||||
|         app_sched_execute(); |         app_sched_execute(); | ||||||
|  |  | ||||||
|         // USB stack | #ifdef NRF52840_XXAA | ||||||
|         tusb_task(); |         tusb_task(); | ||||||
|  |  | ||||||
|         // Send out cdc's data |  | ||||||
|         tud_cdc_write_flush(); |         tud_cdc_write_flush(); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|         if ((m_update_status == BOOTLOADER_COMPLETE) || |         if ((m_update_status == BOOTLOADER_COMPLETE) || | ||||||
|             (m_update_status == BOOTLOADER_TIMEOUT)  || |             (m_update_status == BOOTLOADER_TIMEOUT)  || | ||||||
| @@ -415,7 +416,7 @@ uint32_t bootloader_dfu_sd_update_continue(void) | |||||||
|  |  | ||||||
|     // Ensure that flash operations are not executed within the first 100 ms seconds to allow |     // Ensure that flash operations are not executed within the first 100 ms seconds to allow | ||||||
|     // a debugger to be attached. |     // a debugger to be attached. | ||||||
|     nrf_delay_ms(100); |     NRFX_DELAY_MS(100); | ||||||
|  |  | ||||||
|     err_code = dfu_sd_image_swap(); |     err_code = dfu_sd_image_swap(); | ||||||
|     APP_ERROR_CHECK(err_code); |     APP_ERROR_CHECK(err_code); | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								src/Makefile
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/Makefile
									
									
									
									
									
								
							| @@ -142,10 +142,8 @@ C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_slip.c | |||||||
| C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_transport.c | C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_transport.c | ||||||
| C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c | C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c | ||||||
|  |  | ||||||
| #C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c |  | ||||||
| #C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c |  | ||||||
|  |  | ||||||
| #C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c |  | ||||||
| C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/hal/nrf_nvmc.c | C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/hal/nrf_nvmc.c | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -175,6 +173,12 @@ else | |||||||
|  |  | ||||||
| C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c | C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c | ||||||
|  |  | ||||||
|  | C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c | ||||||
|  | C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c | ||||||
|  | C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c | ||||||
|  |  | ||||||
|  | IPATH += $(SDK_PATH)/drivers_nrf/common | ||||||
|  | IPATH += $(SDK_PATH)/drivers_nrf/uart | ||||||
|  |  | ||||||
| endif | endif | ||||||
|  |  | ||||||
| @@ -185,7 +189,7 @@ endif | |||||||
| ifneq ($(IS_NRF52840),) | ifneq ($(IS_NRF52840),) | ||||||
| ASM_SOURCE_FILES  = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S | ASM_SOURCE_FILES  = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S | ||||||
| else | else | ||||||
| #ASM_SOURCE_FILES  = $(NRFX_PATH)/mdk/gcc_startup_nrf52.S | ASM_SOURCE_FILES  = $(NRFX_PATH)/mdk/gcc_startup_nrf52.S | ||||||
| endif | endif | ||||||
|  |  | ||||||
| #****************************************************************************** | #****************************************************************************** | ||||||
| @@ -220,11 +224,10 @@ IPATH += $(SDK_PATH)/libraries/hci/config | |||||||
| IPATH += $(SDK_PATH)/libraries/uart | IPATH += $(SDK_PATH)/libraries/uart | ||||||
| IPATH += $(SDK_PATH)/libraries/hci | IPATH += $(SDK_PATH)/libraries/hci | ||||||
|  |  | ||||||
| #IPATH += $(SDK_PATH)/drivers_nrf/common |  | ||||||
| #IPATH += $(SDK_PATH)/drivers_nrf/hal | #IPATH += $(SDK_PATH)/drivers_nrf/hal | ||||||
| #IPATH += $(SDK_PATH)/drivers_nrf/config | #IPATH += $(SDK_PATH)/drivers_nrf/config | ||||||
| IPATH += $(SDK_PATH)/drivers_nrf/delay | IPATH += $(SDK_PATH)/drivers_nrf/delay | ||||||
| #IPATH += $(SDK_PATH)/drivers_nrf/uart |  | ||||||
| #IPATH += $(SDK_PATH)/drivers_nrf/power | #IPATH += $(SDK_PATH)/drivers_nrf/power | ||||||
|  |  | ||||||
| # Softdevice | # Softdevice | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user