Skip to content

Commit 0f9dde9

Browse files
authored
Updated to atxmega core 1.15 (#13)
1 parent 214b5d6 commit 0f9dde9

9 files changed

Lines changed: 122 additions & 63 deletions

File tree

Firmware/LedArray/LedArray.cproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
<avrgcc.linker.libraries.Libraries>
136136
<ListValues>
137137
<Value>libm</Value>
138-
<Value>libATxmega64A4U-1.13.a</Value>
138+
<Value>libATxmega64A4U-1.15.a</Value>
139139
</ListValues>
140140
</avrgcc.linker.libraries.Libraries>
141141
<avrgcc.linker.libraries.LibrarySearchPaths>

Firmware/LedArray/app.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void hwbp_app_initialize(void)
2929
uint8_t hwH = 1;
3030
uint8_t hwL;
3131
uint8_t fwH = 2;
32-
uint8_t fwL = 6;
32+
uint8_t fwL = 7;
3333
uint8_t ass = 0;
3434

3535
io_pin2in(&PORTA, 0, PULL_IO_TRISTATE, SENSE_IO_EDGES_BOTH); // VERSION0

Firmware/LedArray/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/LedArray/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

Firmware/LedArray/hwbp_core_regs.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
#ifndef _HWBP_CORE_REGS_H_
22
#define _HWBP_CORE_REGS_H_
33

4+
/************************************************************************/
5+
/* Common Bank Structure */
6+
/************************************************************************/
7+
struct CommonBank
8+
{
9+
uint16_t R_WHO_AM_I;
10+
uint8_t R_HW_VERSION_H;
11+
uint8_t R_HW_VERSION_L;
12+
uint8_t R_ASSEMBLY_VERSION;
13+
uint8_t R_CORE_VERSION_H;
14+
uint8_t R_CORE_VERSION_L;
15+
uint8_t R_FW_VERSION_H;
16+
uint8_t R_FW_VERSION_L;
17+
uint32_t R_TIMESTAMP_SECOND;
18+
uint16_t R_TIMESTAMP_MICRO;
19+
uint8_t R_OPERATION_CTRL;
20+
uint8_t R_RESET_DEV;
21+
uint8_t R_DEVICE_NAME[25];
22+
uint16_t R_SERIAL_NUMBER;
23+
uint8_t R_CLOCK_CONFIG;
24+
uint8_t R_TIMESTAMP_OFFSET;
25+
uint8_t R_UID[16];
26+
uint8_t R_TAG[8];
27+
uint16_t R_HEARTBEAT;
28+
uint8_t R_VERSION[32];
29+
};
430

531
/************************************************************************/
632
/* Common Bank Registers */
@@ -22,9 +48,13 @@
2248
#define ADD_R_SERIAL_NUMBER 0x0D // U16
2349
#define ADD_R_CONFIG 0x0E // U8
2450
#define ADD_R_TIMESTAMP_OFFSET 0x0F // U8
51+
#define ADD_R_UID 0x10 // U8[16]
52+
#define ADD_R_TAG 0x11 // U8[8]
53+
#define ADD_R_HEARTBEAT 0x12 // U16
54+
#define ADD_R_VERSION 0x13 // U8[32]
2555

2656
/* Memory limits */
27-
#define COMMON_BANK_ADD_MAX 0x0F
57+
#define COMMON_BANK_ADD_MAX 0x13
2858
#define COMMON_BANK_ABSOLUTE_ADD_MAX 0x1C
2959

3060
/* R_OPERATION_CTRL */
@@ -34,6 +64,7 @@
3464
#define GM_OP_MODE_ACTIVE (1<<0)
3565
#define GM_OP_MODE_SPEED (3<<0)
3666

67+
#define B_HEARTBEAT_EN (1<<2)
3768
#define B_DUMP (1<<3)
3869
#define B_MUTE_RPL (1<<4)
3970
#define B_VISUALEN (1<<5)
@@ -48,6 +79,7 @@
4879

4980
#define B_NAME_TO_DEFAULT (1<<3)
5081

82+
#define B_BOOT (1<<5)
5183
#define B_BOOT_DEF (1<<6)
5284
#define B_BOOT_EE (1<<7)
5385

@@ -60,5 +92,9 @@
6092
#define B_CLK_UNLOCK (1<<6)
6193
#define B_CLK_LOCK (1<<7)
6294

95+
/* ADD_R_HEARTBEAT */
96+
#define B_IS_SYNCHRONIZED (1<<0)
97+
#define B_IS_ACTIVE (1<<1)
98+
6399

64100
#endif /* _HWBP_CORE_REGS_H_ */

Firmware/LedArray/hwbp_sync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void trigger_sync_timer (void);
3737
#if defined(__AVR_ATxmega16A4U__)
3838
#define INCREASE_LOST_SYNC_COUNTER
3939
#else
40-
#define INCREASE_LOST_SYNC_COUNTER device_lost_sync_counter++
40+
#define INCREASE_LOST_SYNC_COUNTER if(++device_lost_sync_counter == 255) device_lost_sync_counter = 254; if(device_lost_sync_counter >= 5 ) commonbank.R_HEARTBEAT &= ~B_IS_SYNCHRONIZED
4141
#endif
4242

4343

-177 KB
Binary file not shown.
193 KB
Binary file not shown.

device.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# yaml-language-server: $schema=https://harp-tech.org/draft-02/schema/device.json
44
device: LedArray
55
whoAmI: 1088
6-
firmwareVersion: "2.4"
6+
firmwareVersion: "2.7"
77
hardwareTargets: "1.1" # also 1.2 & 1.3
88
registers:
99
EnablePower: &ledstatereg

0 commit comments

Comments
 (0)