Skip to content

Commit 12d907c

Browse files
authored
Merge pull request #7 from harp-tech/as-update-core-1.13
Update files to core 1.13
2 parents fb6c727 + 09b0502 commit 12d907c

8 files changed

Lines changed: 182 additions & 100 deletions

File tree

Firmware/LedArray/LedArray.cproj

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -76,77 +76,75 @@
7676
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
7777
<ToolchainSettings>
7878
<AvrGcc>
79-
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
80-
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
81-
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
82-
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
83-
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
84-
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
85-
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
86-
<avrgcc.compiler.symbols.DefSymbols>
87-
<ListValues>
88-
<Value>NDEBUG</Value>
89-
</ListValues>
90-
</avrgcc.compiler.symbols.DefSymbols>
91-
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
92-
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
93-
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
94-
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
95-
<avrgcc.linker.libraries.Libraries>
96-
<ListValues>
97-
<Value>libm</Value>
98-
<Value>libATxmega64A4U-1.4.a</Value>
99-
</ListValues>
100-
</avrgcc.linker.libraries.Libraries>
101-
<avrgcc.linker.libraries.LibrarySearchPaths>
102-
<ListValues>
103-
<Value>C:\Users\CR Filipe\Google Drive CR Filipe\CR harp\firmware LED array - interface\v1.0</Value>
104-
<Value>C:\Users\Artur\Google Drive\CR harp\firmware LED array - interface\v1.0</Value>
105-
<Value>G:\My Drive\CR harp\firmware LED array - interface\v1.0</Value>
106-
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Firmware\LedArray</Value>
107-
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LedArray\Firmware\LedArray</Value>
108-
</ListValues>
109-
</avrgcc.linker.libraries.LibrarySearchPaths>
110-
</AvrGcc>
79+
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
80+
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
81+
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
82+
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
83+
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
84+
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
85+
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
86+
<avrgcc.compiler.symbols.DefSymbols>
87+
<ListValues>
88+
<Value>NDEBUG</Value>
89+
</ListValues>
90+
</avrgcc.compiler.symbols.DefSymbols>
91+
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
92+
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
93+
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
94+
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
95+
<avrgcc.linker.libraries.Libraries>
96+
<ListValues>
97+
<Value>libm</Value>
98+
<Value>libATxmega64A4U-1.4.a</Value>
99+
<Value>libATxmega64A4U-1.13.a</Value>
100+
</ListValues>
101+
</avrgcc.linker.libraries.Libraries>
102+
<avrgcc.linker.libraries.LibrarySearchPaths>
103+
<ListValues>
104+
<Value>C:\Users\CR Filipe\Google Drive CR Filipe\CR harp\firmware LED array - interface\v1.0</Value>
105+
<Value>C:\Users\Artur\Google Drive\CR harp\firmware LED array - interface\v1.0</Value>
106+
<Value>G:\My Drive\CR harp\firmware LED array - interface\v1.0</Value>
107+
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Firmware\LedArray</Value>
108+
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LedArray\Firmware\LedArray</Value>
109+
<Value>C:\Users\Artur Silva\Desktop\device.ledarray-main (1)\device.ledarray-main\Firmware\LedArray</Value>
110+
</ListValues>
111+
</avrgcc.linker.libraries.LibrarySearchPaths>
112+
</AvrGcc>
111113
</ToolchainSettings>
112114
</PropertyGroup>
113115
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
114116
<ToolchainSettings>
115117
<AvrGcc>
116-
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
117-
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
118-
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
119-
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
120-
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
121-
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
122-
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
123-
<avrgcc.compiler.symbols.DefSymbols>
124-
<ListValues>
125-
<Value>DEBUG</Value>
126-
</ListValues>
127-
</avrgcc.compiler.symbols.DefSymbols>
128-
<avrgcc.compiler.optimization.level>Optimize most (-O3)</avrgcc.compiler.optimization.level>
129-
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
130-
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
131-
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
132-
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
133-
<avrgcc.linker.libraries.Libraries>
134-
<ListValues>
135-
<Value>libm</Value>
136-
<Value>libATxmega64A4U-1.4.a</Value>
137-
</ListValues>
138-
</avrgcc.linker.libraries.Libraries>
139-
<avrgcc.linker.libraries.LibrarySearchPaths>
140-
<ListValues>
141-
<Value>C:\Users\CR Filipe\Google Drive CR Filipe\CR harp\firmware LED array - interface\v1.0</Value>
142-
<Value>C:\Users\Artur\Google Drive\CR harp\firmware LED array - interface\v1.0</Value>
143-
<Value>G:\My Drive\CR harp\firmware LED array - interface\v1.0</Value>
144-
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Firmware\LedArray</Value>
145-
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LedArray\Firmware\LedArray</Value>
146-
</ListValues>
147-
</avrgcc.linker.libraries.LibrarySearchPaths>
148-
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
149-
</AvrGcc>
118+
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
119+
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
120+
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
121+
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
122+
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
123+
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
124+
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
125+
<avrgcc.compiler.symbols.DefSymbols>
126+
<ListValues>
127+
<Value>DEBUG</Value>
128+
</ListValues>
129+
</avrgcc.compiler.symbols.DefSymbols>
130+
<avrgcc.compiler.optimization.level>Optimize most (-O3)</avrgcc.compiler.optimization.level>
131+
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
132+
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
133+
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
134+
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
135+
<avrgcc.linker.libraries.Libraries>
136+
<ListValues>
137+
<Value>libm</Value>
138+
<Value>libATxmega64A4U-1.13.a</Value>
139+
</ListValues>
140+
</avrgcc.linker.libraries.Libraries>
141+
<avrgcc.linker.libraries.LibrarySearchPaths>
142+
<ListValues>
143+
<Value>..</Value>
144+
</ListValues>
145+
</avrgcc.linker.libraries.LibrarySearchPaths>
146+
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
147+
</AvrGcc>
150148
</ToolchainSettings>
151149
</PropertyGroup>
152150
<ItemGroup>

