kopia lustrzana https://github.com/bristol-seds/pico-tracker
Moved gps usart over to glck1 (txco). Should be more stable. Added (untested) test case to check baud rate accuaracy
rodzic
f3b0510d76
commit
ea2f7b5c27
|
@ -43,7 +43,7 @@
|
||||||
## Clock Layout
|
## Clock Layout
|
||||||
|
|
||||||
```
|
```
|
||||||
[osc8m] --> [glck0] +--> [gps usart]
|
[osc8m] --> [glck0] +
|
||||||
|--> [tc5]
|
|--> [tc5]
|
||||||
|--> [adc]
|
|--> [adc]
|
||||||
|--> [extint]
|
|--> [extint]
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
| | --> [glck1] +--> [tc0, telemetry tick]
|
| | --> [glck1] +--> [tc0, telemetry tick]
|
||||||
tcxo --> [xosc] --> 1| | |--> [tc2, count tcxo] <-- gps timepulse
|
tcxo --> [xosc] --> 1| | |--> [tc2, count tcxo] <-- gps timepulse
|
||||||
|/ |--> [glck7] --> [tc5] --> si_gpio1
|
|/ |--> [glck7] --> [tc5] --> si_gpio1
|
||||||
|
|
| |--> [gps usart]
|
||||||
*USE_XOSC*
|
*USE_XOSC*
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#define GPS_SERCOM_MIGO_PIN PIN_PA07
|
#define GPS_SERCOM_MIGO_PIN PIN_PA07
|
||||||
#define GPS_SERCOM_MIGO_PINMUX PINMUX_PA07D_SERCOM0_PAD3
|
#define GPS_SERCOM_MIGO_PINMUX PINMUX_PA07D_SERCOM0_PAD3
|
||||||
#define GPS_SERCOM_MUX USART_RX_3_TX_2_XCK_3
|
#define GPS_SERCOM_MUX USART_RX_3_TX_2_XCK_3
|
||||||
|
#define GPS_GCLK GCLK_GENERATOR_1
|
||||||
#define GPS_BAUD_RATE 9600
|
#define GPS_BAUD_RATE 9600
|
||||||
#define GPS_PLATFORM_MODEL UBX_PLATFORM_MODEL_AIRBORNE_1G
|
#define GPS_PLATFORM_MODEL UBX_PLATFORM_MODEL_AIRBORNE_1G
|
||||||
#define GPS_TIMEPULSE_PIN PIN_PA05
|
#define GPS_TIMEPULSE_PIN PIN_PA05
|
||||||
|
@ -163,7 +164,7 @@
|
||||||
* APRS
|
* APRS
|
||||||
*/
|
*/
|
||||||
#define APRS_ENABLE 1
|
#define APRS_ENABLE 1
|
||||||
#define APRS_USE_GEOFENCE 1
|
#define APRS_USE_GEOFENCE 0
|
||||||
#define APRS_POWER RF_POWER_14dBm
|
#define APRS_POWER RF_POWER_14dBm
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -474,10 +474,9 @@ void gps_usart_init_enable(uint32_t baud_rate)
|
||||||
true, /** Enable transmitter */
|
true, /** Enable transmitter */
|
||||||
false, /** Sample on the rising edge of XLCK */
|
false, /** Sample on the rising edge of XLCK */
|
||||||
false, /** Use the external clock applied to the XCK pin. */
|
false, /** Use the external clock applied to the XCK pin. */
|
||||||
|
|
||||||
0, /** External clock frequency in synchronous mode. */
|
0, /** External clock frequency in synchronous mode. */
|
||||||
true, /** Run in standby */
|
true, /** Run in standby */
|
||||||
GCLK_GENERATOR_0, /** GCLK generator source */
|
GPS_GCLK, /** GCLK generator source */
|
||||||
GPS_SERCOM_MOGI_PINMUX, /** PAD0 pinmux */
|
GPS_SERCOM_MOGI_PINMUX, /** PAD0 pinmux */
|
||||||
GPS_SERCOM_MIGO_PINMUX, /** PAD1 pinmux */
|
GPS_SERCOM_MIGO_PINMUX, /** PAD1 pinmux */
|
||||||
PINMUX_UNUSED, /** PAD2 pinmux */
|
PINMUX_UNUSED, /** PAD2 pinmux */
|
||||||
|
|
|
@ -16,7 +16,11 @@ ifdef name
|
||||||
@$(SED) "s/\[template\]/$(name)/g" template/template.h > tc/$(name).h
|
@$(SED) "s/\[template\]/$(name)/g" template/template.h > tc/$(name).h
|
||||||
@$(SED) "s/\[template\]/$(name)/g" template/template.py > tc/$(name).py
|
@$(SED) "s/\[template\]/$(name)/g" template/template.py > tc/$(name).py
|
||||||
@$(SED) -i "s/\/\* \[new_tc\] \*\//\#include \"$(name).h\"\n\/\* \[new_tc\] \*\//" tmain.c
|
@$(SED) -i "s/\/\* \[new_tc\] \*\//\#include \"$(name).h\"\n\/\* \[new_tc\] \*\//" tmain.c
|
||||||
@$(ECHO) "Done"
|
@$(ECHO) "Done!"
|
||||||
|
@$(ECHO)
|
||||||
|
@$(ECHO) "Your testcase is at tc/$(name)_tc.{py,h}"
|
||||||
|
@$(ECHO)
|
||||||
else
|
else
|
||||||
@$(ECHO) "Please specify a name for the test case!! Like 'make name=my_tc'"
|
@$(ECHO) "Please specify a name for the test case!! Like 'make name=new'"
|
||||||
|
@$(ECHO) "(Note the '_tc' will be appended automatically)"
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
#ifndef __verification__
|
||||||
|
#define __verification__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************//* gps_baud_error_tc *//****************************/
|
||||||
|
/**
|
||||||
|
* Calculates the real hardware baud rate for gps serial
|
||||||
|
*/
|
||||||
|
#include "hw_config.h"
|
||||||
|
#include "sercom/sercom.h"
|
||||||
|
#include "sercom/usart.h"
|
||||||
|
|
||||||
|
/* Parameters in */
|
||||||
|
struct gps_baud_error_tc_params {
|
||||||
|
|
||||||
|
/* Input paramters to your test case go here */
|
||||||
|
uint32_t dummy;
|
||||||
|
|
||||||
|
} gps_baud_error_tc_params;
|
||||||
|
/* Results out */
|
||||||
|
struct gps_baud_error_tc_results {
|
||||||
|
|
||||||
|
/* Result values should be populated here */
|
||||||
|
uint32_t intended_baud;
|
||||||
|
uint32_t peripheral_clock;
|
||||||
|
uint16_t calculated_baud;
|
||||||
|
|
||||||
|
} gps_baud_error_tc_results;
|
||||||
|
/* Function */
|
||||||
|
__verification__ void gps_baud_error_tc(void) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main body of the test case goes here.
|
||||||
|
*
|
||||||
|
* Use the input parameters to run the test case. Populate the
|
||||||
|
* results structure at the end
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t sercom_index = _sercom_get_sercom_inst_index((Sercom*)GPS_SERCOM);
|
||||||
|
uint32_t gclk_index = sercom_index + SERCOM0_GCLK_ID_CORE;
|
||||||
|
uint32_t baudrate = GPS_BAUD_RATE;
|
||||||
|
uint16_t baud; /* The actual register value */
|
||||||
|
|
||||||
|
enum sercom_asynchronous_operation_mode mode = SERCOM_ASYNC_OPERATION_MODE_ARITHMETIC;
|
||||||
|
enum sercom_asynchronous_sample_num sample_num = SERCOM_ASYNC_SAMPLE_NUM_16;
|
||||||
|
|
||||||
|
uint32_t peripheral_clock = system_gclk_chan_get_hz(gclk_index);
|
||||||
|
|
||||||
|
_sercom_get_async_baud_val(baudrate,
|
||||||
|
peripheral_clock, &baud, mode, sample_num);
|
||||||
|
|
||||||
|
gps_baud_error_tc_results.intended_baud = baudrate;
|
||||||
|
gps_baud_error_tc_results.peripheral_clock = peripheral_clock;
|
||||||
|
gps_baud_error_tc_results.calculated_baud = baud;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Imports
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("./test")
|
||||||
|
import main
|
||||||
|
|
||||||
|
from random import randint
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Test Script
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class gps_baud_error_tc:
|
||||||
|
def __init__(self):
|
||||||
|
self.name = self.__class__.__name__
|
||||||
|
self.iterations = 20
|
||||||
|
|
||||||
|
|
||||||
|
def get_test(self):
|
||||||
|
"""Returns some suitable test parameters"""
|
||||||
|
params = main.struct_gps_baud_error_tc_params()
|
||||||
|
|
||||||
|
"""
|
||||||
|
Assign input parameters here
|
||||||
|
"""
|
||||||
|
|
||||||
|
return params
|
||||||
|
|
||||||
|
def is_correct(self, params, result, print_info):
|
||||||
|
"""Returns if a result is correct for the given parameters"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
Compare result and params here, decide sth.
|
||||||
|
Can use print_info
|
||||||
|
"""
|
||||||
|
|
||||||
|
print_info("{} Hz on a {} MHz clock (Intended {} Hz)".format(
|
||||||
|
result["calculated_baud"],
|
||||||
|
result["peripheral_clock"],
|
||||||
|
result["intended_baud"]
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
|
@ -45,6 +45,7 @@
|
||||||
#include "backlog_write_read.h"
|
#include "backlog_write_read.h"
|
||||||
#include "mem_erase_all.h"
|
#include "mem_erase_all.h"
|
||||||
#include "adc_battery_solar_read.h"
|
#include "adc_battery_solar_read.h"
|
||||||
|
#include "gps_baud_error.h"
|
||||||
/* [new_tc] */
|
/* [new_tc] */
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue