Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
40d846e
Squashed commit of the following:
MedadRufus Nov 21, 2022
b66021e
deal with bsp
MedadRufus Nov 21, 2022
822ff41
nearly there
MedadRufus Nov 21, 2022
87bf4de
Update config.h
MedadRufus Nov 21, 2022
ef06882
less verbose
MedadRufus Nov 21, 2022
5735de2
Update bsp.c
MedadRufus Nov 21, 2022
c90e733
115200 baud
MedadRufus Nov 23, 2022
4fce567
old fifo size
MedadRufus Nov 23, 2022
edc8fd9
Revert "115200 baud"
MedadRufus Nov 26, 2022
a165385
Update config.h
MedadRufus Nov 26, 2022
95f3674
handle incoming better
MedadRufus Nov 26, 2022
8dfc37b
Update bsp.c
MedadRufus Nov 26, 2022
51598a7
overhaul
MedadRufus Nov 28, 2022
33724b5
Update bsp.c
MedadRufus Nov 28, 2022
5e8f438
Update bsp.c
MedadRufus Nov 28, 2022
b7576ab
Update bsp.c
MedadRufus Nov 28, 2022
4bae663
Update bsp.c
MedadRufus Nov 28, 2022
d5d1d44
Update bsp.c
MedadRufus Nov 28, 2022
dd91970
Update bsp.c
MedadRufus Nov 28, 2022
e9f5a6d
Update ublox.c
MedadRufus Nov 28, 2022
e143497
Update bsp.c
MedadRufus Nov 28, 2022
02de3c6
Update bsp.c
MedadRufus Nov 28, 2022
016a702
Update bsp.c
MedadRufus Nov 28, 2022
d0e7e41
Update board-config.h
MedadRufus Nov 28, 2022
31a65f3
Update uart-board.c
MedadRufus Nov 28, 2022
821da94
Revert "Update uart-board.c"
MedadRufus Nov 28, 2022
b325bf1
put in NAMote72 code
MedadRufus Nov 28, 2022
7b84c5d
Update board.c
MedadRufus Nov 28, 2022
86d7ce1
Update board-config.h
MedadRufus Nov 28, 2022
aae1301
Create gps-board.c
MedadRufus Nov 28, 2022
dba8bb8
Update uart-board.c
MedadRufus Nov 28, 2022
b03ce2d
Update board.c
MedadRufus Nov 28, 2022
ac69323
ok
MedadRufus Nov 28, 2022
0e14c77
Update uart-board.c
MedadRufus Nov 28, 2022
607471e
Update periodic-uplink-lpp.uvprojx
MedadRufus Nov 28, 2022
e83765d
getting there
MedadRufus Nov 28, 2022
a47d2be
Update gps-board.c
MedadRufus Nov 28, 2022
a6e35c2
Update bsp.c
MedadRufus Nov 28, 2022
7e72aa2
Update i2c_middleware.c
MedadRufus Nov 28, 2022
b7049f2
Update board.c
MedadRufus Nov 28, 2022
5630d65
delete more
MedadRufus Nov 28, 2022
11d58a4
Update gps-board.c
MedadRufus Nov 28, 2022
3e97b17
Update board-config.h
MedadRufus Nov 28, 2022
805364b
Squashed commit of the following:
MedadRufus Nov 28, 2022
8f787b5
Update ublox.c
MedadRufus Nov 28, 2022
0162b0b
rx and tx GPS
MedadRufus Nov 29, 2022
65e85d7
delete old gps files
MedadRufus Nov 29, 2022
1160842
delete ublox references
MedadRufus Nov 29, 2022
02ea9c7
use native gps library
MedadRufus Nov 29, 2022
42f64fd
Update bsp.c
MedadRufus Nov 29, 2022
ece62e1
Update callbacks.c
MedadRufus Nov 29, 2022
cd3d336
compromat - use old gps structure
MedadRufus Nov 29, 2022
da88381
put back no load solarvoltage with dummy
MedadRufus Nov 29, 2022
d1e3d2e
delete redundant.
MedadRufus Nov 29, 2022
2735a79
read from native gps structure
MedadRufus Nov 29, 2022
560bf33
configure correctly
MedadRufus Nov 29, 2022
8de96b0
don't endless loop
MedadRufus Nov 29, 2022
11cb10f
pass on data from GPS
MedadRufus Nov 29, 2022
b2693d0
Add another passthrough
MedadRufus Nov 29, 2022
0f52096
Update board.h
MedadRufus Nov 29, 2022
0c46cca
bug
MedadRufus Nov 29, 2022
08dc952
use simpler callback
MedadRufus Nov 29, 2022
f45e366
use UBX only
MedadRufus Nov 29, 2022
13f5f43
1 stop bit
MedadRufus Nov 29, 2022
6220a20
works to shut non ubx out
MedadRufus Nov 29, 2022
76bdc40
wait 4 startup
MedadRufus Nov 29, 2022
fc75a88
working solution
MedadRufus Nov 29, 2022
c3ca578
simpler
MedadRufus Nov 29, 2022
e87b35a
Revert "simpler"
MedadRufus Nov 29, 2022
3dc082a
Create db_dump.txt
MedadRufus Nov 29, 2022
b1a0bc3
works at 9600 baud
MedadRufus Nov 30, 2022
670c0f4
Revert "Revert "simpler""
MedadRufus Nov 30, 2022
80a4631
delete i2c
MedadRufus Nov 30, 2022
163774f
Update periodic-uplink-lpp.uvprojx
MedadRufus Nov 30, 2022
fdfe210
Delete db_dump.txt
MedadRufus Nov 30, 2022
073c0ef
Update .gitignore
MedadRufus Nov 30, 2022
1df930a
revert useless changes
MedadRufus Nov 30, 2022
b403c35
Update bsp.c
MedadRufus Nov 30, 2022
8c06e93
delete ublox mocks
MedadRufus Nov 30, 2022
373088a
formatting
MedadRufus Nov 30, 2022
93399f5
Revert "Up tx count only after final rx"
MedadRufus Dec 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ ipch/
:50003
:50006
.vscode/.cortex-debug.peripherals.state.json
db_dump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\src\boards\B-L072Z-LRWAN1\adc-board.c</FilePath>
</File>
<File>
<FileName>gps-board.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\src\boards\B-L072Z-LRWAN1\gps-board.c</FilePath>
</File>
</Files>
</Group>
<Group>
Expand Down Expand Up @@ -813,16 +818,6 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\src\peripherals\LoRaWAN_config_switcher.c</FilePath>
</File>
<File>
<FileName>SparkFun_Ublox_Arduino_Library.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\src\peripherals\SparkFun_Ublox_Arduino_Library.c</FilePath>
</File>
<File>
<FileName>ublox.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\src\peripherals\ublox.c</FilePath>
</File>
<File>
<FileName>playback.c</FileName>
<FileType>1</FileType>
Expand All @@ -833,11 +828,6 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\src\peripherals\struct.c</FilePath>
</File>
<File>
<FileName>i2c_middleware.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\src\peripherals\i2c_middleware.c</FilePath>
</File>
<File>
<FileName>eeprom_settings_manager.c</FileName>
<FileType>1</FileType>
Expand Down Expand Up @@ -928,6 +918,11 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\src\system\adc.c</FilePath>
</File>
<File>
<FileName>gps.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\src\system\gps.c</FilePath>
</File>
</Files>
</Group>
</Groups>
Expand Down
5 changes: 3 additions & 2 deletions src/apps/LoRaMac/common/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <stdlib.h>
#include "NvmDataMgmt.h"
#include "string.h"
#include "ublox.h"
#include "soft-se-hal.h"
#include "nvmm.h"
#include "struct.h"
Expand All @@ -40,8 +39,10 @@ void OnNvmDataChange(LmHandlerNvmContextStates_t state, uint16_t size)
DisplayNvmDataChange(state, size);