Firmware/LedArray/app.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ void hwbp_app_initialize(void)
5656
(uint8_t*)(&app_regs),
5757
APP_NBYTES_OF_REG_BANK,
5858
APP_REGS_ADD_MAX - APP_REGS_ADD_MIN + 1,
59-
default_device_name
59+
default_device_name,
60+
false, // The device is _not_ able to repeat the harp timestamp clock
61+
false, // The device is _not_ able to generate the harp timestamp clock
62+
0
6063
);
6164
}
6265

@@ -201,7 +204,9 @@ bool write_SMBus_word(uint8_t add, uint8_t reg, int16_t word)
201204
bool SMBus_exist_on_bus0 = false;
202205
bool SMBus_exist_on_bus1 = false;
203206

204-
void core_callback_1st_config_hw_after_boot(void)
207+
void core_callback_define_clock_default(void) {}
208+
209+
void core_callback_initialize_hardware(void)
205210
{
206211
/* Initialize IOs */
207212
/* Don't delete this function!!! */
@@ -436,6 +441,14 @@ void core_callback_t_1ms(void)
436441
}
437442
}
438443

444+
/************************************************************************/
445+
/* Callbacks: clock control */
446+
/************************************************************************/
447+
void core_callback_clock_to_repeater(void) {}
448+
void core_callback_clock_to_generator(void) {}
449+
void core_callback_clock_to_unlock(void) {}
450+
void core_callback_clock_to_lock(void) {}
451+
439452
/************************************************************************/
440453
/* Callbacks: uart control */
441454
/************************************************************************/

Firmware/LedArray/cpu.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ void timer_type1_wait(TC1_t* timer, uint8_t prescaler, uint16_t target_count);
142142
/************************************************************************/
143143
/* EEPROM */
144144
/************************************************************************/
145+
bool eeprom_is_busy(void);
146+
145147
uint8_t eeprom_rd_byte(uint16_t addr);
146148
void eeprom_wr_byte(uint16_t addr, uint8_t byte);
147149

@@ -171,6 +173,10 @@ int32_t eeprom_rd_i32(uint16_t addr);
171173
#define PRESCALER_ADC_DIV256 ADC_PRESCALER_DIV256_gc
172174
#define PRESCALER_ADC_DIV512 ADC_PRESCALER_DIV512_gc
173175

176+
void adc_A_initialize_single_ended(uint8_t analog_reference);
177+
int16_t adc_A_read_channel(uint8_t index);
178+
void adc_A_calibrate_offset(uint8_t index);
179+
174180
uint16_t adcA_unsigned_single_ended(ADC_t* adc, uint8_t res, uint8_t ref , uint8_t prescaler, uint8_t adc_pin, TC0_t* timer);
175181

176182
#endif /* _CPU_1V1_H_ */

Firmware/LedArray/hwbp_core.h

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ typedef struct {
1818
uint16_t usecond;
1919
} timestamp_t;
2020

