Skip to content

Commit

Permalink
Merge pull request #6 from harp-tech/new_fw_2.1_sin_generator
Browse files Browse the repository at this point in the history
New fw 2.1 sin generator
  • Loading branch information
artursilva0 authored Dec 6, 2023
2 parents 40c2020 + c333feb commit 480557a
Show file tree
Hide file tree
Showing 30 changed files with 1,370 additions and 509 deletions.
5 changes: 4 additions & 1 deletion Firmware/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ bin
obj
Debug
packages
*.componentinfo.xml
*.componentinfo.xml
.generated_files
build
dist
24 changes: 20 additions & 4 deletions Firmware/Firmware.ATXMEGA/SoundCard/SoundCard.cppproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.39.0" />
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.42.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
Expand All @@ -48,9 +48,21 @@
<InterfaceName>PDI</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800031896</ToolNumber>
<ToolNumber>J42700022647</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<com_atmel_avrdbg_tool_simulator>
<ToolOptions xmlns="">
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>
</InterfaceName>
</ToolOptions>
<ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
<ToolNumber xmlns="">
</ToolNumber>
<ToolName xmlns="">Simulator</ToolName>
</com_atmel_avrdbg_tool_simulator>
<ResetRule>0</ResetRule>
<EraseKey />
</PropertyGroup>
Expand Down Expand Up @@ -105,7 +117,9 @@
<avrgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LoadCells\Firmware\LoadCells</Value>
<Value>C:\Users\Work\Documents\device.soundcard\Firmware.ATXMEGA\SoundCard</Value>
<Value>C:\Users\OEPS\Documents\bitbucket\fchampalimaud\Device.SoundCard\Firmware.ATXMEGA\SoundCard</Value>
<Value>C:\Users\OEPS\Documents\bitbucket\_fchampalimaud_\Device.SoundCard\device.soundcard\Firmware.ATXMEGA\SoundCard</Value>
<Value>C:\Users\Artur\Documents\GitHub\device.soundcard\Firmware\Firmware.ATXMEGA\SoundCard</Value>
</ListValues>
</avrgcccpp.linker.libraries.LibrarySearchPaths>
<avrgcccpp.assembler.general.IncludePaths>
Expand Down Expand Up @@ -169,7 +183,9 @@
<avrgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LoadCells\Firmware\LoadCells</Value>
<Value>C:\Users\Work\Documents\device.soundcard\Firmware.ATXMEGA\SoundCard</Value>
<Value>C:\Users\OEPS\Documents\bitbucket\fchampalimaud\Device.SoundCard\Firmware.ATXMEGA\SoundCard</Value>
<Value>C:\Users\OEPS\Documents\bitbucket\_fchampalimaud_\Device.SoundCard\device.soundcard\Firmware.ATXMEGA\SoundCard</Value>
<Value>C:\Users\Artur\Documents\GitHub\device.soundcard\Firmware\Firmware.ATXMEGA\SoundCard</Value>
</ListValues>
</avrgcccpp.linker.libraries.LibrarySearchPaths>
<avrgcccpp.assembler.general.IncludePaths>
Expand Down
16 changes: 15 additions & 1 deletion Firmware/Firmware.ATXMEGA/SoundCard/SoundCard_6_2.cppproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@
<InterfaceName>PDI</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800031896</ToolNumber>
<ToolNumber>J42700022647</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<com_atmel_avrdbg_tool_simulator>
<ToolOptions xmlns="">
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>
</InterfaceName>
</ToolOptions>
<ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
<ToolNumber xmlns="">
</ToolNumber>
<ToolName xmlns="">Simulator</ToolName>
</com_atmel_avrdbg_tool_simulator>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
Expand Down Expand Up @@ -92,6 +104,7 @@
<avrgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LoadCells\Firmware\LoadCells</Value>
<Value>C:\Users\OEPS\Documents\bitbucket\fchampalimaud\Device.SoundCard\Firmware.ATXMEGA\SoundCard</Value>
</ListValues>
</avrgcccpp.linker.libraries.LibrarySearchPaths>
</AvrGccCpp>
Expand Down Expand Up @@ -139,6 +152,7 @@
<avrgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>C:\Users\Filipe Carvalho\Documents\BitBucket\Device.LoadCells\Firmware\LoadCells</Value>
<Value>C:\Users\OEPS\Documents\bitbucket\fchampalimaud\Device.SoundCard\Firmware.ATXMEGA\SoundCard</Value>
</ListValues>
</avrgcccpp.linker.libraries.LibrarySearchPaths>
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
Expand Down
6 changes: 3 additions & 3 deletions Firmware/Firmware.ATXMEGA/SoundCard/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ static const uint8_t default_device_name[] = "SoundCard";
void hwbp_app_initialize(void)
{
/* Define versions */
uint8_t hwH = 1;
uint8_t hwL = 1;
uint8_t hwH = 2;
uint8_t hwL = 0;
uint8_t fwH = MAJOR_FW_VERSION;
uint8_t fwL = 0;
uint8_t fwL = 1;
uint8_t ass = 0;

/* Start core */
Expand Down
123 changes: 73 additions & 50 deletions Firmware/Firmware.ATXMEGA/SoundCard/app_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,30 @@ bool (*app_func_wr_pointer[])(void*) = {
/************************************************************************/
/* REG_PLAY_SOUND_OR_FREQ */
/************************************************************************/
uint16_t last_sound_triggered = 0; // 0 means it's stopped

void app_read_REG_PLAY_SOUND_OR_FREQ(void) {}
bool app_write_REG_PLAY_SOUND_OR_FREQ(void *a)
{
uint16_t reg = *((uint16_t*)a);

if (reg > 1)
{
if (reg < 32)
par_cmd_start_sound(reg, app_regs.REG_ATTNUATION_LEFT, app_regs.REG_ATTENUATION_RIGHT);
else
; // play tone
}
else
if (reg <= 1 || reg > 40000)
return false;

if (last_sound_triggered != 0)
/* Previous event was not sent yet */
return false;

app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[0] = reg;

app_regs.REG_PLAY_SOUND_OR_FREQ = reg;

/* Save the sound being played */
last_sound_triggered = reg;

//par_cmd_start_sound(reg, app_regs.REG_ATTNUATION_LEFT, app_regs.REG_ATTENUATION_RIGHT);
par_cmd_update_frequency(reg);

return true;
}

Expand All @@ -158,7 +166,10 @@ bool app_write_REG_STOP(void *a)
uint8_t reg = *((uint8_t*)a);

if (reg)
{
par_cmd_stop();
last_sound_triggered = 0;
}

app_regs.REG_STOP = reg;
return true;
Expand All @@ -168,71 +179,94 @@ bool app_write_REG_STOP(void *a)
/************************************************************************/
/* REG_ATTNUATION_LEFT */
/************************************************************************/
void app_read_REG_ATTNUATION_LEFT(void)
{
//app_regs.REG_ATTNUATION_LEFT = 0;

}

void app_read_REG_ATTNUATION_LEFT(void) {}
bool app_write_REG_ATTNUATION_LEFT(void *a)
{
uint16_t reg = *((uint16_t*)a);

app_regs.REG_ATTENUATION_BOTH[0] = reg;
app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[1] = reg;

app_regs.REG_ATTNUATION_LEFT = reg;

par_cmd_update_amplitude_left(reg);

return true;
}


/************************************************************************/
/* REG_ATTENUATION_RIGHT */
/************************************************************************/
void app_read_REG_ATTENUATION_RIGHT(void)
{
//app_regs.REG_ATTENUATION_RIGHT = 0;

}

void app_read_REG_ATTENUATION_RIGHT(void) {}
bool app_write_REG_ATTENUATION_RIGHT(void *a)
{
uint16_t reg = *((uint16_t*)a);

app_regs.REG_ATTENUATION_BOTH[1] = reg;
app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[2] = reg;

app_regs.REG_ATTENUATION_RIGHT = reg;

par_cmd_update_amplitude_right(reg);

return true;
}


/************************************************************************/
/* REG_ATTENUATION_BOTH */
/************************************************************************/
void app_read_REG_ATTENUATION_BOTH(void)
{
//app_regs.REG_ATTENUATION_BOTH = 0;

}

void app_read_REG_ATTENUATION_BOTH(void) {}
bool app_write_REG_ATTENUATION_BOTH(void *a)
{
uint16_t reg = *((uint16_t*)a);

app_regs.REG_ATTENUATION_BOTH[0] = reg;
uint16_t *reg = ((uint16_t*)a);

app_regs.REG_ATTNUATION_LEFT = reg[0];
app_regs.REG_ATTENUATION_RIGHT = reg[1];

app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[1] = reg[0];
app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[2] = reg[1];

app_regs.REG_ATTENUATION_BOTH[0] = reg[0];
app_regs.REG_ATTENUATION_BOTH[1] = reg[1];

par_cmd_update_amplitude(reg[0], reg[1]);

return true;
}


/************************************************************************/
/* REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ */
/************************************************************************/
void app_read_REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ(void)
{
//app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ = 0;

}

void app_read_REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ(void) {}
bool app_write_REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ(void *a)
{
uint16_t reg = *((uint16_t*)a);
uint16_t *reg = ((uint16_t*)a);

if (reg[0] <= 1 || reg[0] > 40000)
return false;

app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[0] = reg;
if (last_sound_triggered != 0)
/* Previous event was not sent yet */
return false;

app_regs.REG_PLAY_SOUND_OR_FREQ = reg[0];
app_regs.REG_ATTNUATION_LEFT = reg[1];
app_regs.REG_ATTENUATION_RIGHT = reg[2];
app_regs.REG_ATTENUATION_BOTH[0] = reg[1];
app_regs.REG_ATTENUATION_BOTH[1] = reg[2];

app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[0] = reg[0];
app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[1] = reg[1];
app_regs.REG_SET_ATTENUATION_AND_PLAY_SOUND_OR_FREQ[2] = reg[2];

/* Save the sound being played */
last_sound_triggered = reg[0];

par_cmd_start_sound(reg[0], reg[1], reg[2]);

return true;
}

Expand Down Expand Up @@ -354,26 +388,15 @@ void app_read_REG_DI0_SOUND_INDEX(void)

}

bool app_write_REG_DI0_SOUND_INDEX(void *a)
bool app_write_REG_DI0_SOUND_INDEX(void *a)
{
uint8_t reg = *((uint8_t*)a);

// for future implementation of cmd_index
/*if (reg > 1)
{
if (reg < 32)
par_cmd_index(reg);
else
;
}
else
return false;*/


app_regs.REG_DI0_SOUND_INDEX = reg;
return true;
}


/************************************************************************/
/* REG_DI1_SOUND_INDEX */
/************************************************************************/
Expand Down
6 changes: 3 additions & 3 deletions Firmware/Firmware.ATXMEGA/SoundCard/app_ios_and_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/************************************************************************/
void init_ios(void)
{ /* Configure input pins */
io_pin2in(&PORTB, 0, PULL_IO_UP, SENSE_IO_EDGE_RISING); // DIN0
io_pin2in(&PORTB, 0, PULL_IO_UP, SENSE_IO_EDGES_BOTH); // DIN0
io_pin2in(&PORTD, 0, PULL_IO_UP, SENSE_IO_EDGES_BOTH); // DIN1
io_pin2in(&PORTC, 0, PULL_IO_UP, SENSE_IO_EDGES_BOTH); // DIN2
io_pin2in(&PORTC, 5, PULL_IO_UP, SENSE_IO_EDGE_RISING); // CMD_LATCHED
Expand All @@ -17,9 +17,9 @@ void init_ios(void)
/* Configure input interrupts */
io_set_int(&PORTB, INT_LEVEL_LOW, 0, (1<<0), false); // DIN0
io_set_int(&PORTD, INT_LEVEL_LOW, 0, (1<<0), false); // DIN1
io_set_int(&PORTC, INT_LEVEL_LOW, 0, (1<<0), false); // DIN2
//io_set_int(&PORTC, INT_LEVEL_LOW, 0, (1<<0), false); // DIN2
io_set_int(&PORTC, INT_LEVEL_LOW, 1, (1<<5), false); // CMD_LATCHED
io_set_int(&PORTC, INT_LEVEL_LOW, 1, (1<<6), false); // SOUND_IS_ON
io_set_int(&PORTC, INT_LEVEL_LOW, 0, (1<<6), false); // SOUND_IS_ON

/* Configure output pins */
io_pin2out(&PORTA, 0, OUT_IO_DIGITAL, IN_EN_IO_DIS); // PAR0
Expand Down
17 changes: 3 additions & 14 deletions Firmware/Firmware.ATXMEGA/SoundCard/interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "app_ios_and_regs.h"
#include "app_funcs.h"
#include "hwbp_core.h"
#include "parallel_bus.h"

/************************************************************************/
/* Declare application registers */
Expand Down Expand Up @@ -32,19 +31,7 @@ extern AppRegs app_regs;
/************************************************************************/
ISR(PORTB_INT0_vect, ISR_NAKED)
{

//app_regs.REG_PLAY_SOUND_OR_FREQ = 3; //default plays index 3
//app_write_REG_PLAY_SOUND_OR_FREQ(&app_regs.REG_PLAY_SOUND_OR_FREQ);

uint8_t aux = read_DIN0;

app_regs.REG_DIGITAL_INPUTS = aux;
app_write_REG_DIGITAL_INPUTS(&app_regs.REG_DIGITAL_INPUTS);
core_func_send_event(ADD_REG_DIGITAL_INPUTS, true);

par_cmd_start_sound(app_regs.REG_DI0_SOUND_INDEX, app_regs.REG_ATTNUATION_LEFT, app_regs.REG_ATTENUATION_RIGHT);

reti();
reti();
}

/************************************************************************/
Expand All @@ -58,10 +45,12 @@ ISR(PORTD_INT0_vect, ISR_NAKED)
/************************************************************************/
/* DIN2 */
/************************************************************************/
/*
ISR(PORTC_INT0_vect, ISR_NAKED)
{
reti();
}
/*
/************************************************************************/
/* PIC32_READY */
Expand Down
Loading

0 comments on commit 480557a

Please sign in to comment.