Skip to content

Commit

Permalink
BSP files and build target for Micro17
Browse files Browse the repository at this point in the history
  • Loading branch information
silseva committed Jun 17, 2024
1 parent de93cb7 commit 70498a4
Show file tree
Hide file tree
Showing 7 changed files with 469 additions and 0 deletions.
44 changes: 44 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,24 @@ mod17_src += openrtx_src + stm32f405_src + miosix_cm4f_src + ui_src_module17
mod17_inc += openrtx_inc + stm32f405_inc + miosix_cm4f_inc
mod17_def += openrtx_def + stm32f405_def + miosix_cm4f_def

##
## Micro 17
##
micro17_src = ['platform/targets/Micro17/platform.c',
'platform/drivers/baseband/radio_Micro17.cpp',
'platform/drivers/NVM/nvmem_Micro17.c',
'platform/drivers/stubs/audio_stub.c',
'platform/drivers/stubs/cps_io_stub.c',
'platform/drivers/stubs/display_stub.c',
'platform/drivers/stubs/keyboard_stub.c']

micro17_inc = ['platform/targets/Micro17']
micro17_def = {'PLATFORM_MICRO17': ''}

micro17_src += openrtx_src + stm32g474_src + miosix_cm4f_src + ui_src_default
micro17_inc += openrtx_inc + stm32g474_inc + miosix_cm4f_inc
micro17_def += openrtx_def + stm32g474_def + miosix_cm4f_def

##
## -------------------------- Compilation arguments ----------------------------
##
Expand Down Expand Up @@ -539,6 +557,15 @@ foreach k, v : mod17_def
endif
endforeach

micro17_args = []
foreach k, v : micro17_def
if v == ''
micro17_args += '-D@0@'.format(k)
else
micro17_args += '-D@0@=@1@'.format(k, v)
endif
endforeach

linux_opts = {
'sources' : linux_default_src,
'include_directories': linux_inc,
Expand Down Expand Up @@ -626,6 +653,16 @@ mod17_opts = {
'-Wl,--print-memory-usage'],
}

micro17_opts = {
'sources' : micro17_src,
'include_directories': micro17_inc,
'dependencies' : [codec2_dep],
'c_args' : micro17_args,
'cpp_args' : micro17_args,
'link_args' : ['-Wl,-T../platform/mcu/STM32G4xx/linker_script.ld',
'-Wl,--print-memory-usage'],
}

