Skip to content

Commit

Permalink
Update example project to handle pointers of different sizes and not …
Browse files Browse the repository at this point in the history
…complain on modern platforms.
  • Loading branch information
mvandervoord committed Apr 2, 2024
1 parent ecaccb4 commit 93e2f52
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 26 deletions.
25 changes: 13 additions & 12 deletions examples/temp_sensor/src/AT91SAM7X256.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@
#define AT91SAM7X256_H

typedef volatile unsigned int AT91_REG;// Hardware register definition
typedef volatile void* AT91_PTR;// Hardware register pointer

// *****************************************************************************
// SOFTWARE API DEFINITION FOR System Peripherals
// *****************************************************************************
typedef struct _AT91S_SYS {
AT91_REG AIC_SMR[32]; // Source Mode Register
AT91_REG AIC_SVR[32]; // Source Vector Register
AT91_REG AIC_IVR; // IRQ Vector Register
AT91_REG AIC_FVR; // FIQ Vector Register
AT91_PTR AIC_SVR[32]; // Source Vector Register
AT91_PTR AIC_IVR; // IRQ Vector Register
AT91_PTR AIC_FVR; // FIQ Vector Register
AT91_REG AIC_ISR; // Interrupt Status Register
AT91_REG AIC_IPR; // Interrupt Pending Register
AT91_REG AIC_IMR; // Interrupt Mask Register
Expand All @@ -64,7 +65,7 @@ typedef struct _AT91S_SYS {
AT91_REG AIC_ICCR; // Interrupt Clear Command Register
AT91_REG AIC_ISCR; // Interrupt Set Command Register
AT91_REG AIC_EOICR; // End of Interrupt Command Register
AT91_REG AIC_SPU; // Spurious Vector Register
AT91_PTR AIC_SPU; // Spurious Vector Register
AT91_REG AIC_DCR; // Debug Control Register (Protect)
AT91_REG Reserved1[1]; //
AT91_REG AIC_FFER; // Fast Forcing Enable Register
Expand Down Expand Up @@ -214,9 +215,9 @@ typedef struct _AT91S_SYS {
// *****************************************************************************
typedef struct _AT91S_AIC {
AT91_REG AIC_SMR[32]; // Source Mode Register
AT91_REG AIC_SVR[32]; // Source Vector Register
AT91_REG AIC_IVR; // IRQ Vector Register
AT91_REG AIC_FVR; // FIQ Vector Register
AT91_PTR AIC_SVR[32]; // Source Vector Register
AT91_PTR AIC_IVR; // IRQ Vector Register
AT91_PTR AIC_FVR; // FIQ Vector Register
AT91_REG AIC_ISR; // Interrupt Status Register
AT91_REG AIC_IPR; // Interrupt Pending Register
AT91_REG AIC_IMR; // Interrupt Mask Register
Expand All @@ -227,7 +228,7 @@ typedef struct _AT91S_AIC {
AT91_REG AIC_ICCR; // Interrupt Clear Command Register
AT91_REG AIC_ISCR; // Interrupt Set Command Register
AT91_REG AIC_EOICR; // End of Interrupt Command Register
AT91_REG AIC_SPU; // Spurious Vector Register
AT91_PTR AIC_SPU; // Spurious Vector Register
AT91_REG AIC_DCR; // Debug Control Register (Protect)
AT91_REG Reserved1[1]; //
AT91_REG AIC_FFER; // Fast Forcing Enable Register
Expand Down Expand Up @@ -1727,14 +1728,14 @@ typedef struct _AT91S_ADC {
#define AT91C_AIC_EOICR ((AT91_REG *) 0xFFFFF130) // (AIC) End of Interrupt Command Register
#define AT91C_AIC_DCR ((AT91_REG *) 0xFFFFF138) // (AIC) Debug Control Register (Protect)
#define AT91C_AIC_FFER ((AT91_REG *) 0xFFFFF140) // (AIC) Fast Forcing Enable Register
#define AT91C_AIC_SVR ((AT91_REG *) 0xFFFFF080) // (AIC) Source Vector Register
#define AT91C_AIC_SPU ((AT91_REG *) 0xFFFFF134) // (AIC) Spurious Vector Register
#define AT91C_AIC_SVR ((AT91_PTR *) 0xFFFFF080) // (AIC) Source Vector Register
#define AT91C_AIC_SPU ((AT91_PTR *) 0xFFFFF134) // (AIC) Spurious Vector Register
#define AT91C_AIC_FFDR ((AT91_REG *) 0xFFFFF144) // (AIC) Fast Forcing Disable Register
#define AT91C_AIC_FVR ((AT91_REG *) 0xFFFFF104) // (AIC) FIQ Vector Register
#define AT91C_AIC_FVR ((AT91_PTR *) 0xFFFFF104) // (AIC) FIQ Vector Register
#define AT91C_AIC_FFSR ((AT91_REG *) 0xFFFFF148) // (AIC) Fast Forcing Status Register
#define AT91C_AIC_IMR ((AT91_REG *) 0xFFFFF110) // (AIC) Interrupt Mask Register
#define AT91C_AIC_ISR ((AT91_REG *) 0xFFFFF108) // (AIC) Interrupt Status Register
#define AT91C_AIC_IVR ((AT91_REG *) 0xFFFFF100) // (AIC) IRQ Vector Register
#define AT91C_AIC_IVR ((AT91_PTR *) 0xFFFFF100) // (AIC) IRQ Vector Register
#define AT91C_AIC_IDCR ((AT91_REG *) 0xFFFFF124) // (AIC) Interrupt Disable Command Register
#define AT91C_AIC_CISR ((AT91_REG *) 0xFFFFF114) // (AIC) Core Interrupt Status Register
#define AT91C_AIC_IPR ((AT91_REG *) 0xFFFFF10C) // (AIC) Interrupt Pending Register
Expand Down
2 changes: 1 addition & 1 deletion examples/temp_sensor/src/TimerInterruptConfigurator.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Timer_EnableInterrupt(void)

static inline void SetInterruptHandler(void)
{
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = (uint32)Timer_InterruptHandler;
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = Timer_InterruptHandler;
}

static inline void ConfigureInterruptSourceModeRegister(void)
Expand Down
54 changes: 51 additions & 3 deletions examples/temp_sensor/targets/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ compiler:
prefix: '-D'
items:
- __monitor
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
Expand All @@ -36,9 +37,56 @@ linker:
extension: '.exe'
destination: *build_path
:cmock:
:plugins: []
:includes:
# Core conffiguration
:plugins: [] # What plugins should be used by CMock?
:verbosity: 2 # the options being 0 errors only, 1 warnings and errors, 2 normal info, 3 verbose
:when_no_prototypes: :warn # the options being :ignore, :warn, or :erro

# File configuration
:mock_path: './build/mocks' # Subdirectory to store mocks when generated (default: mocks)
:skeleton_path: '' # Subdirectory to store stubs when generated (default: '')
:subdir: nil # Subdirectory under mock_path to store when generated (default: nil)
:mock_prefix: 'Mock' # Prefix to append to filenames for mocks
:mock_suffix: '' # Suffix to append to filenames for mocks

# Parser configuration
:strippables: ['(?:__attribute__\s*\([ (]*.*?[ )]*\)+)']
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude # the options being :include or :exclud
:treat_inlines: :exclude # the options being :include or :exclud

# Type handling configuration
#:unity_helper_path: '' # specify a string of where to find a unity_helper.h file to discover custom type assertions
#:treat_as: {} # optionally add additional types to map custom types
#:treat_as_array: {} # hint to cmock that these types are pointers to something
#:treat_as_void: [] # hint to cmock that these types are actually aliases of void
:memcmp_if_unknown: true # allow cmock to use the memory comparison assertions for unknown types
:when_ptr: :compare_data # hint to cmock how to handle pointers in general, the options being :compare_ptr, :compare_data, or :smart

# Mock generation configuration
:weak: '' # Symbol to use to declare weak functions
:enforce_strict_ordering: false # Do we want cmock to enforce ordering of all function calls?
:fail_on_unexpected_calls: true # Do we want cmock to fail when it encounters a function call that wasn't expected?
:callback_include_count: true # Do we want cmock to include the number of calls to this callback, when using callbacks?
:callback_after_arg_check: false # Do we want cmock to enforce an argument check first when using a callback?
:includes: # You can add additional includes here, or specify the location with the options below
- Types.h
:mock_path: ./build/mocks
:includes_h_pre_orig_header: nil
:includes_h_post_orig_header: nil
:includes_c_pre_header: nil
:includes_c_post_header: nil
:orig_header_include_fmt: '#include "%s"'
:array_size_type: [] # Specify a type or types that should be used for array lengths
:array_size_name: 'size|len' # Specify a name or names that CMock might automatically recognize as the length of an array
:exclude_setjmp_h: false # Don't use setjmp when running CMock. Note that this might result in late reporting or out-of-order failures.

colour: true
54 changes: 50 additions & 4 deletions examples/temp_sensor/targets/iar_v4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,54 @@ simulator:
- -d
- sim
:cmock:
:plugins: []
:includes:
- Types.h
:mock_path: ./build/mocks
# Core conffiguration
:plugins: [] # What plugins should be used by CMock?
:verbosity: 2 # the options being 0 errors only, 1 warnings and errors, 2 normal info, 3 verbose
:when_no_prototypes: :warn # the options being :ignore, :warn, or :erro

# File configuration
:mock_path: './build/mocks' # Subdirectory to store mocks when generated (default: mocks)
:skeleton_path: './' # Subdirectory to store stubs when generated (default: '')
:subdir: nil # Subdirectory under mock_path to store when generated (default: nil)
:mock_prefix: 'Mock' # Prefix to append to filenames for mocks
:mock_suffix: '' # Suffix to append to filenames for mocks

# Parser configuration
:strippables: ['(?:__attribute__\s*\([ (]*.*?[ )]*\)+)']
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude # the options being :include or :exclud
:treat_inlines: :exclude # the options being :include or :exclud

# Type handling configuration
#:unity_helper_path: '' # specify a string of where to find a unity_helper.h file to discover custom type assertions
#:treat_as: {} # optionally add additional types to map custom types
#:treat_as_array: {} # hint to cmock that these types are pointers to something
#:treat_as_void: [] # hint to cmock that these types are actually aliases of void
:memcmp_if_unknown: true # allow cmock to use the memory comparison assertions for unknown types
:when_ptr: :compare_data # hint to cmock how to handle pointers in general, the options being :compare_ptr, :compare_data, or :smart

# Mock generation configuration
:weak: '' # Symbol to use to declare weak functions
:enforce_strict_ordering: false # Do we want cmock to enforce ordering of all function calls?
:fail_on_unexpected_calls: true # Do we want cmock to fail when it encounters a function call that wasn't expected?
:callback_include_count: true # Do we want cmock to include the number of calls to this callback, when using callbacks?
:callback_after_arg_check: false # Do we want cmock to enforce an argument check first when using a callback?
:includes: # You can add additional includes here, or specify the location with the options below
- Types.h
:includes_h_pre_orig_header: nil
:includes_h_post_orig_header: nil
:includes_c_pre_header: nil
:includes_c_post_header: nil
:orig_header_include_fmt: '#include "%s"'
:array_size_type: [] # Specify a type or types that should be used for array lengths
:array_size_name: 'size|len' # Specify a name or names that CMock might automatically recognize as the length of an array
:exclude_setjmp_h: false # Don't use setjmp when running CMock. Note that this might result in late reporting or out-of-order failures.
54 changes: 50 additions & 4 deletions examples/temp_sensor/targets/iar_v5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,54 @@ simulator:
- -d
- sim
:cmock:
:plugins: []
:includes:
- Types.h
:mock_path: ./build/mocks
# Core conffiguration
:plugins: [] # What plugins should be used by CMock?
:verbosity: 2 # the options being 0 errors only, 1 warnings and errors, 2 normal info, 3 verbose
:when_no_prototypes: :warn # the options being :ignore, :warn, or :erro

# File configuration
:mock_path: './build/mocks' # Subdirectory to store mocks when generated (default: mocks)
:skeleton_path: '' # Subdirectory to store stubs when generated (default: '')
:subdir: nil # Subdirectory under mock_path to store when generated (default: nil)
:mock_prefix: 'Mock' # Prefix to append to filenames for mocks
:mock_suffix: '' # Suffix to append to filenames for mocks

# Parser configuration
:strippables: ['(?:__attribute__\s*\([ (]*.*?[ )]*\)+)']
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude # the options being :include or :exclud
:treat_inlines: :exclude # the options being :include or :exclud

# Type handling configuration
#:unity_helper_path: '' # specify a string of where to find a unity_helper.h file to discover custom type assertions
#:treat_as: {} # optionally add additional types to map custom types
#:treat_as_array: {} # hint to cmock that these types are pointers to something
#:treat_as_void: [] # hint to cmock that these types are actually aliases of void
:memcmp_if_unknown: true # allow cmock to use the memory comparison assertions for unknown types
:when_ptr: :compare_data # hint to cmock how to handle pointers in general, the options being :compare_ptr, :compare_data, or :smart

# Mock generation configuration
:weak: '' # Symbol to use to declare weak functions
:enforce_strict_ordering: false # Do we want cmock to enforce ordering of all function calls?
:fail_on_unexpected_calls: true # Do we want cmock to fail when it encounters a function call that wasn't expected?
:callback_include_count: true # Do we want cmock to include the number of calls to this callback, when using callbacks?
:callback_after_arg_check: false # Do we want cmock to enforce an argument check first when using a callback?
:includes: # You can add additional includes here, or specify the location with the options below
- Types.h
:includes_h_pre_orig_header: nil
:includes_h_post_orig_header: nil
:includes_c_pre_header: nil
:includes_c_post_header: nil
:orig_header_include_fmt: '#include "%s"'
:array_size_type: [] # Specify a type or types that should be used for array lengths
:array_size_name: 'size|len' # Specify a name or names that CMock might automatically recognize as the length of an array
:exclude_setjmp_h: false # Don't use setjmp when running CMock. Note that this might result in late reporting or out-of-order failures.
4 changes: 2 additions & 2 deletions examples/temp_sensor/test/TestTimerInterruptConfigurator.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void testResetSystemTimeDelegatesTo_Timer_SetSystemTime_Appropriately(void)

void testConfigureInterruptShouldSetInterruptHandlerAppropriately(void)
{
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = (uint32)0;
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = 0;
Timer_ConfigureInterrupt();
TEST_ASSERT_EQUAL((uint32)Timer_InterruptHandler, AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0]);
TEST_ASSERT_EQUAL_PTR(Timer_InterruptHandler, AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0]);
}

void testConfigureInterruptShouldSetInterruptLevelInSourceModeRegisterAppropriately(void)
Expand Down

0 comments on commit 93e2f52

Please sign in to comment.