Skip to content

Commit

Permalink
Merge pull request #3 from harp-tech/as-core-update-1.13
Browse files Browse the repository at this point in the history
Update core to 1.13
  • Loading branch information
artursilva0 authored Aug 24, 2023
2 parents ae5b97c + 7665e7a commit dfcdc32
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 24 deletions.
9 changes: 9 additions & 0 deletions Firmware/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Visual studio files
.vs
.suo
.nuget
bin
obj
Debug
packages
*.componentinfo.xml
62 changes: 49 additions & 13 deletions Firmware/CameraController/CameraController.cppproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>6.2</ProjectVersion>
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.CPP</ToolchainName>
<ProjectGuid>{4699b3b7-8e6c-4ba9-9926-134793d51fda}</ProjectGuid>
<avrdevice>ATxmega64A4U</avrdevice>
Expand All @@ -27,16 +27,16 @@
<BootSegment>2</BootSegment>
<eraseonlaunchrule>0</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data xmlns="">
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.21.0" />
</dependencies>
</framework-data>
<framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.42.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
<avrtoolinterface>PDI</avrtoolinterface>
Expand All @@ -51,10 +51,13 @@
<ToolNumber>J41800031896</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<ResetRule>0</ResetRule>
<EraseKey />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGccCpp>
<avrgcc.common.Device>-mmcu=atxmega64a4u -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\gcc\dev\atxmega64a4u"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
Expand All @@ -67,6 +70,11 @@
<Value>NDEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
Expand All @@ -78,6 +86,11 @@
<Value>NDEBUG</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\include\</Value>
</ListValues>
</avrgcccpp.compiler.directories.IncludePaths>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
Expand All @@ -86,19 +99,27 @@
<ListValues>
<Value>libm</Value>
<Value>libATxmega64A4U-1.4.a</Value>
<Value>libATxmega64A4U-1.13.a</Value>
</ListValues>
</avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.CameraController\Firmware\CameraController</Value>
<Value>C:\Users\Artur\Documents\GitHub\device.cameracontroller\Firmware\CameraController</Value>
</ListValues>
</avrgcccpp.linker.libraries.LibrarySearchPaths>
<avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\include\</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
</AvrGccCpp>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGccCpp>
<avrgcc.common.Device>-mmcu=atxmega64a4u -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\gcc\dev\atxmega64a4u"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
Expand All @@ -111,6 +132,11 @@
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize most (-O3)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
Expand All @@ -123,6 +149,11 @@
<Value>DEBUG</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\include\</Value>
</ListValues>
</avrgcccpp.compiler.directories.IncludePaths>
<avrgcccpp.compiler.optimization.level>Optimize most (-O3)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
Expand All @@ -131,14 +162,19 @@
<avrgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
<Value>libATxmega64A4U-1.4.a</Value>
<Value>libATxmega64A4U-1.13.a</Value>
</ListValues>
</avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.CameraController\Firmware\CameraController</Value>
<Value>..</Value>
</ListValues>
</avrgcccpp.linker.libraries.LibrarySearchPaths>
<avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.2.141\include\</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
</AvrGccCpp>
</ToolchainSettings>
Expand Down
17 changes: 15 additions & 2 deletions Firmware/CameraController/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ void hwbp_app_initialize(void)
(uint8_t*)(&app_regs),
APP_NBYTES_OF_REG_BANK,
APP_REGS_ADD_MAX - APP_REGS_ADD_MIN + 1,
default_device_name
default_device_name,
false, // The device is _not_ able to repeat the harp timestamp clock
false, // The device is _not_ able to generate the harp timestamp clock
0 // Default timestamp offset
);

}
Expand Down Expand Up @@ -243,7 +246,9 @@ void disable_motor1(void)
/************************************************************************/
/* Initialization Callbacks */
/************************************************************************/
void core_callback_1st_config_hw_after_boot(void)
void core_callback_define_clock_default(void) {}

void core_callback_initialize_hardware(void)
{
/* Initialize IOs */
/* Don't delete this function!!! */
Expand Down Expand Up @@ -365,6 +370,14 @@ void core_callback_t_new_second(void) { _2000ms_counter = 0; }
void core_callback_t_500us(void) {}
void core_callback_t_1ms(void) {}

/************************************************************************/
/* Callbacks: clock control */
/************************************************************************/
void core_callback_clock_to_repeater(void) {}
void core_callback_clock_to_generator(void) {}
void core_callback_clock_to_unlock(void) {}
void core_callback_clock_to_lock(void) {}

/************************************************************************/
/* Callbacks: uart control */
/************************************************************************/
Expand Down
6 changes: 6 additions & 0 deletions Firmware/CameraController/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ void timer_type1_wait(TC1_t* timer, uint8_t prescaler, uint16_t target_count);
/************************************************************************/
/* EEPROM */
/************************************************************************/
bool eeprom_is_busy(void);

uint8_t eeprom_rd_byte(uint16_t addr);
void eeprom_wr_byte(uint16_t addr, uint8_t byte);

Expand Down Expand Up @@ -171,6 +173,10 @@ int32_t eeprom_rd_i32(uint16_t addr);
#define PRESCALER_ADC_DIV256 ADC_PRESCALER_DIV256_gc
#define PRESCALER_ADC_DIV512 ADC_PRESCALER_DIV512_gc

void adc_A_initialize_single_ended(uint8_t analog_reference);
int16_t adc_A_read_channel(uint8_t index);
void adc_A_calibrate_offset(uint8_t index);

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);

