Skip to content

Commit 4ac77dd

Browse files
committed
Updated to atxmega core 1.15
1 parent fbf7c37 commit 4ac77dd

9 files changed

Lines changed: 165 additions & 106 deletions

File tree

Firmware/StepperDriver/StepperDriver.cproj

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -114,50 +114,50 @@
114114
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
115115
<ToolchainSettings>
116116
<AvrGcc>
117-
<avrgcc.common.Device>-mmcu=atxmega128a1u -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.3.146\gcc\dev\atxmega128a1u"</avrgcc.common.Device>
118-
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
119-
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
120-
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
121-
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
122-
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
123-
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
124-
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
125-
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
126-
<avrgcc.compiler.symbols.DefSymbols>
127-
<ListValues>
128-
<Value>DEBUG</Value>
129-
</ListValues>
130-
</avrgcc.compiler.symbols.DefSymbols>
131-
<avrgcc.compiler.directories.IncludePaths>
132-
<ListValues>
133-
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
134-
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.3.146\include\</Value>
135-
</ListValues>
136-
</avrgcc.compiler.directories.IncludePaths>
137-
<avrgcc.compiler.optimization.level>Optimize most (-O3)</avrgcc.compiler.optimization.level>
138-
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
139-
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
140-
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
141-
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
142-
<avrgcc.linker.libraries.Libraries>
143-
<ListValues>
144-
<Value>libm</Value>
145-
<Value>libATxmega128A1U-1.14-preview.a</Value>
146-
</ListValues>
147-
</avrgcc.linker.libraries.Libraries>
148-
<avrgcc.linker.libraries.LibrarySearchPaths>
149-
<ListValues>
150-
<Value>..</Value>
151-
</ListValues>
152-
</avrgcc.linker.libraries.LibrarySearchPaths>
153-
<avrgcc.assembler.general.IncludePaths>
154-
<ListValues>
155-
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
156-
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.3.146\include\</Value>
157-
</ListValues>
158-
</avrgcc.assembler.general.IncludePaths>
159-
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
160-
</AvrGcc>
117+
<avrgcc.common.Device>-mmcu=atxmega128a1u -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.3.146\gcc\dev\atxmega128a1u"</avrgcc.common.Device>
118+
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
119+
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
120+
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
121+
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
122+
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
123+
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
124+
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
125+
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
126+
<avrgcc.compiler.symbols.DefSymbols>
127+
<ListValues>
128+
<Value>DEBUG</Value>
129+
</ListValues>
130+
</avrgcc.compiler.symbols.DefSymbols>
131+
<avrgcc.compiler.directories.IncludePaths>
132+
<ListValues>
133+
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
134+
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.3.146\include\</Value>
135+
</ListValues>
136+
</avrgcc.compiler.directories.IncludePaths>
137+
<avrgcc.compiler.optimization.level>Optimize most (-O3)</avrgcc.compiler.optimization.level>
138+
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
139+
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
140+
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
141+
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
142+
<avrgcc.linker.libraries.Libraries>
143+
<ListValues>
144+
<Value>libm</Value>
145+
<Value>libATxmega128A1U-1.15.a</Value>
146+
</ListValues>
147+
</avrgcc.linker.libraries.Libraries>
148+
<avrgcc.linker.libraries.LibrarySearchPaths>
149+
<ListValues>
150+
<Value>..</Value>
151+
</ListValues>
152+
</avrgcc.linker.libraries.LibrarySearchPaths>
153+
<avrgcc.assembler.general.IncludePaths>
154+
<ListValues>
155+
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
156+
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.3.146\include\</Value>
157+
</ListValues>
158+
</avrgcc.assembler.general.IncludePaths>
159+
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
160+
</AvrGcc>
161161
</ToolchainSettings>
162162
</PropertyGroup>
163163
<ItemGroup>

Firmware/StepperDriver/app.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void hwbp_app_initialize(void)
3434
uint8_t hwH = 1;
3535
uint8_t hwL = 0;
3636
uint8_t fwH = 0;
37-
uint8_t fwL = 7;
37+
uint8_t fwL = 8;
3838
uint8_t ass = 0;
3939

