Fixing RAM calculator and reduced actual SRAM usage

- Changed static variables to const that should have been const
- Updated CMake files to prepare for MCHCK custom bootloader
- Changed the USB ID numbers and ID number for bootloader
- Only generate DFU or Teensy binary image, not both
- Fixed RAM and FLASH calculator
- Added missing license in delay.c/h (much of it was taken from Teensy source though I've changed a bunch of it)
- Prepared mk20dx.c for upcoming bootloader addition
- mk20dx.h cleanup
- Reduced the MCHCK based flash size for the application image (bootloader changes requires more flash space)
- Fixed bugs in macro.c
- Added keyHold cli command
- Added show pending events debug message for PartialMap macro module
This commit is contained in:
Jacob Alexander 2014-08-15 10:42:12 -07:00
parent 2f7e3cb117
commit eabb1c546a
24 changed files with 418 additions and 110 deletions

View file

@ -34,8 +34,13 @@ set( MCU "${CHIP}" ) # For loading script compatibility
#| Chip Size Database
#| MCHCK Based
if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
set( SIZE_RAM 16384 )
set( SIZE_FLASH 126976 )
#| Teensy 3.0
if ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx128vlf5" )
elseif ( "${CHIP}" MATCHES "mk20dx128" )
set( SIZE_RAM 16384 )
set( SIZE_FLASH 131072 )
@ -84,12 +89,18 @@ message( "${COMPILER_SRCS}" )
#| USB Defines, this is how the loader programs detect which type of chip base is used
if ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" )
set( VENDOR_ID "0x16C0" )
set( PRODUCT_ID "0x0487" )
elseif ( "${CHIP}" MATCHES "mk20dx128vlf5" )
set( VENDOR_ID "0x2323" )
set( PRODUCT_ID "0x0001" )
if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
set( VENDOR_ID "0x1C11" )
set( PRODUCT_ID "0xB04D" )
set( BOOT_VENDOR_ID "0x1C11" )
set( BOOT_PRODUCT_ID "0xB007" )
set( DFU 1 )
elseif ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" )
set( VENDOR_ID "0x1C11" )
set( PRODUCT_ID "0xB04D" )
set( BOOT_VENDOR_ID "0x16c0" ) # TODO Double check, this is likely incorrect
set( BOOT_PRODUCT_ID "0x0487" )
set( TEENSY 1 )
endif ()
@ -98,18 +109,24 @@ endif ()
#| gnu89 = c89 plus GCC extensions
#| c99 = ISO C99 standard (not yet fully implemented)
#| gnu99 = c99 plus GCC extensions
set( CSTANDARD "-std=gnu99" )
#| gnu11 = c11 plus GCC extensions
set( CSTANDARD "-std=gnu11" )
#| Warning Options
#| -Wall...: warning level
set( WARN "-Wall -g" )
set( WARN "-Wall -ggdb3" )
#| Tuning Options
#| -f...: tuning, see GCC manual
#| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin" )
if( BOOTLOADER )
set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin" )
#set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" )
else()
set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" )
endif()
#| Optimization level, can be [0, 1, 2, 3, s].
@ -136,7 +153,14 @@ add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING}
#| Linker Flags
set( LINKER_FLAGS "-mcpu=${CPU} -Wl,-Map=link.map,--cref -Wl,--gc-sections -mthumb -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld -nostartfiles" )
if( BOOTLOADER )
# Bootloader linker flags
set( LINKER_FLAGS "${TUNING} -Wl,--gc-sections -fwhole-program -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld -nostartfiles -Wl,-Map=link.map" )
#set( LINKER_FLAGS "-Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld" )
else()
# Normal linker flags
set( LINKER_FLAGS "-Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld" )
endif()
#| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)

View file

@ -36,6 +36,10 @@ message( STATUS "MCU Selected:" )
message( "${MCU}" )
#| Indicate to later build step that this is a Teensy
set( Teensy )
#| Chip Size Database
#| Teensy 1.0
if ( "${CHIP}" MATCHES "at90usb162" )
@ -80,8 +84,10 @@ message( "${CPU}" )
#| USB Defines
set( VENDOR_ID "0x16C0" )
set( PRODUCT_ID "0x047D" )
set( VENDOR_ID "0x1C11" )
set( PRODUCT_ID "0xB04D" )
set( BOOT_VENDOR_ID "0x16C0" ) # TODO Double check, this is likely incorrect
set( BOOT_PRODUCT_ID "0x047D" )
#| Compiler flag to set the C Standard level.

View file