/**
* @brief This is the last event in a Class A transmission, as the last
* @brief Only turn back on the GPS during the Store function call. This is the last
* event in a Class A transmission, so its now safe to turn back on the GPS. The last
* RX window has closed by now.
*
*/
if (state == LORAMAC_HANDLER_NVM_STORE)
{
Expand Down
2 changes: 1 addition & 1 deletion src/apps/LoRaMac/periodic-uplink-lpp/B-L072Z-LRWAN1/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "Commissioning.h"

#include "config.h"
#include "ublox.h"
#include "geofence.h"
#include "iwdg.h"
#include "print_utils.h"
Expand Down Expand Up @@ -244,6 +243,7 @@ static void PrepareTxFrame( void )
return;
}

tx_count_on_this_credential ++;
sensor_read_and_send( &AppData, LmHandlerParams.Region );
uint32_t interval = read_tx_interval_in_eeprom( TX_INTERVAL_EEPROM_ADDRESS,
TX_INTERVAL_GPS_FIX_OK );
Expand Down
10 changes: 7 additions & 3 deletions src/boards/B-L072Z-LRWAN1/board-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ extern "C"
#define LED_3 PB_6
#define LED_4 PB_7
#define GPS_INT PB_13
#define LOAD_ENABLE PA_11

#define LED_GREEN LED_1
#define LED_RED1 LED_2
Expand All @@ -93,8 +92,13 @@ extern "C"
#define I2C_SCL PB_8
#define I2C_SDA PB_9

