Large diffs are not rendered by default.

Binary file not shown.
@@ -0,0 +1,5 @@
Debug/delay.c.o: delay.c delay.h types.h

delay.h:

types.h:
Binary file not shown.
@@ -0,0 +1,7 @@
Debug/startup.c.o: startup.c delay.h types.h gpio.h

delay.h:

types.h:

gpio.h:
@@ -0,0 +1 @@
""

Large diffs are not rendered by default.

Binary file not shown.
@@ -0,0 +1,5 @@
Debug/delay.c.o: delay.c delay.h types.h

delay.h:

types.h:
Binary file not shown.
@@ -0,0 +1,7 @@
Debug/startup.c.o: startup.c delay.h types.h gpio.h

delay.h:

types.h:

gpio.h:
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="SysTickInterrupt" Version="10.0.0" InternalType="User templates">
<Plugins>
<Plugin Name="qmake">
<![CDATA[00010001N0005Debug000000000000]]>
</Plugin>
<Plugin Name="CMakePlugin">
<![CDATA[[{
"name": "Debug",
"enabled": false,
"buildDirectory": "build",
"sourceDirectory": "$(ProjectPath)",
"generator": "",
"buildType": "",
"arguments": [],
"parentProject": ""
}]]]>
</Plugin>
</Plugins>
<Description/>
<Dependencies/>
<VirtualDirectory Name="src">
<File Name="startup.c"/>
<File Name="delay.h"/>
<File Name="gpio.h"/>
<File Name="types.h"/>
<File Name="delay.c"/>
</VirtualDirectory>
<VirtualDirectory Name="resources">
<File Name="md407-ram.x"/>
</VirtualDirectory>
<Settings Type="Executable">
<GlobalSettings>
<Compiler Options="" C_Options="" Assembler="">
<IncludePath Value="."/>
</Compiler>
<Linker Options="">
<LibraryPath Value="."/>
</Linker>
<ResourceCompiler Options=""/>
</GlobalSettings>
<Configuration Name="Debug" CompilerType="Cross GCC ( arm-none-eabi )" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
<Compiler Options="-g;-O0;-W" C_Options="-Wa,-adhln=test.s;-g;-O0;-w;-mthumb -march=armv6-m -mfloat-abi=soft;-std=c99;-mthumb;-march=armv6-m" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
<IncludePath Value="."/>
<Preprocessor Value="SIMULATOR"/>
</Compiler>
<Linker Options="-T$(ProjectPath)/md407-ram.x;-L$(ARM_V6LIB) -L$(ARM_GCC_V6LIB);-nostartfiles" Required="yes">
<Library Value="gcc"/>
<Library Value="c_nano"/>
</Linker>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="$(IntermediateDirectory)/$(ProjectName).elf" IntermediateDirectory="./Debug" Command="$(ProjectPath)/$(IntermediateDirectory)/$(ProjectName).elf" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="Default"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[ARM_V6LIB=$(CodeLiteDir)/tools/gcc-arm/arm-none-eabi/lib/thumb/v6-m
ARM_GCC_V6LIB=$(CodeLiteDir)/tools/gcc-arm/lib/gcc/arm-none-eabi/6.3.1/thumb/v6-m
ARM_M4FPLIB=$(CodeLiteDir)/tools/gcc-arm/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard
ARM_GCC_M4FPLIB=$(CodeLiteDir)/tools/gcc-arm/lib/gcc/arm-none-eabi/6.3.1/thumb/v7e-m]]>
</Environment>
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="1234" DebuggerPath="" IsExtended="no">
<DebuggerSearchPaths/>
<PostConnectCommands>load
monitor restart</PostConnectCommands>
<StartupCommands/>
</Debugger>
<PreBuild/>
<PostBuild>
<Command Enabled="yes">arm-none-eabi-objcopy -S -O srec $(IntermediateDirectory)/$(ProjectName).elf $(IntermediateDirectory)/$(ProjectName).s19</Command>
<Command Enabled="yes">arm-none-eabi-objdump -D -S $(IntermediateDirectory)/$(ProjectName).elf &gt; $(IntermediateDirectory)/$(ProjectName).dass</Command>
</PostBuild>
<CustomBuild Enabled="no">
<RebuildCommand/>
<CleanCommand/>
<BuildCommand/>
<PreprocessFileCommand/>
<SingleFileCommand/>
<MakefileGenerationCommand/>
<ThirdPartyToolName>None</ThirdPartyToolName>
<WorkingDirectory/>
</CustomBuild>
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild/>
</AdditionalRules>
<Completion EnableCpp11="no" EnableCpp14="no">
<ClangCmpFlagsC/>
<ClangCmpFlags/>
<ClangPP/>
<SearchPaths/>
</Completion>
</Configuration>
<Configuration Name="Release" CompilerType="Cross GCC ( arm-none-eabi )" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
<Compiler Options="-O2;-W" C_Options="-Wa,-adhln=test.s;-g;-O2;-w;-mthumb -march=armv6-m -mfloat-abi=soft;-std=c99" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
<IncludePath Value="."/>
<Preprocessor Value="NDEBUG"/>
</Compiler>
<Linker Options="-T$(ProjectPath)/md407-ram.x;-L$(ARM_V6LIB) -L$(ARM_GCC_V6LIB);-nostartfiles" Required="yes">
<Library Value="gcc"/>
<Library Value="c_nano"/>
</Linker>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="$(IntermediateDirectory)/$(ProjectName).elf" IntermediateDirectory="./Release" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="Default"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[ARM_V6LIB=$(CodeLiteDir)/tools/gcc-arm/arm-none-eabi/lib/thumb/v6-m
ARM_GCC_V6LIB=$(CodeLiteDir)/tools/gcc-arm/lib/gcc/arm-none-eabi/6.3.1/thumb/v6-m
ARM_M4FPLIB=$(CodeLiteDir)/tools/gcc-arm/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard
ARM_GCC_M4FPLIB=$(CodeLiteDir)/tools/gcc-arm/lib/gcc/arm-none-eabi/6.3.1/thumb/v7e-m]]>
</Environment>
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="1234" DebuggerPath="" IsExtended="no">
<DebuggerSearchPaths/>
<PostConnectCommands>load
monitor restart</PostConnectCommands>
<StartupCommands/>
</Debugger>
<PreBuild/>
<PostBuild>
<Command Enabled="yes">arm-none-eabi-objcopy -S -O srec $(IntermediateDirectory)/$(ProjectName).elf $(IntermediateDirectory)/$(ProjectName).s19</Command>
<Command Enabled="yes">arm-none-eabi-objdump -D -S $(IntermediateDirectory)/$(ProjectName).elf &gt; $(IntermediateDirectory)/$(ProjectName).dass</Command>
</PostBuild>
<CustomBuild Enabled="no">
<RebuildCommand/>
<CleanCommand/>
<BuildCommand/>
<PreprocessFileCommand/>
<SingleFileCommand/>
<MakefileGenerationCommand/>
<ThirdPartyToolName>None</ThirdPartyToolName>
<WorkingDirectory/>
</CustomBuild>
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild/>
</AdditionalRules>
<Completion EnableCpp11="no" EnableCpp14="no">
<ClangCmpFlagsC/>
<ClangCmpFlags/>
<ClangPP/>
<SearchPaths/>
</Completion>
</Configuration>
</Settings>
</CodeLite_Project>
@@ -0,0 +1 @@
./Debug/startup.c.o ./Debug/delay.c.o
@@ -0,0 +1,80 @@
#include "delay.h"