4040
/* Start core */

Firmware/StepperDriver/hwbp_core.h

Lines changed: 72 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,102 +18,120 @@ typedef struct {
1818
uint16_t usecond;
1919
} timestamp_t;
2020

21-
// Used to define the clock direction default of the device.
21+
/// Used to define the clock direction default of the device.
2222
void core_callback_define_clock_default(void);
2323

24-
// It's the first callback used, right after booting the core.
25-
// The pins, ports and external hardware should be initialized.
24+
/// It's the first callback used, right after booting the core.
25+
/// The pins, ports and external hardware should be initialized.
2626
void core_callback_initialize_hardware(void);
2727

28-
// Used to initialize the registers.
29-
// All registers should be written to their default state.
28+
/// Used to initialize the registers.
29+
/// All registers should be written to their default state.
3030
void core_callback_reset_registers(void);
3131

32-
// Call right after load the register with default or EEPROM values.
33-
// The state registers and external hardware should be configured according the value of the registers.
32+
/// Call right after load the register with default or EEPROM values.
33+
/// The state registers and external hardware should be configured according the value of the registers.
3434
void core_callback_registers_were_reinitialized(void);
3535

36-
// Called when the application must turn off all the visual indicators.
36+
/// Called when the application must turn off all the visual indicators.
3737
void core_callback_visualen_to_on(void);
38-
// Called when the application can turn on the visual indicators.
38+
/// Called when the application can turn on the visual indicators.
3939
void core_callback_visualen_to_off(void);
4040

41-
// When the device goes to Standby Mode.
41+
/// When the device goes to Standby Mode.
4242
void core_callback_device_to_standby(void);
43-
// When the device goes to Active Mode.
43+
/// When the device goes to Active Mode.
4444
void core_callback_device_to_active(void);
45-
// When the device goes to Speed Mode.
45+
/// When the device goes to Speed Mode.
4646
void core_callback_device_to_speed(void);
4747

4848

49-
// Called before execute the timer interrupts
49+
/// Called before execute the timer interrupts
5050
void core_callback_t_before_exec(void);
51-
// Called after execute the timer interrupts
51+
/// Called after execute the timer interrupts
5252
void core_callback_t_after_exec(void);
5353

54-
// Called every millisecond.
54+
/// Called every millisecond.
5555
void core_callback_t_1ms(void);
56-
// Called 500 microseconds after the "void core_callback_t_1ms(void)".
56+
/// Called 500 microseconds after the "void core_callback_t_1ms(void)".
5757
void core_callback_t_500us(void);
58-
// Called every time a new second starts.
58+
/// Called every time a new second starts.
5959
void core_callback_t_new_second(void);
6060

6161

62-
// Read from an application register.
62+
/// Read from an application register.
6363
bool core_read_app_register(uint8_t add, uint8_t type);
64-
// Write to an application register.
64+
/// Write to an application register.
6565
bool core_write_app_register(uint8_t add, uint8_t type, uint8_t * content, uint16_t n_elements);
66-
// Read from a common register.
66+
/// Read from a common register.
6767
bool hwbp_read_common_reg(uint8_t add, uint8_t type);
68-
// Write to an common register.
68+
/// Write to an common register.
6969
bool hwbp_write_common_reg(uint8_t add, uint8_t type, uint8_t * content, uint16_t n_elements);
7070

7171

7272
/************************************************************************/
7373
/* Register RESET_APP */
7474
/************************************************************************/
75-
// Write to common register RESET_APP.
75+
/// Write to common register RESET_APP.
7676
bool hwbp_write_common_reg_RESET_APP(void *a);
7777

78-
// Used to save all registers to non-volatile memory
78+
/// Used to save all registers to non-volatile memory
7979
bool core_save_all_registers_to_eeprom(void);
8080

8181

