Merge branch 'DiSlord_tinySA-V4' into tinySA-V4-SI4463

multi_trace
erikkaashoek 5 years ago
commit 02c5ed2141

@ -267,8 +267,8 @@
PIN_OTYPE_PUSHPULL(13) | \
PIN_OTYPE_PUSHPULL(GPIO_SPI2_SDO) | \
PIN_OTYPE_PUSHPULL(GPIO_SPI2_SDI))
#define VAL_GPIOB_OSPEEDR (PIN_PUPDR_FLOATING(GPIOB_XN) | \
PIN_PUPDR_FLOATING(GPIOB_YN) | \
#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_100M(GPIOB_XN) | \
PIN_OSPEED_100M(GPIOB_YN) | \
PIN_OSPEED_100M(2) | \
PIN_OSPEED_100M(3) | \
PIN_OSPEED_100M(4) | \

@ -290,8 +290,8 @@
PIN_OTYPE_PUSHPULL(13) | \
PIN_OTYPE_PUSHPULL(14) | \
PIN_OTYPE_PUSHPULL(15))
#define VAL_GPIOB_OSPEEDR (PIN_PUPDR_FLOATING(GPIOB_XN) | \
PIN_PUPDR_FLOATING(GPIOB_YN) | \
#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_100M(GPIOB_XN) | \
PIN_OSPEED_100M(GPIOB_YN) | \
PIN_OSPEED_100M(GPIO_LCD_RESET) | \
PIN_OSPEED_100M(GPIOB_SPI_SCLK) | \
PIN_OSPEED_100M(GPIOB_SPI_MISO) | \