@ -50,7 +50,7 @@ if ( EXISTS compiler )
endif ()
#| Load the compiler family specific configurations
include( Lib/CMake/${COMPILER_FAMILY}.cmake )
include( ${COMPILER_FAMILY} )
#| Binutils not set by CMake
set( CMAKE_SIZE "${_CMAKE_TOOLCHAIN_PREFIX}size" )

View file

@ -129,6 +129,14 @@ message( "${DEBUG_SRCS}" )
###
# CMake Module Checking
#
find_package( Git REQUIRED )
find_package( Ctags ) # Optional
###
# Generate USB Defines
#
@ -240,13 +248,6 @@ ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
###
# CMake Module Checking
#
find_package( Git REQUIRED )
find_package( Ctags ) # Optional
###
# ctag Generation
#
@ -287,19 +288,23 @@ set_target_properties( ${TARGET_ELF} PROPERTIES
#| Convert the .ELF into a .bin to load onto the McHCK
set( TARGET_BIN ${TARGET}.bin.dfu )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
COMMENT "Creating binary file to load: ${TARGET_BIN}"
)
if( DEFINED DFU )
set( TARGET_BIN ${TARGET}.dfu.bin )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
)
endif()
#| Convert the .ELF into a .HEX to load onto the Teensy
set( TARGET_HEX ${TARGET}.teensy.hex )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
)
if ( DEFINED TEENSY )
set( TARGET_HEX ${TARGET}.teensy.hex )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
)
endif()
#| Generate the Extended .LSS
@ -331,8 +336,8 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
#| After Changes Size Information
add_custom_target( SizeAfter ALL
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ihex ${TARGET_ELF} ${SIZE_RAM} " SRAM"
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ihex ${TARGET_HEX} ${SIZE_FLASH} "Flash"
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ram ${TARGET_ELF} ${SIZE_RAM} " SRAM"
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} flash ${TARGET_ELF} ${SIZE_FLASH} "Flash"
DEPENDS ${TARGET_ELF}
COMMENT "Chip usage for ${CHIP}"
)

View file

@ -2,15 +2,24 @@
#| Jacob Alexander 2014
#| Arg List
#| 1 - size binary (e.g. avr-size)
#| 2 - target binary (e.g. ihex)
#| 2 - measurement type (flash or ram)
#| 3 - binary file (e.g. kiibohd.hex)
#| 4 - total available (flash/ram) in bytes
#| 5 - flash/ram
#| 5 - flash/ram text
# Looks for the data column, to get the flash/ram used (in bytes)
# <size binary> --target=<target binary> <binary file> | cut -f2 | tail -n 1
USED=$("$1" --target="$2" "$3" | cut -f2 | tail -n 1)
case "$2" in
"flash")
USED=$("$1" "$3" | tail -n-1 | awk '{ print $1+$2 }')
;;
"ram")
USED=$("$1" "$3" | tail -n-1 | awk '{ print $2+$3 }')
;;
*)
echo "INVALID Measurement type: $2"
exit 1
esac
# Calculates the total flash/ram used
TOTAL="$4"
@ -35,7 +44,7 @@ fi
# Displays Results
NAME="$5"
echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m ${USED}/${TOTAL}\tbytes"
echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m \t${USED}/${TOTAL}\tbytes"
exit 0

View file