8282
/************************************************************************/
8383
/* Register CONFIG */
8484
/************************************************************************/
85-
// Write to common register CONFIG.
85+
/// Write to common register CONFIG.
8686
bool hwbp_write_common_reg_CONFIG(void *a);
87-
// Read from common register CONFIG.
87+
/// Read from common register CONFIG.
8888
void hwbp_read_common_reg_CONFIG(void);
8989

90-
// Called when the application should configure the hardware to repeat the harp timestamp clock input.
90+
/// Called when the application should configure the hardware to repeat the harp timestamp clock input.
9191
void core_callback_clock_to_repeater(void);
92-
// Called when the application should configure the hardware to generate the harp timestamp clock.
92+
/// Called when the application should configure the hardware to generate the harp timestamp clock.
9393
void core_callback_clock_to_generator(void);
94-
// Called when the timestamp lock is changed to unlocked.
94+
/// Called when the timestamp lock is changed to unlocked.
9595
void core_callback_clock_to_unlock(void);
96-
// Called when the timestamp lock is changed to locked.
96+
/// Called when the timestamp lock is changed to locked.
9797
void core_callback_clock_to_lock(void);
9898

99-
// Used to know if the device is repeating the harp timestamp clock
99+
/// Used to know if the device is repeating the harp timestamp clock
100100
bool core_bool_device_is_repeater(void);
101-
// Used to know if the device is generating the harp timestamp clock
101+
/// Used to know if the device is generating the harp timestamp clock
102102
bool core_bool_device_is_generator(void);
103-
// Used to check if the timestamp register is locked
103+
/// Used to check if the timestamp register is locked
104104
bool core_bool_clock_is_locked(void);
105105

106-
// Used to set the device as a repeater
106+
/// Used to set the device as a repeater
107107
bool core_device_to_clock_repeater(void);
108-
// Used to set the device as a generator
108+
/// Used to set the device as a generator
109109
bool core_device_to_clock_generator(void);
110-
// Used to lock the timestamp register
110+
/// Used to lock the timestamp register
111111
bool core_clock_to_lock(void);
112-
// Used to unlock the timestamp register
112+
/// Used to unlock the timestamp register
113113
bool core_clock_to_unlock(void);
114114

115115

