Skip to content

Commit d7f24a6

Browse files
authored
Merge pull request #760 from ARMmbed/microbit-foundation-microbit_base
KL27Z base port merge
2 parents 9baff73 + e49f8b5 commit d7f24a6

31 files changed

+12723
-13
lines changed

projects.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ module:
5050
- records/rtos/rtos-cm0.yaml
5151
- records/hic_hal/kl26z.yaml
5252
- records/usb/usb-bulk.yaml
53+
hic_kl27z: &module_hic_kl27z
54+
- records/rtos/rtos-cm0.yaml
55+
- records/hic_hal/kl27z.yaml
56+
- records/usb/usb-bulk.yaml
5357
hic_lpc11u35: &module_hic_lpc11u35
5458
- records/rtos/rtos-cm0.yaml
5559
- records/hic_hal/lpc11u35.yaml
@@ -82,6 +86,14 @@ projects:
8286
- *module_if
8387
- *module_hic_kl26z
8488
- records/family/all_family.yaml
89+
kl27z_bl:
90+
- *module_bl
91+
- records/hic_hal/kl27z.yaml
92+
- records/board/kl27z_bl.yaml
93+
kl27z_if:
94+
- *module_if
95+
- *module_hic_kl27z
96+
- records/family/all_family.yaml
8597
k20dx_bl:
8698
- *module_bl
8799
- records/hic_hal/k20dx.yaml
@@ -154,6 +166,10 @@ projects:
154166
- *module_if
155167
- *module_hic_kl26z
156168
- records/board/microbit.yaml
169+
kl27z_microbit_if:
170+
- *module_if
171+
- *module_hic_kl27z
172+
- records/board/microbitv2.yaml
157173
kl26z_nina_b1_if:
158174
- *module_if
159175
- *module_hic_kl26z

records/board/kl27z_bl.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
common:
2+
sources:
3+
board:
4+
- source/board/kl27z_bl.c

records/board/microbitv2.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
common:
2+
macros:
3+
- HID_LED_DEF=GPIO_LED_ON
4+
- CDC_LED_DEF=GPIO_LED_ON
5+
- MSC_LED_DEF=GPIO_LED_ON
6+
- USB_PROD_STR="BBC micro:bit CMSIS-DAP"
7+
sources:
8+
board:
9+
- source/board/microbitv2/microbitv2.c
10+
target:
11+
- source/family/nordic/nrf5x/target.c
12+
- source/family/nordic/target_reset_nrf52.c

records/hic_hal/kl27z.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
common:
2+
target:
3+
- mkl27z256xxx4
4+
core:
5+
- Cortex-M0+
6+
macros:
7+
- INTERFACE_KL27Z
8+
- CPU_MKL27Z256VFM4
9+
- DAPLINK_HIC_ID=0x9796990B # DAPLINK_HIC_ID_KL27
10+
- FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT=0
11+
- FLASH_DRIVER_IS_FLASH_RESIDENT=1
12+
- DAPLINK_NO_ASSERT_FILENAMES
13+
- OS_CLOCK=48000000
14+
includes:
15+
- source/hic_hal/freescale/kl27z
16+
- source/hic_hal/freescale/kl27z/MKL27Z4
17+
- source/hic_hal/freescale/iap
18+
- projectfiles/uvision/kl27z_bl/build
19+
sources:
20+
hic_hal:
21+
- source/hic_hal/freescale
22+
- source/hic_hal/freescale/kl27z
23+
- source/hic_hal/freescale/kl27z/MKL27Z4
24+
- source/hic_hal/freescale/kl27z/armcc
25+
fsl_flash_driver:
26+
- source/hic_hal/freescale/iap
27+
28+
tool_specific:
29+
uvision:
30+
misc:
31+
ld_flags:
32+
- --predefine="-I..\..\..\source\hic_hal\freescale\kl27z"
33+
make_armcc:
34+
misc:
35+
ld_flags:
36+
- --predefine="-Isource\hic_hal\freescale\kl27z"