@ -1,15 +1,15 @@
/* Copyright (C) 2013-2014 by Jacob Alexander
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

View file

@ -1,10 +1,50 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Modifications by Jacob Alexander 2013-2014
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// ----- Local Includes -----
#include "delay.h"
#include "mk20dx.h"
// ----- Variables -----
// the systick interrupt is supposed to increment this at 1 kHz rate
volatile uint32_t systick_millis_count = 0;
// ----- Functions -----
void yield(void) {};
uint32_t micros(void)

View file

@ -1,14 +1,53 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Modifications by Jacob Alexander 2013-2014
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __DELAY_H
#define __DELAY_H
// ----- System Includes -----
#include <stdint.h>
// ----- Macros -----
// Convenience Macros, for delay compatibility with AVR-GCC
#define _delay_ms(val) delay( val )
#define _delay_us(val) delayMicroseconds( val )
// ----- Functions -----
// the systick interrupt is supposed to increment this at 1 kHz rate
extern volatile uint32_t systick_millis_count;

View file

@ -31,7 +31,6 @@
// Local Includes
#include "mk20dx.h"
#include <print.h>
@ -45,6 +44,8 @@ extern unsigned long _sbss;
extern unsigned long _ebss;
extern unsigned long _estack;
const uint8_t sys_reset_to_loader_magic[22] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
// ----- Function Declarations -----
@ -354,23 +355,98 @@ const uint8_t flashconfigbytes[16] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
};
#elif defined(_mk20dx128vlf5_) && defined(_bootloader_)
// XXX Byte labels may be in incorrect positions, double check before modifying
// FSEC is in correct location -Jacob
__attribute__ ((section(".flashconfig"), used))
const uint8_t flashconfigbytes[16] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Backdoor Verif Key 28.3.1
0xFF, 0xFF, 0xFF, 0xFF, // Program Flash Protection Bytes FPROT0-3
0xBE, // Flash security byte FSEC
0x03, // Flash nonvolatile option byte FOPT
0xFF, // EEPROM Protection Byte FEPROT
0xFF, // Data Flash Protection Byte FDPROT
};
#endif
// ----- Functions -----
__attribute__((noreturn))
static inline void jump_to_app( uintptr_t addr )
{
// addr is in r0
__asm__("ldr sp, [%[addr], #0]\n"
"ldr pc, [%[addr], #4]"
:: [addr] "r" (addr));
// NOTREACHED
__builtin_unreachable();
}
void *memset( void *addr, int val, unsigned int len )
{
char *buf = addr;
for (; len > 0; --len, ++buf)
*buf = val;
return (addr);
}
int memcmp( const void *a, const void *b, unsigned int len )
{
const uint8_t *ap = a, *bp = b;
int val = 0;
for (; len > 0 && (val = *ap - *bp) == 0; --len, ++ap, ++bp)
/* NOTHING */;
return (val);
}
void *memcpy( void *dst, const void *src, unsigned int len )
{
char *dstbuf = dst;
const char *srcbuf = src;
for (; len > 0; --len, ++dstbuf, ++srcbuf)
*dstbuf = *srcbuf;
return (dst);
}
// ----- Chip Entry Point -----
__attribute__ ((section(".startup")))
void ResetHandler()
{
uint32_t *src = &_etext;
uint32_t *dest = &_sdata;
// Disable Watchdog
WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
WDOG_STCTRLH = WDOG_STCTRLH_ALLOWUPDATE;
#if defined(_mk20dx128vlf5_) && defined(_bootloader_) // Bootloader Section
extern uint32_t _app_rom;
// We treat _app_rom as pointer to directly read the stack
// pointer and check for valid app code. This is no fool
// proof method, but it should help for the first flash.
if ( RCM_SRS0 & 0x40 || _app_rom == 0xffffffff ||
memcmp( (uint8_t*)&VBAT, sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic) ) == 0 ) // Check for soft reload
{
memset( (uint8_t*)&VBAT, 0, sizeof(VBAT) );
}
else
{
uint32_t addr = (uintptr_t)&_app_rom;
SCB_VTOR = addr; // relocate vector table
jump_to_app( addr );
}
#endif
uint32_t *src = &_etext;
uint32_t *dest = &_sdata;
// Enable clocks to always-used peripherals
SIM_SCGC5 = 0x00043F82; // Clocks active to all GPIO
SIM_SCGC6 = SIM_SCGC6_FTM0 | SIM_SCGC6_FTM1 | SIM_SCGC6_ADC0 | SIM_SCGC6_FTFL;
@ -486,11 +562,17 @@ void ResetHandler()
SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_PLLFLLSEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL( 6 );
#endif
#if !defined(_bootloader_)
// Initialize the SysTick counter
SYST_RVR = (F_CPU / 1000) - 1;
SYST_CSR = SYST_CSR_CLKSOURCE | SYST_CSR_TICKINT | SYST_CSR_ENABLE;
__enable_irq();
#else
// Disable Watchdog for bootloader
WDOG_STCTRLH &= ~WDOG_STCTRLH_WDOGEN;
#endif
main();
while ( 1 ); // Shouldn't get here...

View file