116-
// It is mandatory that this function is the first of the application code.
116+
/// It is mandatory that this function is the first of the application code.
117+
void core_func_start_core_V2 (
118+
const uint16_t who_am_i,
119+
const uint8_t hwH,
120+
const uint8_t hwL,
121+
const uint8_t hwP,
122+
const uint8_t fwH,
123+
const uint8_t fwL,
124+
const uint8_t fwP,
125+
uint8_t *pointer_to_app_regs,
126+
const uint16_t app_mem_size_to_save,
127+
const uint8_t num_of_app_registers,
128+
const uint8_t *device_name,
129+
const bool device_is_able_to_repeat_clock,
130+
const bool device_is_able_to_generate_clock,
131+
const uint8_t default_timestamp_offset
132+
);
133+
134+
/// Old initialization function. Use "core_func_start_core_V2()" instead.
117135
void core_func_start_core (
118136
const uint16_t who_am_i,
119137
const uint8_t hwH,
@@ -130,41 +148,45 @@ void core_func_start_core (
130148
const uint8_t default_timestamp_offset
131149
);
132150

133-
// Call this function in case of error
134-
// A power up or reset must be performed to remove the device from this state
151+
/// Call this function in case of error
152+
/// A power up or reset must be performed to remove the device from this state
135153
void core_func_catastrophic_error_detected(void);
136-
// When a catastrophic error is detected (last callback before go into error state)
137-
// User should shutdown all the peripherals
154+
/// When a catastrophic error is detected (last callback before go into error state)
155+
/// User should shutdown all the peripherals
138156
void core_callback_catastrophic_error_detected(void);
139157

140-
// Used to leave the speed mode.
158+
/// Used to leave the speed mode.
141159
void core_func_leave_speed_mode_and_go_to_standby_mode(void);
142160

143161

144-
// Used to create a specific timestamp that can be used when sending Events
162+
/// Used to create a specific timestamp that can be used when sending Events
145163
void core_func_update_user_timestamp(uint32_t seconds, uint16_t useconds);
146164

147-
// Used to read the current user timestamps
165+
/// Used to read the current user timestamps
148166
void core_func_read_user_timestamp(uint32_t *seconds, uint16_t *useconds);
149167

150-
// Used to save the current timestamp
168+
/// Used to save the current timestamp
151169
void core_func_mark_user_timestamp(void);
152170

153-
// Used to send an Event
171+
/// Used to send an Event
154172
void core_func_send_event(uint8_t add, bool use_core_timestamp);
155173

156-
// Used to get the content of register R_TIMESTAMP_SECOND.
174+
/// Used to get the content of register R_TIMESTAMP_SECOND.
157175
uint32_t core_func_read_R_TIMESTAMP_SECOND(void);
158-
// Used to get the content of register R_TIMESTAMP_MICRO.
176+
/// Used to get the content of register R_TIMESTAMP_MICRO.
159177
uint16_t core_func_read_R_TIMESTAMP_MICRO(void);
160178

161179

162180

163181

164-
// Return "true" if the LEDs can be ON.
182+
/// Return "true" if the LEDs can be ON.
165183
bool core_bool_is_visual_enabled(void);
166-
// Return "true" if the device is in Speed Mode.
184+
/// Return "true" if the device is in Speed Mode.
167185
bool core_bool_speed_mode_is_in_use(void);
186+
/// Return "true" if the device is in Active Mode.
187+
bool core_bool_device_is_active(void);
188+
/// Return "true" if the device is synchronized.
189+
bool core_bool_device_is_synchronized(void);
168190

169191

170192

Firmware/StepperDriver/hwbp_core_com.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define HWBP_UART_CTS_INT_LEVEL INT_LEVEL_HIGH
2222

2323
#define HWBP_UART_RXBUFSIZ MAX_PACKET_SIZE
24+
#define HWBP_UART_TEMP_RXBUFSIZ 32
2425

2526
#if defined(__AVR_ATxmega16A4U__)
2627
#define HWBP_UART_UART USARTE0
@@ -119,7 +120,7 @@
119120
#define hwbp_uart_leave_interrupt return/*reti();*/
120121

121122
/* Use as much as possible */
122-
#define HWBP_UART_TXBUFSIZ 6144
123+
#define HWBP_UART_TXBUFSIZ 5120
123124
#endif
124125

125126
#if defined(__AVR_ATxmega128A1U__)
@@ -144,7 +145,7 @@
144145
#define hwbp_uart_leave_interrupt return/*reti();*/
145146

146147
/* Use as much as possible */
147-
#define HWBP_UART_TXBUFSIZ 6144
148+
#define HWBP_UART_TXBUFSIZ 5120
148149
#endif
149150

150151

@@ -165,17 +166,17 @@ void hwbp_uart_xmit(const uint8_t *dataIn0, uint8_t siz);
165166
bool hwbp_uart_rcv_now(uint8_t * byte); // Not used
166167

167168

168-
// Called before execute the uart rRX interrupt
169+
/// Called before execute the uart rRX interrupt
169170
void core_callback_uart_rx_before_exec(void);
170-
// Called after execute the uart RX interrupt
171+
/// Called after execute the uart RX interrupt
171172
void core_callback_uart_rx_after_exec(void);
172-
// Called before execute the uart Tx interrupt
173+
/// Called before execute the uart Tx interrupt
173174
void core_callback_uart_tx_before_exec(void);
174-
// Called after execute the uart TX interrupt
175+
/// Called after execute the uart TX interrupt
175176
void core_callback_uart_tx_after_exec(void);
176-
// Called before execute the uart CTS interrupt
177+
/// Called before execute the uart CTS interrupt
177178
void core_callback_uart_cts_before_exec(void);
178-
// Called after execute the uart CTS interrupt
179+
/// Called after execute the uart CTS interrupt
179180
void core_callback_uart_cts_after_exec(void);
180181

181182

0 commit comments

Comments
 (0)