#define UART_TX PA_9
#define UART_RX PA_10
#define GPS_POWER_ON PA_11
#define GPS_PPS PB_14
#define GPS_UART_TX PA_2
#define GPS_UART_RX PA_3

#define UART1_TX PA_9
#define UART1_RX PA_10

// Debug pins definition.
#define RADIO_DBG_PIN_TX PB_13
Expand Down
27 changes: 21 additions & 6 deletions src/boards/B-L072Z-LRWAN1/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "delay.h"
#include "iwdg.h"
#include "string.h"
#include "gps.h"

#include "stm32l0xx_ll_adc.h"

Expand All @@ -63,7 +64,6 @@
Gpio_t Led1;

Gpio_t Gps_int;
Gpio_t Load_enable;

Gpio_t i2c_scl;
Gpio_t i2c_sda;
Expand All @@ -72,6 +72,7 @@ Gpio_t i2c_sda;
* MCU objects
*/
Uart_t Uart1;
Uart_t Uart2;
I2c_t I2c;
Adc_t Adc;

Expand Down Expand Up @@ -101,7 +102,6 @@ static void CalibrateSystemWakeupTime( void );
*/
static void SystemClockReConfig( void );


/*!
* Timer used at first boot to calibrate the SystemWakeupTime
*/
Expand All @@ -121,7 +121,7 @@ static bool UsbIsConnected = false;
* UART1 FIFO buffers size
*/
#define UART1_FIFO_TX_SIZE 1024
#define UART1_FIFO_RX_SIZE 50 // We should hardly expect any rx data at all. Max 2-3 bytes
#define UART1_FIFO_RX_SIZE 1024 // We should hardly expect any rx data at all. Max 2-3 bytes

uint8_t Uart1TxBuffer[UART1_FIFO_TX_SIZE];
uint8_t Uart1RxBuffer[UART1_FIFO_RX_SIZE];
Expand Down Expand Up @@ -153,6 +153,8 @@ void BoardCriticalSectionEnd( uint32_t *mask )

void BoardInitPeriph( void )
{

GpsInit( );
BSP_sensor_Init();
}

Expand All @@ -171,7 +173,6 @@ void BoardInitMcu( void )
GpioInit( &Led1, LED_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 );

// Load enable for sensors, GPS
GpioInit( &Load_enable, LOAD_ENABLE, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 );
SystemClockConfig( );

#if DEEP_SLEEP_ENABLE
Expand All @@ -182,9 +183,11 @@ void BoardInitMcu( void )

FifoInit( &Uart1.FifoTx, Uart1TxBuffer, UART1_FIFO_TX_SIZE );
FifoInit( &Uart1.FifoRx, Uart1RxBuffer, UART1_FIFO_RX_SIZE );
Uart1.IrqNotify = HostMcuIrqNotify;

// Configure your terminal for 8 Bits data (7 data bit + 1 parity bit), no parity and no flow ctrl
UartInit( &Uart1, UART_1, UART_TX, UART_RX );
UartConfig( &Uart1, RX_TX, 2000000, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL );
UartInit( &Uart1, UART_1, UART1_TX, UART1_RX );
UartConfig( &Uart1, RX_TX, 9600, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL );

I2cInit( &I2c, I2C_1, I2C_SCL, I2C_SDA );

Expand Down Expand Up @@ -546,3 +549,15 @@ void assert_failed( uint8_t* file, uint32_t line )
}
}
#endif

