Skip to content

Commit

Permalink
add main.h and SystemFault IRQ files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Rosenau committed May 23, 2023
1 parent 81ca298 commit 2ed6f18
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Debug
/settings
/py-f002-project.dep
Binary file modified README.md
Binary file not shown.
33 changes: 33 additions & 0 deletions inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
///
// basic system macros
//

#ifndef __main_h
#define __main_h

// System Include Files
#include <stddef.h> // offsetof()
#include <stdlib.h> // abs()
#include <stdbool.h> // bool type defined properly whether using C99 or C++
#include <stdio.h> // needed for NULL and debug printf.
#include <string.h> // memset, memcpy
// needed for IAR v8.x+:
#include <intrinsics.h> // including __no_operation()
// CPU specific defines
#include "py32f0xx.h"

///
// @brief DEBUG macros
//
#if defined (DEBUG)
#define DEBUG_BREAK() do { __asm("bkpt #0"); } while(0)
#define DEBUG_NOP() __no_operation()
// helps debugging local function vars in debug mode.
#define STATIC static
#else
#define DEBUG_BREAK()
#define DEBUG_NOP()
#define STATIC
#endif

#endif
3 changes: 1 addition & 2 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdio.h>
#include "py32f0xx.h"
#include "main.h"

void SysTick_Handler()
{
Expand Down
15 changes: 15 additions & 0 deletions py-f002-project.ewp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,15 @@
<name>$PROJ_DIR$\CMSIS\Device\PY32F0xx\Source\system_py32f0xx.c</name>
</file>
</group>
<group>
<name>inc</name>
<file>
<name>$PROJ_DIR$\inc\main.h</name>
</file>
<file>
<name>$PROJ_DIR$\inc\py32f0xx_hal_conf.h</name>
</file>
</group>
<group>
<name>PY32_HAL_driver</name>
<group>
Expand Down Expand Up @@ -1353,6 +1362,12 @@
</file>
</group>
</group>
<group>
<name>src</name>
<file>
<name>$PROJ_DIR$\src\SystemFaultIRQ.c</name>
</file>
</group>
<file>
<name>$PROJ_DIR$\main.c</name>
</file>
Expand Down
15 changes: 15 additions & 0 deletions py-f002-project.ewt
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,15 @@
<name>$PROJ_DIR$\CMSIS\Device\PY32F0xx\Source\system_py32f0xx.c</name>
</file>
</group>
<group>
<name>inc</name>
<file>
<name>$PROJ_DIR$\inc\main.h</name>
</file>
<file>
<name>$PROJ_DIR$\inc\py32f0xx_hal_conf.h</name>
</file>
</group>
<group>
<name>PY32_HAL_driver</name>
<group>
Expand Down Expand Up @@ -1483,6 +1492,12 @@
</file>
</group>
</group>
<group>
<name>src</name>
<file>
<name>$PROJ_DIR$\src\SystemFaultIRQ.c</name>
</file>
</group>
<file>
<name>$PROJ_DIR$\main.c</name>
</file>
Expand Down
27 changes: 13 additions & 14 deletions py-f002-project.eww
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="iso-8859-1"?>

<?xml version="1.0" encoding="UTF-8"?>
<workspace>
<project>
<path>$WS_DIR$\py-f002-project.ewp</path>
</project>
<batchBuild>
<batchDefinition>
<name>all</name>
<member>
<project>py-f002 project</project>
<configuration>Debug</configuration>
</member>
</batchDefinition>
</batchBuild>
<project>
<path>$WS_DIR$\py-f002-project.ewp</path>
</project>
<batchBuild>
<batchDefinition>
<name>all</name>
<member>
<project>py-f002-project</project>
<configuration>Debug</configuration>
</member>
</batchDefinition>
</batchBuild>
</workspace>
20 changes: 20 additions & 0 deletions src/SystemFaultIRQ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
///
// system Fault handlers
//

#include "main.h"

void NMI_Handler(void)
{
DEBUG_BREAK();

exit(ERROR);
}

void HardFault_Handler(void)
{
DEBUG_BREAK();

exit(ERROR);
}

19 changes: 0 additions & 19 deletions src/main.c

This file was deleted.

0 comments on commit 2ed6f18

Please sign in to comment.