#define STK_CTRL ((volatile unsigned int *)(0xE000E010))
uint8 sysTick_flag = 0;

static volatile uint32 delay_counter;

void delay_250ns( void )
{
uint32 x = 0;
SYS_TICK.CTRL = 0;
SYS_TICK.CTRL_COUNT = 0;
SYS_TICK.VAL = 0;
SYS_TICK.LOAD = 42;
SYS_TICK.CTRL = 0x05;

x = SYS_TICK.VAL;
while (SYS_TICK.CTRL_COUNT & 0x1 == 0)
{
x = SYS_TICK.VAL;
}
SYS_TICK.CTRL = 0;
}

void delay_500ns( void )
{
delay_250ns();
delay_250ns();
}

void delay_micro( uint32_c us )
{
for (uint32 loops = 0; loops < us; loops++ )
{
delay_250ns();
delay_250ns();
delay_250ns();
delay_250ns();
}
}

void delay_milli( uint32 ms )
{
#ifdef SIMULATOR
ms = ms / 1000;
ms++;
#endif // SIMULATOR
delay_micro(ms*1000);
}

//-----------------------------------------------------------------------------------'

void sysTick_irq_handler(void)
{
SYS_TICK.CTRL = 0;
SYS_TICK.CTRL_COUNT = 0;

delay_counter--;
if (delay_counter > 0 ) {
delay_1micro();
} else {
sysTick_flag = 1;
}
}