void HostMcuIrqNotify(UartNotifyId_t id)
{
uint8_t data;
if (id == UART_NOTIFY_RX)
{
if (UartGetChar(&Uart1, &data) == 0)
{
UartPutChar(&Uart2, data);
}
}
}
160 changes: 160 additions & 0 deletions src/boards/B-L072Z-LRWAN1/gps-board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*!
* \file gps-board.c
*
* \brief Target board GPS driver implementation
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2017 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*
* \author Gregory Cristian ( Semtech )
*/
#include "board-config.h"
#include "board.h"
#include "gpio.h"
#include "gps.h"
#include "uart.h"
#include "lpm-board.h"
#include "rtc-board.h"
#include "gps-board.h"
#include "delay.h"

/*!
* FIFO buffers size
*/
#define FIFO_TX_SIZE 128
#define FIFO_RX_SIZE 128

static uint8_t TxBuffer[FIFO_TX_SIZE];
static uint8_t RxBuffer[FIFO_RX_SIZE];

/*!
* \brief Buffer holding the raw data received from the gps
*/
static uint8_t NmeaString[128];

/*!
* \brief Maximum number of data byte that we will accept from the GPS
*/
static volatile uint8_t NmeaStringSize = 0;

static Gpio_t GpsPowerEn;
static Gpio_t GpsPps;

static volatile bool GpsPowerEnInverted = true;

extern Uart_t Uart2;
extern Uart_t Uart1;

void GpsMcuOnPpsSignal( void* context )
{
bool parseData = true;

// GpsPpsHandler( &parseData );

if( parseData == true )
{
// Disables lowest power modes
// LpmSetStopMode( LPM_GPS_ID , LPM_DISABLE );


}
}

void GpsMcuInvertPpsTrigger( void )
{

}
#define STRING_SIZE 28
uint8_t ubxOnlyString[STRING_SIZE] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0x79};

void GpsMcuInit( void )
{
NmeaStringSize = 0;

GpioInit( &GpsPowerEn, GPS_POWER_ON, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 );

GpioInit( &GpsPps, GPS_PPS, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioSetInterrupt( &GpsPps, IRQ_FALLING_EDGE, IRQ_VERY_LOW_PRIORITY, &GpsMcuOnPpsSignal );

FifoInit( &Uart2.FifoRx, RxBuffer, FIFO_RX_SIZE );
FifoInit( &Uart2.FifoTx, TxBuffer, FIFO_TX_SIZE );
Uart2.IrqNotify = GpsMcuIrqNotify;

UartInit( &Uart2, UART_2, GPS_UART_TX, GPS_UART_RX );
UartConfig( &Uart2, RX_TX, 9600, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL );
GpsMcuStart( );

DelayMs(1000);

while (UartPutBuffer(&Uart2, (uint8_t *)ubxOnlyString, (uint16_t)STRING_SIZE) != 0)
{
};
}

void GpsMcuStart( void )
{
if( GpsPowerEnInverted == true )
{
GpioWrite( &GpsPowerEn, 0 ); // power up the GPS
}
else
{
GpioWrite( &GpsPowerEn, 1 ); // power up the GPS
}
}

void GpsMcuStop( void )
{
if( GpsPowerEnInverted == true )
{
GpioWrite( &GpsPowerEn, 1 ); // power down the GPS
}
else
{
GpioWrite( &GpsPowerEn, 0 ); // power down the GPS
}
}

void GpsMcuProcess( void )
{

}

void GpsMcuIrqNotify( UartNotifyId_t id )
{
uint8_t data;
if( id == UART_NOTIFY_RX )
{
if( UartGetChar( &Uart2, &data ) == 0 )
{
UartPutChar( &Uart1, data );
if( ( data == '$' ) || ( NmeaStringSize >= 127 ) )
{
NmeaStringSize = 0;
}

NmeaString[NmeaStringSize++] = ( int8_t )data;

if( data == '\n' )
{
NmeaString[NmeaStringSize++] = '\0';
GpsParseGpsData( ( int8_t* )NmeaString, NmeaStringSize );
// UartDeInit( &Uart2 );
// Enables lowest power modes
// LpmSetStopMode( LPM_GPS_ID , LPM_ENABLE );
}
}
}
}
Loading