ttwrplus_opts = {
'sources' : ['CMakeLists.txt'],
'include_directories': [],
Expand Down Expand Up @@ -697,6 +734,13 @@ targets = [
'wrap' : ' ',
'load_addr': ' '
},
{
'name' : 'micro17',
'opts' : micro17_opts,
'flashable': true,
'wrap' : ' ',
'load_addr': ' '
},
{
'name' : 'ttwrplus',
'opts' : ttwrplus_opts,
Expand Down
44 changes: 44 additions & 0 deletions openrtx/include/calibration/calibInfo_Micro17.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/***************************************************************************
* Copyright (C) 2024 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* Frederik Saraci IU2NRO *
* Silvano Seva IU2KWO *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/

#ifndef CALIBINFO_MICRO17_H
#define CALIBINFO_MICRO17_H

#include <datatypes.h>
#include <stdint.h>

/**
* \brief Calibration data for Micro17.
*/
typedef struct
{
uint16_t tx_wiper; ///< Baseband TX potentiometer
uint16_t rx_wiper; ///< Baseband RX potentiometer
uint16_t mic_wiper; ///< Microphone input potentiometer
uint16_t spk_wiper; ///< Speaker output potentiometer
uint8_t bb_tx_invert : 1, ///< Invert TX baseband
bb_rx_invert : 1, ///< Invert RX baseband
ptt_in_level : 1, ///< PTT in acive level
ptt_out_level : 1, ///< PTT out active level
_padding : 4;
}
micro17Calib_t;

#endif /* CALIBINFO_MICRO17_H */
74 changes: 74 additions & 0 deletions platform/drivers/NVM/nvmem_Micro17.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/***************************************************************************
* Copyright (C) 2024 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* Frederik Saraci IU2NRO *
* Silvano Seva IU2KWO *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/

#include <interfaces/nvmem.h>
#include <calibInfo_Micro17.h>

micro17Calib_t micro17CalData;


void nvm_init()
{

}

void nvm_terminate()
{

}

void nvm_readCalibData(void *buf)
{
(void) buf;
}

void nvm_readHwInfo(hwInfo_t *info)
{
(void) info;
}

int nvm_readVfoChannelData(channel_t *channel)
{
(void) channel;

return -1;
}

int nvm_readSettings(settings_t *settings)
{
(void) settings;

return -1;
}

int nvm_writeSettings(const settings_t *settings)
{
(void) settings;

return -1;
}

int nvm_writeSettingsAndVfo(const settings_t *settings, const channel_t *vfo)
{
(void) settings;
(void) vfo;

return -1;
}
115 changes: 115 additions & 0 deletions platform/drivers/baseband/radio_Micro17.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/***************************************************************************
* Copyright (C) 2024 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* Frederik Saraci IU2NRO *
* Silvano Seva IU2KWO *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/

#include <interfaces/radio.h>
#include <peripherals/gpio.h>
#include <calibInfo_Micro17.h>
#include <hwconfig.h>

static enum opstatus radioStatus; // Current operating status
extern micro17Calib_t micro17CalData; // Calibration data


void radio_init(const rtxStatus_t *rtxState)
{
(void) rtxState;

// Configure PTT output GPIO and set it to idle state (TX off)
gpio_setMode(PTT_OUT, OUTPUT);
radio_disableRtx();

radioStatus = OFF;
}

void radio_terminate()
{
radioStatus = OFF;
}

void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset)
{
(void) vhfOffset;
(void) uhfOffset;
}

void radio_setOpmode(const enum opmode mode)
{
(void) mode;
}

bool radio_checkRxDigitalSquelch()
{
return false;
}

void radio_enableAfOutput()
{

}

void radio_disableAfOutput()
{

}

void radio_enableRx()
{
radioStatus = RX;

// Module17 PTT output is open drain. This means that, on MCU side, we have
// to assert the gpio to bring it to low state.
if(micro17CalData.ptt_out_level)
gpio_setPin(PTT_OUT);
else
gpio_clearPin(PTT_OUT);
}

void radio_enableTx()
{
radioStatus = TX;

if(micro17CalData.ptt_out_level)
gpio_clearPin(PTT_OUT);
else
gpio_setPin(PTT_OUT);
}

void radio_disableRtx()
{
if(micro17CalData.ptt_out_level)
gpio_setPin(PTT_OUT);
else
gpio_clearPin(PTT_OUT);
}

void radio_updateConfiguration()
{

}

rssi_t radio_getRssi()
{
return -123.0f;
}

enum opstatus radio_getStatus()
{
return radioStatus;
}
37 changes: 37 additions & 0 deletions platform/targets/Micro17/hwconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/***************************************************************************
* Copyright (C) 2024 Silvano Seva IU2KWO *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/

#ifndef HWCONFIG_H
#define HWCONFIG_H

#include <stm32g4xx.h>
#include "pinmap.h"

/* Screen dimensions */
#define CONFIG_SCREEN_WIDTH 128
#define CONFIG_SCREEN_HEIGHT 64

/* Screen pixel format */
#define CONFIG_PIX_FMT_BW

/* Device has no battery */
#define CONFIG_BAT_NONE

/* Device supports M17 mode */
#define CONFIG_M17

#endif
48 changes: 48 additions & 0 deletions platform/targets/Micro17/pinmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/***************************************************************************
* Copyright (C) 2024 Silvano Seva IU2KWO *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/

#ifndef PINMAP_H
#define PINMAP_H

#include <stm32g4xx.h>

/* PTT control */
#define PTT_IN GPIOC,13
#define PTT_OUT GPIOA,6

/* Audio */
#define AUDIO_IN GPIOA,2 // ADC1_IN3
#define AUDIO_OUT GPIOA,5 // DAC1_OUT2
#define BASEBAND_IN GPIOA,1 // ADC12_IN2
#define BASEBAND_OUT GPIOA,4 // DAC1_OUT1
#define BASEBAND_BYP GPIOA,7
#define AUDIOOUT_MUTE GPIOB,1

/* I2C for MCP4451 */
#define I2C_SDA GPIOB,9
#define I2C_SCL GPIOA,15

/* Serial ports */
#define MCU_TX GPIOA,9
#define MCU_RX GPIOA,10
#define USART3_TX GPIOB,10
#define USART3_RX GPIOB,11

/* Misc */
#define AIN_HWVER GPIOA,3 // ADC1_IN4

#endif /* PINMAP_H */
Loading

0 comments on commit 70498a4

Please sign in to comment.