source/board/kl27z_bl.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* @file kl27z_bl.c
3+
* @brief board ID and meta-data for the hardware interface circuit (HIC) based on the NXP KL27Z
4+
*
5+
* DAPLink Interface Firmware
6+
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
7+
* SPDX-License-Identifier: Apache-2.0
8+
*
9+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
10+
* not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
*/
21+
22+
#include "target_config.h"
23+
#include "daplink_addr.h"
24+
#include "compiler.h"
25+
#include "target_board.h"
26+
#include "target_family.h"
27+
28+
// Warning - changing the interface start will break backwards compatibility
29+
COMPILER_ASSERT(DAPLINK_ROM_IF_START == KB(32));
30+
COMPILER_ASSERT(DAPLINK_ROM_IF_SIZE == (KB(128) - KB(32) - KB(1)));
31+
32+
/**
33+
* List of start and size for each size of flash sector
34+
* The size will apply to all sectors between the listed address and the next address
35+
* in the list.
36+
* The last pair in the list will have sectors starting at that address and ending
37+
* at address start + size.
38+
*/
39+
static const sector_info_t sectors_info[] = {
40+
{DAPLINK_ROM_IF_START, 1024},
41+
};
42+
43+
// kl26z128 target information
44+
target_cfg_t target_device = {
45+
.sectors_info = sectors_info,
46+
.sector_info_length = (sizeof(sectors_info))/(sizeof(sector_info_t)),
47+
.flash_regions[0].start = DAPLINK_ROM_IF_START,
48+
.flash_regions[0].end = DAPLINK_ROM_IF_START + DAPLINK_ROM_IF_SIZE,
49+
.flash_regions[0].flags = kRegionIsDefault,
50+
.ram_regions[0].start = 0x1FFFE000,
51+
.ram_regions[0].end = 0x20006000,
52+
};
53+
54+
//bootloader has no family
55+
const target_family_descriptor_t *g_target_family = NULL;
56+
57+
const board_info_t g_board_info = {
58+
.info_version = kBoardInfoVersion,
59+
.board_id = "0000",
60+
.daplink_url_name = "HELP_FAQHTM",
61+
.daplink_drive_name = "MAINTENANCE",
62+
.daplink_target_url = "https://mbed.com/daplink",
63+
.target_cfg = &target_device,
64+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @file microbitv2.c
3+
* @brief board ID for the BBC Microbit board
4+
*
5+
* DAPLink Interface Firmware
6+
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
7+
* SPDX-License-Identifier: Apache-2.0
8+
*
9+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
10+
* not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
*/
21+
#include "fsl_device_registers.h"
22+
#include "IO_Config.h"
23+
#include "DAP.h"
24+
#include "target_family.h"
25+
#include "target_board.h"
26+
27+
const char * const board_id_mb_2_0 = "9903";
28+
29+
extern target_cfg_t target_device_nrf52_64;
30+
31+
// Called in main_task() to init before USB and files are configured
32+
static void prerun_board_config(void) {
33+
target_device = target_device_nrf52_64;
34+
target_device.rt_board_id = board_id_mb_2_0;
35+
}
36+
37+
// USB HID override function return 1 if the activity is trivial or response is null
38+
uint8_t usbd_hid_no_activity(uint8_t *buf)
39+
{
40+
if(buf[0] == ID_DAP_Vendor3 && buf[1] == 0)
41+
return 1;
42+
else
43+
return 0;
44+
}
45+
46+
const board_info_t g_board_info = {
47+
.info_version = kBoardInfoVersion,
48+
.family_id = kNordic_Nrf52_FamilyID,
49+
.daplink_url_name = "MICROBITHTM",
50+
.daplink_drive_name = "MICROBIT",
51+
.daplink_target_url = "https://microbit.org/device/?id=@B&v=@V",
52+
.prerun_board_config = prerun_board_config,
53+
.target_cfg = &target_device,
54+
};

source/daplink/daplink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ COMPILER_ASSERT(DAPLINK_RAM_SHARED_START + DAPLINK_RAM_SHARED_SIZE == DAPLINK_RA
6363
#define DAPLINK_HIC_ID_STM32F103XB 0x97969908
6464
#define DAPLINK_HIC_ID_K26F 0x97969909
6565
#define DAPLINK_HIC_ID_K22F 0x9796990A
66-
#define DAPLINK_HIC_ID_KL27Z 0x9796990B // reserving for future use
66+
#define DAPLINK_HIC_ID_KL27Z 0x9796990B
6767
#define DAPLINK_HIC_ID_LPC54606 0x9796990C // reserving for future use
6868
#define DAPLINK_HIC_ID_STM32F723IE 0x9796990D // reserving for future use
6969
#define DAPLINK_HIC_ID_LPC55S69 0x97969920 // reserving for future use

source/hic_hal/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#if defined (INTERFACE_K20D5) \
2626
|| defined (INTERFACE_K26F) \
2727
|| defined (INTERFACE_KL26Z) \
28+
|| defined (INTERFACE_KL27Z) \
2829
|| defined (INTERFACE_LPC55XX)
2930
#include "fsl_device_registers.h"
3031
#elif defined (INTERFACE_LPC11U35)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @file hic_init.c
3+
* @brief
4+
*
5+
* DAPLink Interface Firmware
6+
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
7+
* Copyright (c) 2016-2017 NXP
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
11+
* not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
23+
#include "fsl_device_registers.h"
24+
25+
/* Enable all clocks needed for USB to function */
26+
void hic_enable_usb_clocks(void)
27+
{
28+
/* Set USB clock to 48 MHz */
29+
SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK | /* MCGPLLCLK used as src */
30+
SIM_SOPT2_PLLFLLSEL_MASK ; /* Select MCGPLLCLK as clock */
31+
SIM->CLKDIV2 &= ~(SIM_CLKDIV2_USBFRAC_MASK | /* Clear CLKDIV2 FS values */
32+
SIM_CLKDIV2_USBDIV_MASK);
33+
SIM->CLKDIV2 = SIM_CLKDIV2_USBDIV(0) ; /* USB clk = (PLL*1/2) */
34+
/* = ( 48*1/1)=48 */
35+
SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK; /* Enable USBOTG clock */
36+
}
37+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @file hic_init.h
3+
* @brief
4+
*
5+
* DAPLink Interface Firmware
6+
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
7+
* Copyright (c) 2016-2017 NXP
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
11+
* not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
23+
#if defined(__cplusplus)
24+
extern "C" {
25+
#endif
26+
27+
//! @brief Enable clocks required for USB operation.
28+
void hic_enable_usb_clocks(void);
29+
30+
#if defined(__cplusplus)
31+
}
32+
#endif

0 commit comments

Comments
 (0)