@ -257,6 +257,7 @@ static char *ftoaS(char *p, float num, int precision) {
#define PAD_ZERO 16
#define PLUS_SPACE 32
#define DEFAULT_PRESCISION 64
#define _32_BIT_FLOAT 128
int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
char *p, *s, c, filler=' ';
@ -308,6 +309,8 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
else if (*fmt == ' ')
state|=PLUS_SPACE;
#endif
else if (*fmt == 'b')
state|=_32_BIT_FLOAT;
else
break;
fmt++;
@ -405,6 +408,9 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
#if CHPRINTF_USE_FLOAT
case 'F':
case 'f':
if (state & _32_BIT_FLOAT)
value.u = va_arg(ap, uint32_t);
else
value.f = va_arg(ap, double);
if (value.f < 0) {
state|=NEGATIVE;

@ -34,6 +34,8 @@
#define LCD_RESET_NEGATE palSetPad(GPIO_LCD_RESET_PORT, GPIO_LCD_RESET)
#define LCD_DC_CMD palClearPad(GPIO_LCD_CD_PORT, GPIO_LCD_CD)
#define LCD_DC_DATA palSetPad(GPIO_LCD_CD_PORT, GPIO_LCD_CD)
#define SD_CS_LOW palClearLine(LINE_SD_CS)
#define SD_CS_HIGH palSetLine(LINE_SD_CS)
#else
#define LCD_CS_LOW palClearPad(GPIOB, GPIOB_LCD_CS)
#define LCD_CS_HIGH palSetPad(GPIOB, GPIOB_LCD_CS)
@ -45,6 +47,8 @@
// LCD display SPI bus
#define LCD_SPI SPI1
// SD card spi bus
#define SD_SPI SPI1
// Custom display definition
#ifdef LCD_DRIVER_ILI9341
@ -65,6 +69,11 @@
#define __USE_DISPLAY_DMA_RX__
#endif
// Define SD SPI speed on work
#define SD_SPI_SPEED SPI_BR_DIV2
// Define SD SPI speed on initialization (100-400kHz need)
#define SD_INIT_SPI_SPEED SPI_BR_DIV256
// Disable DMA rx on disabled DMA tx
#ifndef __USE_DISPLAY_DMA__
#undef __USE_DISPLAY_DMA_RX__
@ -223,6 +232,7 @@ void spi_DropRx(void){
// Drop Rx buffer after tx and wait tx complete
while (SPI_RX_IS_NOT_EMPTY(LCD_SPI)||SPI_IS_BUSY(LCD_SPI))
(void)SPI_READ_8BIT(LCD_SPI);
(void)SPI_READ_8BIT(LCD_SPI);
}
//*****************************************************
@ -346,8 +356,11 @@ void set_SPI_mode(uint16_t mode){
// Disable current mode
switch(current_spi_mode){
case SPI_MODE_LCD:
LCD_CS_HIGH;
break;
case SPI_MODE_SD_CARD:
case SPI_MODE_SD_CARD_LOW:
SD_CS_HIGH;
break;
case SPI_MODE_SI:
stop_SI4432_SPI_mode();
@ -359,16 +372,18 @@ void set_SPI_mode(uint16_t mode){
// Enable new mode
switch(mode){
case SPI_MODE_LCD:
SPI_BR_SET(LCD_SPI, LCD_SPI_SPEED); // Set Baud rate for LCD
break;
case SPI_MODE_SD_CARD:
LCD_CS_HIGH;
SPI_BR_SET(LCD_SPI, SD_SPI_SPEED); // Set Baud rate for SD work
break;
case SPI_MODE_SD_CARD_LOW:
SPI_BR_SET(LCD_SPI, SD_INIT_SPI_SPEED); // Set Baud rate for SD init
break;
case SPI_MODE_SI:
LCD_CS_HIGH;
start_SI4432_SPI_mode();
break;
case SPI_MODE_PE:
LCD_CS_HIGH;
start_PE4312_SPI_mode();
break;
}
@ -546,7 +561,7 @@ void ili9341_init(void)
for (p = LCD_INIT; *p; ) {
send_command(p[0], p[1], &p[2]);
p += 2 + p[1];
chThdSleepMilliseconds(5);
chThdSleepMilliseconds(2);
}
ili9341_clear_screen();
LCD_CS_HIGH;
@ -1188,15 +1203,6 @@ void ili9341_test(int mode)
// Define sector size
#define SD_SECTOR_SIZE 512
// SD card spi bus
#define SD_SPI SPI1
// Define SD SPI speed on work
#define SD_SPI_SPEED SPI_BR_DIV2
// div4 give less error and high speed for Rx
#define SD_SPI_RX_SPEED SPI_BR_DIV2
// Define SD SPI speed on initialization (100-400kHz need)
#define SD_INIT_SPI_SPEED SPI_BR_DIV256
// Set number of try read or write sector data (1 only one try)
#define SD_READ_WRITE_REPEAT 1
// Local values for SD card state
@ -1225,23 +1231,23 @@ void testLog(void){
//*******************************************************
// SD card SPI functions
//*******************************************************
#define SD_CS_LOW palClearLine(LINE_SD_CS)
#define SD_CS_HIGH palSetLine(LINE_SD_CS)
bool SD_Inserted(void){
return !(palReadPort(GPIOB)&(1<<GPIO_SD_CD));
}
static void SD_Select_SPI(uint32_t speed) {
static void SD_Select_SPI(void) {
set_SPI_mode(SPI_MODE_SD_CARD);
SPI_BR_SET(SD_SPI, speed); // Set Baud rate control for SD card
SD_CS_LOW; // Select SD Card
}
static void SD_Select_SPI_LOW(void) {
set_SPI_mode(SPI_MODE_SD_CARD_LOW);
SD_CS_LOW; // Select SD Card
}
static void SD_Unselect_SPI(void) {
SD_CS_HIGH; // Unselect SD Card
spi_RxByte(); // Dummy read/write one Byte recommend for SD after CS up
SPI_BR_SET(LCD_SPI, LCD_SPI_SPEED); // Restore Baud rate for LCD
}
//*******************************************************
@ -1318,14 +1324,13 @@ static inline uint8_t SD_ReadR1(uint32_t cnt) {
static inline bool SD_WaitDataToken(uint8_t token, uint32_t wait_time) {
uint8_t res;
uint32_t time = chVTGetSystemTimeX();
uint32_t count = 0;
uint8_t count = 0;
do{
if ((res = spi_RxByte()) == token)
return true;
count++;
// Check timeout only every 65536 bytes read (~50ms interval)
if ((count&0xFFFF) == 0)
if ((chVTGetSystemTimeX() - time) > wait_time)
// Check timeout only every 256 bytes read (~8ms)
if (count == 0 && (chVTGetSystemTimeX() - time) > wait_time)
break;
}while (res == 0xFF);
return false;
@ -1342,14 +1347,13 @@ static inline uint8_t SD_WaitDataAccept(uint32_t cnt) {
static uint8_t SD_WaitNotBusy(uint32_t wait_time) {
uint8_t res;
uint32_t time = chVTGetSystemTimeX();
uint32_t count = 0;
uint8_t count = 0;
do{
if ((res = spi_RxByte()) == 0xFF)
return res;
count++;
// Check timeout only every 65536 bytes read (~50ms interval)
if ((count&0xFFFF) == 0)
if ((chVTGetSystemTimeX() - time) > wait_time)
// Check timeout only every 256 bytes read (~8ms)
if (count == 0 && (chVTGetSystemTimeX() - time) > wait_time)
break;
}while (1);
return 0;
@ -1465,9 +1469,9 @@ static uint8_t SD_SendCmd(uint8_t cmd, uint32_t arg) {
}
// Power on SD
void SD_PowerOn(void) {
static void SD_PowerOn(void) {
uint16_t n;
SD_Select_SPI(SD_INIT_SPI_SPEED);
SD_Select_SPI_LOW();
// Dummy TxRx 80 bits for power up SD
for (n=0;n<10;n++)
@ -1475,9 +1479,6 @@ void SD_PowerOn(void) {
// Set SD card to idle state
if (SD_SendCmd(CMD0, 0) == SD_R1_IDLE)
Stat|= STA_POWER_ON;
else{
Stat = STA_NOINIT;
}
SD_Unselect_SPI();
}
@ -1513,13 +1514,16 @@ DSTATUS disk_initialize(BYTE pdrv) {
total_time = chVTGetSystemTimeX();
#endif
if (pdrv != 0) return STA_NOINIT;
// Start init SD card
Stat = STA_NOINIT;
// power on, try detect on bus, set card to idle state
SD_PowerOn();
if (!SD_CheckPower()) return Stat;
// check disk type
uint8_t type = 0;
uint32_t cnt = 100;
// Set low SPI bus speed = PLL/256 (on 72MHz =281.250kHz)
SD_Select_SPI(SD_INIT_SPI_SPEED);
SD_Select_SPI_LOW();
// send GO_IDLE_STATE command
if (SD_SendCmd(CMD0, 0) == SD_R1_IDLE)
{
@ -1584,11 +1588,9 @@ DSTATUS disk_initialize(BYTE pdrv) {
SD_Unselect_SPI();
CardType = type;
DEBUG_PRINT("CardType %d\r\n", type);
// Clear STA_NOINIT and set Power on
if (type){
Stat&= ~STA_NOINIT;
Stat|= STA_POWER_ON;
}
// Clear STA_NOINIT
if (type)
Stat&=~STA_NOINIT;
else // Initialization failed
SD_PowerOff();
return Stat;
@ -1612,7 +1614,7 @@ DRESULT disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count) {
r_time-= chVTGetSystemTimeX();
#endif
SD_Select_SPI(SD_SPI_RX_SPEED);
SD_Select_SPI();
// READ_SINGLE_BLOCK
uint8_t cnt = SD_READ_WRITE_REPEAT; // read repeat count
do{
@ -1664,7 +1666,7 @@ DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count) {
w_time-= chVTGetSystemTimeX();
#endif
SD_Select_SPI(SD_SPI_SPEED);
SD_Select_SPI();
// WRITE_SINGLE_BLOCK
uint8_t cnt = SD_READ_WRITE_REPEAT; // write repeat count
do{
@ -1691,7 +1693,7 @@ DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff) {
DRESULT res = RES_PARERR;
// No disk or not ready
if (pdrv != 0 || Stat & STA_NOINIT) return RES_NOTRDY;
SD_Select_SPI(SD_SPI_RX_SPEED);
SD_Select_SPI();
switch (cmd){
// Makes sure that the device has finished pending write process.
// If the disk I/O layer or storage device has a write-back cache,

@ -114,14 +114,19 @@ static THD_FUNCTION(Thread1, arg)
{
(void)arg;
chRegSetThreadName("sweep");
// Init UI and plot grid
area_height = AREA_HEIGHT_NORMAL;
ui_init();
//Initialize graph plotting
plot_init();
#ifdef __SD_CARD_LOAD__
sd_card_load_config("autoload.ini");
#endif
#ifndef TINYSA4
ui_process();
#endif
//#ifndef TINYSA4
// ui_process();
//#endif
while (1) {
// START_PROFILE
@ -2272,10 +2277,6 @@ int main(void)
i2sStart(&I2SD2, &i2sconfig);
i2sStartExchange(&I2SD2);
#endif
area_height = AREA_HEIGHT_NORMAL;
ui_init();
//Initialize graph plotting
plot_init();
setup_sa();
// if (setting.mode != -1) {

@ -1252,7 +1252,7 @@ typedef struct ui_button {
uint32_t u;
float f;
const char *text;
} param_1, param_2; // void data for label printf
} param_1; // void data for label printf
char text[32];
} ui_button_t;

@ -2019,7 +2019,8 @@ disable_waterfall(void)
void
plot_init(void)
{
force_set_markmap();
redraw_request|= REDRAW_AREA | REDRAW_BATTERY | REDRAW_CAL_STATUS | REDRAW_FREQUENCY;
draw_all(true);
}
#pragma GCC pop_options

@ -81,7 +81,8 @@
#ifdef TINYSA4
#define SPI_MODE_LCD 0x00
#define SPI_MODE_SD_CARD 0x01
#define SPI_MODE_SI 0x02
#define SPI_MODE_SD_CARD_LOW 0x02
#define SPI_MODE_SI 0x03
#define SPI_MODE_PE 0x04
void set_SPI_mode(uint16_t mode);
void start_SI4432_SPI_mode(void);

@ -1691,7 +1691,7 @@ static const uint16_t rbwsel_x10[]={0,30,100,300,1000,3000,6000};
#endif
#ifdef __VBW__
static const uint16_t vbwsel_x100[]={0,100,30,10,3,1};
static const char* vbwsel_text[]={"auto","0.01","0.03", "0.1", "0.3"," "};
//static const char* vbwsel_text[]={"auto","0.01","0.03", "0.1", "0.3"," "};
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_rbw_acb)
@ -1715,7 +1715,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_vbw_acb)
{
(void)item;
if (b){
b->param_1.text = vbwsel_text[data];
b->param_1.f = vbwsel_x100[data] > 0 ? 1.0f/vbwsel_x100[data] : 0;
b->icon = setting.vbw_x100 == vbwsel_x100[data] ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
@ -2256,11 +2256,11 @@ static const menuitem_t menu_rbw[] = {
#ifdef __VBW__
static const menuitem_t menu_vbw[] = {
{ MT_ADV_CALLBACK, 0, " AUTO", menu_vbw_acb},
{ MT_ADV_CALLBACK, 1, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 2, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 3, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 4, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 5, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 1, "%b.2f RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 2, "%b.2f RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 3, "%b.2f RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 4, "%b.2f RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 5, "%b.2f RBW", menu_vbw_acb},
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
#endif

Loading…
Cancel
Save

Powered by TurnKey Linux.