void delay_1micro(void)
{
SYS_TICK.CTRL = 0;
SYS_TICK.CTRL_COUNT = 0;
SYS_TICK.VAL = 0;
SYS_TICK.LOAD = 167;
SYS_TICK.CTRL = 0x07;
}

void delay(uint8 counter)
{
delay_counter = counter;
sysTick_flag = 0;
delay_1micro();
}
@@ -0,0 +1,31 @@
#ifndef DELAY_H
#define DELAY_H
#include "types.h"

#define SYS_TICK_ADDRESS 0xE000E010
#define ARM_250_CYCLE_TIME 41

extern uint8 sysTick_flag;

typedef struct {
uint8 CTRL;
uint8_c RES_CTRL1;
uint8 CTRL_COUNT;
uint8_c RES_CTRL2;
uint32 LOAD;
uint32 VAL;
} SysTick;

typedef volatile SysTick* SysTickPtr;
#define SYS_TICK (*((SysTickPtr) SYS_TICK_ADDRESS))

void delay_250ns( void );
void delay_500ns( void );
void delay_micro( uint32_c us );
void delay_milli( uint32_c ms );

void sysTick_irq_handler(void);
void delay(uint8 counter);
void delay_1micro(void);

#endif
@@ -0,0 +1,42 @@
#ifndef GPIO_H
#define GPIO_H
#include "types.h"

#define PORT_D 0x40020C00
#define PORT_E 0x40021000

typedef struct {
uint32 MODER;
uint16 OTYPER;
uint16_c RES_OT;
uint32 OSPEEDR;
uint32 PUPDR;
union { uint16 IDR;
struct {
uint8 IDR_LOW;
uint8 IDR_HIGH;
};
};
uint16_c RES_IDR;

union { uint16 ODR;
struct {
uint8 ODR_LOW;
uint8 ODR_HIGH;
};
};
uint16_c RES_ODR;
uint32 BSRR;
uint16 LOCKR;
uint8 LOCKR_16;
uint8_c RES_LOCKR;
uint32 AFR1;
uint32 AFR2;
} gpioPort;

typedef volatile gpioPort* gpioPtr;

#define GPIO_D (*((gpioPtr) PORT_D))
#define GPIO_E (*((gpioPtr) PORT_E))

#endif // GPIO_H
@@ -0,0 +1,28 @@
/*
Default linker script for MD407 (STM32F407)
All code and data goes to RAM.
*/

MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 108K
}

SECTIONS
{
.text :
{
. = ALIGN(4);
*(.start_section) /* startup code */
*(.text) /* remaining code */
*(.text.*)
*(.bss) /* unintialised data */
*(COMMON)
*(.data) /* initialised data */
*(.data.*)
*(.rodata) /* read-only data (constants) */
*(.rodata.*)
. = ALIGN(4);
} >RAM

}
@@ -0,0 +1,54 @@
/*
* startup.c
*
*/

#include "delay.h"
#include "gpio.h"
#include "types.h"

#ifdef SIMULATOR
#define DELAY_COUNT 1000
#else
#define DELAY_COUNT 1000000
#endif

extern uint8 sysTick_flag;

void startup(void) __attribute__((naked)) __attribute__((section (".start_section")) );

void startup ( void )
{
__asm volatile(
" LDR R0,=0x2001C000\n" /* set stack */
" MOV SP,R0\n"
" BL main\n" /* call main */
"_exit: B .\n" /* never return */
);

}


init_app(void) {
GPIO_D.MODER = 0x00005555;

*((void (**) (void)) 0x2001C03C) = sysTick_irq_handler;
}

void main(void)
{
uint8 c = 0;
init_app();
GPIO_D.ODR_LOW = 0x00;
delay(DELAY_COUNT);
GPIO_D.ODR_LOW = 0xFF;
while (1) {
if (sysTick_flag == 1) {
break;
}
GPIO_D.ODR_LOW = c;
c++;
}
GPIO_D.ODR_LOW = 0x0;
}

@@ -0,0 +1,23 @@
#ifndef TYPES_H
#define TYPES_H

#define TRUE 1
#define FALSE 0

typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;

typedef signed int int32;
typedef signed short int16;
typedef signed char int8;

typedef const unsigned int uint32_c;
typedef const unsigned short uint16_c;
typedef const unsigned char uint8_c;

typedef const signed int int32_c;
typedef const signed short int16_c;
typedef const signed char int8_c;

#endif // TYPES_H