#endif /* _CPU_1V1_H_ */
56 changes: 52 additions & 4 deletions Firmware/CameraController/hwbp_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ typedef struct {
uint16_t usecond;
} timestamp_t;

// Used to define the clock direction default of the device.
void core_callback_define_clock_default(void);

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

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



// Called before execute the timer interrupts
void core_callback_t_before_exec(void);
// Called after execute the timer interrupts
Expand All @@ -57,7 +59,6 @@ void core_callback_t_500us(void);
void core_callback_t_new_second(void);



// Read from an application register.
bool core_read_app_register(uint8_t add, uint8_t type);
// Write to an application register.
Expand All @@ -68,6 +69,48 @@ bool hwbp_read_common_reg(uint8_t add, uint8_t type);
bool hwbp_write_common_reg(uint8_t add, uint8_t type, uint8_t * content, uint16_t n_elements);


/************************************************************************/
/* Register RESET_APP */
/************************************************************************/
// Write to common register RESET_APP.
bool hwbp_write_common_reg_RESET_APP(void *a);

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


/************************************************************************/
/* Register CONFIG */
/************************************************************************/
// Write to common register CONFIG.
bool hwbp_write_common_reg_CONFIG(void *a);
// Read from common register CONFIG.
void hwbp_read_common_reg_CONFIG(void);

// Called when the application should configure the hardware to repeat the harp timestamp clock input.
void core_callback_clock_to_repeater(void);
// Called when the application should configure the hardware to generate the harp timestamp clock.
void core_callback_clock_to_generator(void);
// Called when the timestamp lock is changed to unlocked.
void core_callback_clock_to_unlock(void);
// Called when the timestamp lock is changed to locked.
void core_callback_clock_to_lock(void);

// Used to know if the device is repeating the harp timestamp clock
bool core_bool_device_is_repeater(void);
// Used to know if the device is generating the harp timestamp clock
bool core_bool_device_is_generator(void);
// Used to check if the timestamp register is locked
bool core_bool_clock_is_locked(void);

// Used to set the device as a repeater
bool core_device_to_clock_repeater(void);
// Used to set the device as a generator
bool core_device_to_clock_generator(void);
// Used to lock the timestamp register
bool core_clock_to_lock(void);
// Used to unlock the timestamp register
bool core_clock_to_unlock(void);


// It is mandatory that this function is the first of the application code.
Expand All @@ -81,7 +124,11 @@ void core_func_start_core (
uint8_t *pointer_to_app_regs,
const uint16_t app_mem_size_to_save,
const uint8_t num_of_app_registers,
const uint8_t *device_name);
const uint8_t *device_name,
const bool device_is_able_to_repeat_clock,
const bool device_is_able_to_generate_clock,
const uint8_t default_timestamp_offset
);

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




// Return "true" if the LEDs can be ON.
bool core_bool_is_visual_enabled(void);
// Return "true" if the device is in Speed Mode.
Expand Down
20 changes: 17 additions & 3 deletions Firmware/CameraController/hwbp_core_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
#define ADD_R_HW_VERSION_H 0x01 // U8
#define ADD_R_HW_VERSION_L 0x02 // U8
#define ADD_R_ASSEMBLY_VERSION 0x03 // U8
#define ADD_R_HARP_VERSION_H 0x04 // U8
#define ADD_R_HARP_VERSION_L 0x05 // U8
#define ADD_R_CORE_VERSION_H 0x04 // U8
#define ADD_R_CORE_VERSION_L 0x05 // U8
#define ADD_R_FW_VERSION_H 0x06 // U8
#define ADD_R_FW_VERSION_L 0x07 // U8
#define ADD_R_TIMESTAMP_SECOND 0x08 // U32
#define ADD_R_TIMESTAMP_MICRO 0x09 // U16
#define ADD_R_OPERATION_CTRL 0x0A // U8
#define ADD_R_RESET_DEV 0x0B // U8
#define ADD_R_DEVICE_NAME 0x0C // U8
#define ADD_R_SERIAL_NUMBER 0x0D // U16
#define ADD_R_CONFIG 0x0E // U8
#define ADD_R_TIMESTAMP_OFFSET 0x0F // U8

/* Memory limits */
#define COMMON_BANK_ADD_MAX 0x0C
#define COMMON_BANK_ADD_MAX 0x0F
#define COMMON_BANK_ABSOLUTE_ADD_MAX 0x1C

/* R_OPERATION_CTRL */
Expand All @@ -43,8 +46,19 @@

#define B_SAVE (1<<2)

#define B_NAME_TO_DEFAULT (1<<3)

#define B_BOOT_DEF (1<<6)
#define B_BOOT_EE (1<<7)

/* ADD_R_CONFIG */
#define B_CLK_REP (1<<0)
#define B_CLK_GEN (1<<1)
#define B_CLK_SAVE (1<<2)
#define B_REP_ABLE (1<<3)
#define B_GEN_ABLE (1<<4)
#define B_CLK_UNLOCK (1<<6)
#define B_CLK_LOCK (1<<7)


#endif /* _HWBP_CORE_REGS_H_ */
4 changes: 2 additions & 2 deletions Firmware/CameraController/hwbp_core_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#define MSK_TIMESTAMP_AT_PAYLOAD 0x10

/************************************************************************/
/* Maximum size of an entire packet (header to chksum) */
/* Maximum size of a received packet */
/************************************************************************/
#define MAX_PACKET_SIZE 256
#define MAX_PACKET_SIZE 255


#endif /* _HWBP_CORE_TYPES_H_ */
Loading

0 comments on commit dfcdc32

Please sign in to comment.