Skip to content

Commit

Permalink
Allow reading the firmware version attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
Onwrikbaar committed Nov 20, 2024
1 parent 0ee14b8 commit 5f9c289
Show file tree
Hide file tree
Showing 7 changed files with 1,457 additions and 1,462 deletions.
2,890 changes: 1,440 additions & 1,450 deletions firmware/build/neodk_g071.hex

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion firmware/inc/app_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum {
ET_THIRD_PARTY = ET_AO_FIRST_APP_EVENT, // To keep other libs working.
ET_APP_HEARTBEAT, ET_ADC_DATA_AVAILABLE,
ET_DEBUG_SYNC, ET_DATAGRAM_SYNC, ET_INCOMING_PACKET,
ET_CONTROLLER_CONNECTED, ET_CONTROLLER_DISCONNECTED, ET_ATTRIBUTE_CHANGED,
ET_CONTROLLER_CONNECTED, ET_CONTROLLER_DISCONNECTED,
ET_PLAY, ET_PAUSE, ET_STOP, ET_UNKNOWN_COMMAND, ET_TOGGLE_PLAY_PAUSE,
ET_SELECT_NEXT_PATTERN, ET_SELECT_PATTERN_BY_NAME, ET_SET_INTENSITY,
ET_BURST_REQUESTED, ET_BURST_REJECTED, ET_BURST_STARTED, ET_BURST_COMPLETED, ET_BURST_EXPIRED,
Expand Down
1 change: 1 addition & 0 deletions firmware/inc/bsp_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ bool BSP_startPulseTrain(PulseTrain const *);
void BSP_triggerADC(void);

// Firmware update.
char const *BSP_firmwareVersion();
void BSP_gotoDfuMode(void);

// Close any communication ports and release resources, if applicable.
Expand Down
8 changes: 7 additions & 1 deletion firmware/src/bsp_stm32g071.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static IRQn_Type const app_timer_irq = TIM2_IRQn;

static BSP bsp = {0};

// A couple of functions from STM's infamous HAL.
// Using a couple of functions from STM's infamous HAL.
extern HAL_StatusTypeDef HAL_InitTick(uint32_t);
extern void HAL_IncTick(void);

Expand Down Expand Up @@ -643,6 +643,12 @@ void BSP_init()
}


char const *BSP_firmwareVersion()
{
return "v0.40-beta";
}


void BSP_initComms(void)
{
initUSART2(115200UL);
Expand Down
8 changes: 5 additions & 3 deletions firmware/src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ static void handleReadRequest(Controller *me, AttributeAction const *aa)
{
switch (aa->attribute_id)
{
case AI_FIRMWARE_VERSION:
// TODO Implement.
case AI_FIRMWARE_VERSION: {
char const *fw_version = BSP_firmwareVersion();
attributeChanged(me, AI_FIRMWARE_VERSION, EE_UTF8_1LEN, (uint8_t const *)fw_version, strlen(fw_version));
break;
}
case AI_VOLTAGES:
Attribute_awaitRead(aa->attribute_id, (AttrNotifier)&attributeChanged, me);
BSP_triggerADC();
Expand Down Expand Up @@ -301,7 +303,7 @@ Controller *Controller_new()

void Controller_init(Controller *me, Sequencer *sequencer, DataLink *datalink)
{
strncpy(me->box_name, "My first Neostim box", sizeof me->box_name - 1);
strncpy(me->box_name, "Mean Machine", sizeof me->box_name - 1);
me->sequencer = sequencer;
me->datalink = datalink;
}
Expand Down
6 changes: 3 additions & 3 deletions firmware/src/debug_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void gatherInputCharacters(CmndInterp *me, char ch)

static void setIntensity(CmndInterp *me, uint8_t intensity_perc)
{
EventQueue_postEvent(me->delegate, ET_SET_INTENSITY, &intensity_perc, sizeof intensity_perc);
EventQueue_postEvent((EventQueue *)me->sequencer, ET_SET_INTENSITY, &intensity_perc, sizeof intensity_perc);
}


Expand Down Expand Up @@ -90,7 +90,7 @@ static void interpretCommand(CmndInterp *me, char ch)
BSP_toggleTheLED();
break;
case 'n':
EventQueue_postEvent(me->delegate, ET_SELECT_NEXT_PATTERN, NULL, 0);
EventQueue_postEvent((EventQueue *)me->sequencer, ET_SELECT_NEXT_PATTERN, NULL, 0);
break;
case 'q': { // Quit.
int sig = 2; // Simulate Ctrl-C.
Expand All @@ -101,7 +101,7 @@ static void interpretCommand(CmndInterp *me, char ch)
changeIntensity(me, +2);
break;
case 'v':
CLI_logf("Firmware v0.39-beta\n");
CLI_logf("Firmware %s\n", BSP_firmwareVersion());
break;
case 'w': // Allow rediscovery by Dweeb.
DataLink_waitForSync(me->datalink);
Expand Down
4 changes: 0 additions & 4 deletions firmware/src/neodk_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ static void dispatchEvent(Boss *me, AOEvent const *evt)
case ET_BUTTON_RELEASED:
// Ignore for now.
break;
case ET_SELECT_NEXT_PATTERN:
case ET_SET_INTENSITY:
EventQueue_repostEvent((EventQueue *)me->sequencer, evt);
break;
default:
BSP_logf("%s(%hu)?\n", __func__, evt_type);
}
Expand Down

0 comments on commit 5f9c289

Please sign in to comment.