21+
// Used to define the clock direction default of the device.
22+
void core_callback_define_clock_default(void);
23+
2124
// It's the first callback used, right after booting the core.
2225
// The pins, ports and external hardware should be initialized.
23-
void core_callback_1st_config_hw_after_boot(void);
26+
void core_callback_initialize_hardware(void);
2427

2528
// Used to initialize the registers.
2629
// All registers should be written to their default state.
@@ -43,7 +46,6 @@ void core_callback_device_to_active(void);
4346
void core_callback_device_to_speed(void);
4447

4548

46-
4749
// Called before execute the timer interrupts
4850
void core_callback_t_before_exec(void);
4951
// Called after execute the timer interrupts
@@ -57,7 +59,6 @@ void core_callback_t_500us(void);
5759
void core_callback_t_new_second(void);
5860

5961

60-
6162
// Read from an application register.
6263
bool core_read_app_register(uint8_t add, uint8_t type);
6364
// Write to an application register.
@@ -68,6 +69,48 @@ bool hwbp_read_common_reg(uint8_t add, uint8_t type);
6869
bool hwbp_write_common_reg(uint8_t add, uint8_t type, uint8_t * content, uint16_t n_elements);
6970

7071

72+
/************************************************************************/
73+
/* Register RESET_APP */
74+
/************************************************************************/
75+
// Write to common register RESET_APP.
76+
bool hwbp_write_common_reg_RESET_APP(void *a);
77+
78+
// Used to save all registers to non-volatile memory
79+
bool core_save_all_registers_to_eeprom(void);
80+
81+
82+
/************************************************************************/
83+
/* Register CONFIG */
84+
/************************************************************************/
85+
// Write to common register CONFIG.
86+
bool hwbp_write_common_reg_CONFIG(void *a);
87+
// Read from common register CONFIG.
88+
void hwbp_read_common_reg_CONFIG(void);
89+
90+
// Called when the application should configure the hardware to repeat the harp timestamp clock input.
91+
void core_callback_clock_to_repeater(void);
92+
// Called when the application should configure the hardware to generate the harp timestamp clock.
93+
void core_callback_clock_to_generator(void);
94+
// Called when the timestamp lock is changed to unlocked.
95+
void core_callback_clock_to_unlock(void);
96+
// Called when the timestamp lock is changed to locked.
97+
void core_callback_clock_to_lock(void);
98+
99+
// Used to know if the device is repeating the harp timestamp clock
100+
bool core_bool_device_is_repeater(void);
101+
// Used to know if the device is generating the harp timestamp clock
102+
bool core_bool_device_is_generator(void);
103+
// Used to check if the timestamp register is locked
104+
bool core_bool_clock_is_locked(void);
105+
106+
// Used to set the device as a repeater
107+
bool core_device_to_clock_repeater(void);
108+
// Used to set the device as a generator
109+
bool core_device_to_clock_generator(void);
110+
// Used to lock the timestamp register
111+
bool core_clock_to_lock(void);
112+
// Used to unlock the timestamp register
113+
bool core_clock_to_unlock(void);
71114

72115

73116
// It is mandatory that this function is the first of the application code.
@@ -81,7 +124,11 @@ void core_func_start_core (
81124
uint8_t *pointer_to_app_regs,
82125
const uint16_t app_mem_size_to_save,
83126
const uint8_t num_of_app_registers,
84-
const uint8_t *device_name);
127+
const uint8_t *device_name,
128+
const bool device_is_able_to_repeat_clock,
129+
const bool device_is_able_to_generate_clock,
130+
const uint8_t default_timestamp_offset
131+
);
85132

86133
// Call this function in case of error
87134
// A power up or reset must be performed to remove the device from this state
@@ -113,6 +160,7 @@ uint16_t core_func_read_R_TIMESTAMP_MICRO(void);
113160

114161

115162

163+
116164
// Return "true" if the LEDs can be ON.
117165
bool core_bool_is_visual_enabled(void);
118166
// Return "true" if the device is in Speed Mode.