@ -1,6 +1,7 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Modified by Jacob Alexander 2014
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -31,12 +32,7 @@
#ifndef _mk20dx_h_
#define _mk20dx_h_
//#define F_CPU 96000000
//#define F_CPU 48000000
//#define F_CPU 24000000
//#define F_BUS 48000000
//#define F_BUS 24000000
//#define F_MEM 24000000
// ----- Defines -----
#if (F_CPU == 96000000)
#define F_BUS 48000000
@ -54,8 +50,16 @@
#define NULL ((void *)0)
#endif
// ----- Includes -----
#include <stdint.h>
// ----- Registers -----
// chapter 11: Port control and interrupts (PORT)
#define PORT_PCR_ISF (uint32_t)0x01000000 // Interrupt Status Flag
#define PORT_PCR_IRQC(n) (uint32_t)(((n) & 15) << 16) // Interrupt Configuration
@ -249,7 +253,7 @@
#define SIM_SOPT1 *(volatile uint32_t *)0x40047000 // System Options Register 1
#define SIM_SOPT1CFG *(volatile uint32_t *)0x40047004 // SOPT1 Configuration Register
#define SIM_SOPT2 *(volatile uint32_t *)0x40048004 // System Options Register 2
#define SIM_SOPT2_USBSRC (uint32_t)0x00040000 // 0=USB_CLKIN, 1=FFL/PLL
#define SIM_SOPT2_USBSRC (uint32_t)0x00040000 // 0=USB_CLKIN, 1=FFL/PLL
#define SIM_SOPT2_PLLFLLSEL (uint32_t)0x00010000 // 0=FLL, 1=PLL
#define SIM_SOPT2_TRACECLKSEL (uint32_t)0x00001000 // 0=MCGOUTCLK, 1=CPU
#define SIM_SOPT2_PTD7PAD (uint32_t)0x00000800 // 0=normal, 1=double drive PTD7
@ -703,7 +707,7 @@
#define MCG_C2 *(volatile uint8_t *)0x40064001 // MCG Control 2 Register
#define MCG_C2_IRCS (uint8_t)0x01 // Internal Reference Clock Select, Selects between the fast or slow internal reference clock source.
#define MCG_C2_LP (uint8_t)0x02 // Low Power Select, Controls whether the FLL or PLL is disabled in BLPI and BLPE modes.
#define MCG_C2_EREFS (uint8_t)0x04 // External Reference Select, Selects the source for the external reference clock.
#define MCG_C2_EREFS (uint8_t)0x04 // External Reference Select, Selects the source for the external reference clock.
#define MCG_C2_HGO0 (uint8_t)0x08 // High Gain Oscillator Select, Controls the crystal oscillator mode of operation
#define MCG_C2_RANGE0(n) (uint8_t)(((n) & 0x03) << 4) // Frequency Range Select, Selects the frequency range for the crystal oscillator
#define MCG_C2_LOCRE0 (uint8_t)0x80 // Loss of Clock Reset Enable, Determines whether an interrupt or a reset request is made following a loss of OSC0
@ -721,7 +725,7 @@
#define MCG_C6 *(volatile uint8_t *)0x40064005 // MCG Control 6 Register
#define MCG_C6_VDIV0(n) (uint8_t)((n) & 0x1F) // VCO 0 Divider
#define MCG_C6_CME0 (uint8_t)0x20 // Clock Monitor Enable
#define MCG_C6_PLLS (uint8_t)0x40 // PLL Select, Controls whether the PLL or FLL output is selected as the MCG source when CLKS[1:0]=00.
#define MCG_C6_PLLS (uint8_t)0x40 // PLL Select, Controls whether the PLL or FLL output is selected as the MCG source when CLKS[1:0]=00.
#define MCG_C6_LOLIE0 (uint8_t)0x80 // Loss of Lock Interrrupt Enable
#define MCG_S *(volatile uint8_t *)0x40064006 // MCG Status Register
#define MCG_S_IRCST (uint8_t)0x01 // Internal Reference Clock Status
@ -1960,8 +1964,32 @@ typedef struct {
// Other
#define VBAT *(volatile uint8_t *)0x4003E000 // Register available in all power states
// ----- Macros -----
#define SOFTWARE_RESET() SCB_AIRCR = 0x5FA0004
// ----- Variables -----
extern const uint8_t sys_reset_to_loader_magic[22];
// ----- Functions -----
void *memset( void *addr, int val, unsigned int len );
void *memcpy( void *dst, const void *src, unsigned int len );
int memcmp( const void *a, const void *b, unsigned int len );
extern int nvic_execution_priority(void);
// ----- Interrupts -----
extern void nmi_isr(void);
extern void hard_fault_isr(void);
extern void memmanage_fault_isr(void);
@ -2053,7 +2081,5 @@ extern void portd_isr(void);
extern void porte_isr(void);
extern void software_isr(void);
#define SOFTWARE_RESET() SCB_AIRCR = 0x5FA0004
#endif

View file

@ -31,7 +31,7 @@
MEMORY
{
FLASH (rx) : ORIGIN = 3K, LENGTH = 128K-3K
FLASH (rx) : ORIGIN = 4K, LENGTH = 128K-4K
RAM (rwx) : ORIGIN = 0x20000000 - 16K / 2, LENGTH = 16K
}