add CDC mode only for use with Arduino touch 1200
fix issue with reading current.uf2 size when flashed with jlink
This commit is contained in:
		| @@ -57,8 +57,6 @@ | ||||
|       <file file_name="../sdk_config.h" /> | ||||
|       <folder Name="usb"> | ||||
|         <file file_name="../usb/tusb_config.h" /> | ||||
|         <file file_name="../usb/tusb_descriptors.c" /> | ||||
|         <file file_name="../usb/tusb_descriptors.h" /> | ||||
|         <folder Name="uf2"> | ||||
|           <file file_name="../usb/uf2/uf2cfg.h" /> | ||||
|           <file file_name="../usb/uf2/uf2.h" /> | ||||
| @@ -66,6 +64,8 @@ | ||||
|         </folder> | ||||
|         <file file_name="../usb/msc_uf2.c" /> | ||||
|         <file file_name="../usb/usb.c" /> | ||||
|         <file file_name="../usb/usb_desc.c" /> | ||||
|         <file file_name="../usb/usb_desc.h" /> | ||||
|       </folder> | ||||
|       <folder Name="cmsis"> | ||||
|         <folder Name="include"> | ||||
| @@ -210,7 +210,6 @@ | ||||
|             <file file_name="../../lib/tinyusb/src/device/usbd.c" /> | ||||
|             <file file_name="../../lib/tinyusb/src/device/usbd.h" /> | ||||
|             <file file_name="../../lib/tinyusb/src/device/usbd_pvt.h" /> | ||||
|             <file file_name="../../lib/tinyusb/src/device/usbd_auto_desc.c" /> | ||||
|           </folder> | ||||
|           <folder Name="osal"> | ||||
|             <file file_name="../../lib/tinyusb/src/osal/osal.c" /> | ||||
|   | ||||
| @@ -135,7 +135,14 @@ static uint32_t get_flash_size(void) | ||||
|       const bootloader_settings_t * boot_setting; | ||||
|       bootloader_util_settings_get(&boot_setting); | ||||
|  | ||||
|       // if bank0 size is not valid, happens when flashed with jlink | ||||
|       // use maximum application size | ||||
|  | ||||
|       flash_sz = boot_setting->bank_0_size; | ||||
|       if ( (flash_sz == 0) || (flash_sz == 0xFFFFFFFFUL) ) | ||||
|       { | ||||
|         flash_sz = FLASH_SIZE; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -44,11 +44,16 @@ | ||||
|  | ||||
| #include "nrf_usbd.h" | ||||
| #include "tusb.h" | ||||
| #include "usb_desc.h" | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // MACRO TYPEDEF CONSTANT ENUM DECLARATION | ||||
| //--------------------------------------------------------------------+ | ||||
|  | ||||
| // from usb_desc.c for dynamic descriptor | ||||
| extern tusb_desc_device_t usb_desc_dev; | ||||
| extern usb_desc_cfg_t     usb_desc_cfg; | ||||
|  | ||||
| /* tinyusb function that handles power event (detected, ready, removed) | ||||
|  * We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */ | ||||
| extern void tusb_hal_nrf_power_event(uint32_t event); | ||||
| @@ -95,6 +100,16 @@ void usb_init(bool cdc_only) | ||||
|     tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY); | ||||
|   } | ||||
|  | ||||
|   if ( cdc_only ) | ||||
|   { | ||||
|     // Change PID to CDC only | ||||
|     usb_desc_dev.idProduct = USB_DESC_SERIAL_ONLY_PID; | ||||
|  | ||||
|     // Remove MSC interface = reduce total interface + adjust config desc length | ||||
|     usb_desc_cfg.config.bNumInterfaces--; | ||||
|     usb_desc_cfg.config.wTotalLength -= sizeof(usb_desc_cfg.msc); | ||||
|   } | ||||
|  | ||||
|   // Init tusb stack | ||||
|   tusb_init(); | ||||
| } | ||||
|   | ||||
| @@ -85,9 +85,6 @@ typedef struct ATTR_PACKED | ||||
| } usb_desc_cfg_t; | ||||
|  | ||||
|  | ||||
| extern tusb_desc_device_t usb_desc_dev; | ||||
| extern usb_desc_cfg_t     usb_desc_cfg; | ||||
|  | ||||
| #ifdef __cplusplus | ||||
|  } | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user