Firmware/LedArray/hwbp_core_regs.h

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,59 @@
66
/* Common Bank Registers */
77
/************************************************************************/
88
/* Registers */
9-
#define ADD_R_WHO_AM_I 0x00 // U16
10-
#define ADD_R_HW_VERSION_H 0x01 // U8
11-
#define ADD_R_HW_VERSION_L 0x02 // U8
12-
#define ADD_R_ASSEMBLY_VERSION 0x03 // U8
13-
#define ADD_R_HARP_VERSION_H 0x04 // U8
14-
#define ADD_R_HARP_VERSION_L 0x05 // U8
15-
#define ADD_R_FW_VERSION_H 0x06 // U8
16-
#define ADD_R_FW_VERSION_L 0x07 // U8
17-
#define ADD_R_TIMESTAMP_SECOND 0x08 // U32
18-
#define ADD_R_TIMESTAMP_MICRO 0x09 // U16
19-
#define ADD_R_OPERATION_CTRL 0x0A // U8
20-
#define ADD_R_RESET_DEV 0x0B // U8
9+
#define ADD_R_WHO_AM_I 0x00 // U16
10+
#define ADD_R_HW_VERSION_H 0x01 // U8
11+
#define ADD_R_HW_VERSION_L 0x02 // U8
12+
#define ADD_R_ASSEMBLY_VERSION 0x03 // U8
13+
#define ADD_R_CORE_VERSION_H 0x04 // U8
14+
#define ADD_R_CORE_VERSION_L 0x05 // U8
15+
#define ADD_R_FW_VERSION_H 0x06 // U8
16+
#define ADD_R_FW_VERSION_L 0x07 // U8
17+
#define ADD_R_TIMESTAMP_SECOND 0x08 // U32
18+
#define ADD_R_TIMESTAMP_MICRO 0x09 // U16
19+
#define ADD_R_OPERATION_CTRL 0x0A // U8
20+
#define ADD_R_RESET_DEV 0x0B // U8
21+
#define ADD_R_DEVICE_NAME 0x0C // U8
22+
#define ADD_R_SERIAL_NUMBER 0x0D // U16
23+
#define ADD_R_CONFIG 0x0E // U8
24+
#define ADD_R_TIMESTAMP_OFFSET 0x0F // U8
2125

2226
/* Memory limits */
23-
#define COMMON_BANK_ADD_MIN 0x00
24-
#define COMMON_BANK_ADD_MAX 0x0B
25-
#define COMMON_BANK_ABSOLUTE_ADD_MAX 0x1C
27+
#define COMMON_BANK_ADD_MAX 0x0F
28+
#define COMMON_BANK_ABSOLUTE_ADD_MAX 0x1C
2629

2730
/* R_OPERATION_CTRL */
28-
#define MSK_OP_MODE (3<<0)
31+
#define MSK_OP_MODE (3<<0)
2932

30-
#define GM_OP_MODE_STANDBY (0<<0)
31-
#define GM_OP_MODE_ACTIVE (1<<0)
32-
#define GM_OP_MODE_SPEED (3<<0)
33+
#define GM_OP_MODE_STANDBY (0<<0)
34+
#define GM_OP_MODE_ACTIVE (1<<0)
35+
#define GM_OP_MODE_SPEED (3<<0)
3336

34-
#define B_VISUALEN (1<<5)
35-
#define B_OPLEDEN (1<<6)
37+
#define B_DUMP (1<<3)
38+
#define B_MUTE_RPL (1<<4)
39+
#define B_VISUALEN (1<<5)
40+
#define B_OPLEDEN (1<<6)
41+
#define B_ALIVE_EN (1<<7)
3642

3743
/* ADD_R_MEMORY */
38-
#define B_RST_DEF (1<<0)
39-
#define B_RST_EE (1<<1)
44+
#define B_RST_DEF (1<<0)
45+
#define B_RST_EE (1<<1)
4046

41-
#define B_SAVE (1<<2)
47+
#define B_SAVE (1<<2)
4248

43-
#define B_BOOT_DEF (1<<6)
44-
#define B_BOOT_EE (1<<7)
49+
#define B_NAME_TO_DEFAULT (1<<3)
50+
51+
#define B_BOOT_DEF (1<<6)
52+
#define B_BOOT_EE (1<<7)
53+
54+
/* ADD_R_CONFIG */
55+
#define B_CLK_REP (1<<0)
56+
#define B_CLK_GEN (1<<1)
57+
#define B_CLK_SAVE (1<<2)
58+
#define B_REP_ABLE (1<<3)
59+
#define B_GEN_ABLE (1<<4)
60+
#define B_CLK_UNLOCK (1<<6)
61+
#define B_CLK_LOCK (1<<7)
4562

4663

4764
#endif /* _HWBP_CORE_REGS_H_ */

0 commit comments

Comments
 (0)