Skip to content

Commit 852436e

Browse files
committed
clone kl26 codebase for prepartion as kl27
1 parent 8e7333e commit 852436e

File tree

18 files changed

+10887
-0
lines changed

18 files changed

+10887
-0
lines changed

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/kl26z_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/microbit.c
10+
family:
11+
- source/family/nordic/nrf51822/target_16.c
12+
- source/family/nordic/target_reset_nrf51.c

records/hic_hal/kl27z.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
common:
2+
target:
3+
- mkl26z128xxx4
4+
core:
5+
- Cortex-M0+
6+
macros:
7+
- INTERFACE_KL26Z
8+
- CPU_MKL26Z128VLH4
9+
- DAPLINK_HIC_ID=0x97969901 # DAPLINK_HIC_ID_KL26
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/kl26z
16+
- source/hic_hal/freescale/kl26z/MKL26Z4
17+
- projectfiles/uvision/kl26z_bl/build
18+
sources:
19+
hic_hal:
20+
- source/hic_hal/freescale
21+
- source/hic_hal/freescale/kl26z
22+
- source/hic_hal/freescale/kl26z/MKL26Z4
23+
- source/hic_hal/freescale/kl26z/armcc
24+
fsl_flash_driver:
25+
- source/hic_hal/freescale/iap
26+
27+
tool_specific:
28+
uvision:
29+
misc:
30+
ld_flags:
31+
- --predefine="-I..\..\..\source\hic_hal\freescale\kl26z"
32+
make_armcc:
33+
misc:
34+
ld_flags:
35+
- --predefine="-Isource\hic_hal\freescale\kl26z"

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 kl26z_bl.c
3+
* @brief board ID and meta-data for the hardware interface circuit (HIC) based on the NXP KL26Z
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(95));
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 = 0x1FFFF000,
51+
.ram_regions[0].end = 0x20003000,
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+
};

source/board/microbitv2.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* @file microbit.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_1_3 = "9900";
28+
const char * const board_id_mb_1_5 = "9901";
29+
30+
typedef enum {
31+
BOARD_VERSION_1_3 = 0,
32+
BOARD_VERSION_1_5 = 1,
33+
} mb_version_t;
34+
35+
// Enables Board Type Pin, reads it and disables it
36+
// Depends on gpio_init() to have been executed already
37+
static uint8_t read_board_type_pin(void) {
38+
uint8_t pin_state = 0;
39+
// GPIO mode, Pull enable, pull down, input
40+
PIN_BOARD_TYPE_PORT->PCR[PIN_BOARD_TYPE_BIT] = PORT_PCR_MUX(1) | PORT_PCR_PE(1) | PORT_PCR_PS(0);
41+
PIN_BOARD_TYPE_GPIO->PDDR &= ~PIN_BOARD_TYPE;
42+
// Wait to stabilise, based on gpio.c busy_wait(), at -O2 10000 iterations delay ~850us
43+
for (volatile uint32_t i = 10000; i > 0; i--);
44+
// Read pin
45+
pin_state = (PIN_BOARD_TYPE_GPIO->PDIR & PIN_BOARD_TYPE);
46+
// Revert and disable
47+
PIN_BOARD_TYPE_PORT->PCR[PIN_BOARD_TYPE_BIT] = PORT_PCR_MUX(0) | PORT_PCR_PE(0);
48+
return pin_state;
49+
}
50+
51+
static void set_board_id(mb_version_t board_version) {
52+
switch (board_version) {
53+
case BOARD_VERSION_1_3:
54+
target_device.rt_board_id = board_id_mb_1_3;
55+
break;
56+
case BOARD_VERSION_1_5:
57+
target_device.rt_board_id = board_id_mb_1_5;
58+
break;
59+
default:
60+
target_device.rt_board_id = board_id_mb_1_5;
61+
break;
62+
}
63+
}
64+
65+
// Called in main_task() to init before USB and files are configured
66+
static void prerun_board_config(void) {
67+
// With only two boards the digital pin read maps directly to the type
68+
mb_version_t board_version = (mb_version_t)read_board_type_pin();
69+
set_board_id(board_version);
70+
}
71+
72+
// USB HID override function return 1 if the activity is trivial or response is null
73+
uint8_t usbd_hid_no_activity(uint8_t *buf)
74+
{
75+
if(buf[0] == ID_DAP_Vendor3 && buf[1] == 0)
76+
return 1;
77+
else
78+
return 0;
79+
}
80+
81+
const board_info_t g_board_info = {
82+
.info_version = kBoardInfoVersion,
83+
.family_id = kNordic_Nrf51_FamilyID,
84+
.daplink_url_name = "MICROBITHTM",
85+
.daplink_drive_name = "MICROBIT ",
86+
.daplink_target_url = "https://microbit.org/device/?id=@B&v=@V",
87+
.prerun_board_config = prerun_board_config,
88+
.target_cfg = &target_device,
89+
};

0 commit comments

Comments
 (0)