Skip to content

Commit

Permalink
Standard features are being made configurable, so that we can disable…
Browse files Browse the repository at this point in the history
… them during ports. #181.
  • Loading branch information
travisgoodspeed committed Jul 19, 2016
1 parent 188aed0 commit 851d4e3
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 9 deletions.
2 changes: 1 addition & 1 deletion applet/Makefile.s13.020
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#SRCS += rtc_timer.o i2c.o display.o

#Minimal set
SRCS = main.o usb.o stm32f4xx_it.o system_stm32f4xx.o printf.o dmesg.o gfx.o
SRCS = main.o usb.o stm32f4xx_it.o system_stm32f4xx.o printf.o dmesg.o
PROJ_NAME=main


Expand Down
17 changes: 13 additions & 4 deletions applet/config.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
/*! \file config.h
\brief Configuration options.
This file defines temporary options that are sometimes useful.
This file configures our patches, either to temporarily enable
unstable features or to disable standard features when porting to a
new target application version.
The default version of this file, as found in the repository, is to
be used for all external releases.
*/


/* Basic features that ought to be working in 2.032 but might be
missing in later revisions. */
#define SPIFLASH
#define GRAPHICS
#define SPIC5000


/* Uncomment this to print AMBE frames for decoding with DSD. You
probable want this instead of AMBECORRECTEDPRINT or
AMBEUNCORRECTEDPRINT below.
Expand All @@ -16,9 +28,6 @@
*/
//#define AMBEWAVPRINT




/* Uncomment these to enable printing raw frames, either before or
after error correction is applied. */
//#define AMBECORRECTEDPRINT
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion applet/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void wstrhex(wchar_t *string, long value){
/* Displays a startup demo on the device's screen, including some of
the setting information and a picture or two. */
void demo(){
#ifdef GRAPHICS
drawtext(L"MD380Tools ",
160,20);
drawtext(L"by KK4VCZ ",
Expand All @@ -133,7 +134,8 @@ void demo(){
gfx_drawbmp(welcomebmp,0,i);
sleep(30);
}

#endif GRAPHICS

//Restore the bottom line of text before we return.
md380_spiflash_read(botlinetext, 0x2054, 20);
}
Expand Down
155 changes: 155 additions & 0 deletions applet/src/symbols_s13.020
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/* Symbols for ../firmware/unwrapped/S013.020.img imported from ../firmware/unwrapped/D002.032.img. */
/* This file contains symbols for version 2.032 of the firmware. */

/* For maximum portability, try to use only symbols that cleanly */
/* port to other versions. Good candidates have long prologues. */

/* Startup routines, very handy for hooking our startup. */
/* startup_topline has bad match of 8 points at 0x0802299d*/
/* startup_botline has bad match of 8 points at 0x080229af*/

/* Graphics functions. */
gfx_drawtext = 0x0800def7; /* 28 byte match */
gfx_drawbmp = 0x08023adb; /* 58 byte match */
/* gfx_drawtext2 has bad match of 4 points at 0x0801de3d*/
/* gfx_chars_to_display has bad match of 4 points at 0x0801de3d*/

gfx_select_font = 0x08021b51; /* 14 byte match */
/* gfx_set_bg_color has bad match of 2 points at 0x0800de65*/
/* gfx_set_fg_color has bad match of 2 points at 0x0800de65*/
gfx_blockfill = 0x0801d9c1; /* 200 byte match */

/* Function that handles the end of a DMR call. */
dmr_call_end = 0x08041f49; /* 16 byte match */
/* Function that handles a DMR call. */
dmr_call_start = 0x0804151b; /* 18 byte match */
/* Function that handles a DMR SMS. */
/* dmr_handle_data has bad match of 2 points at 0x0800df1b*/
/* Function that handles an incoming SMS. */
/* dmr_sms_arrive has bad match of 2 points at 0x0800df1b*/
/* //! Called before unsquelching. */
/* dmr_before_squelch has bad match of 2 points at 0x0800de65*/



/* Upload and download handlers. */
usb_upld_handle = 0x08090149; /* 232 byte match */
usb_dnld_handle = 0x0808fa2f; /* 432 byte match */

/* This returns a USB packet to the host from the upload handler. */
usb_send_packet = 0x0805a943; /* 148 byte match */

/* Higher-level USB functions. These need stub hooks. */
usb_modestring = 0x080974bd; /* 12 byte match */
/* usb_manufacturer has bad match of 6 points at 0x080974df*/
usb_serialnumber = 0x080974ef; /* 12 byte match */
usb_setcallbacks = 0x08055f41; /* 18 byte match */
usb_do_setup = 0x0808f971; /* 90 byte match */

/* USB DFU functions. */
usb_dfu_write = 0x080911b1; /* 274 byte match */
usb_dfu_read = 0x08091201; /* 194 byte match */


/* spi-flash */
md380_spiflash_read = 0x080318b3; /* 78 byte match */
md380_spiflash_write = 0x0803199b; /* 712 byte match */
md380_spiflash_security_registers_read = 0x08031ced; /* 146 byte match */
md380_spiflash_enable = 0x08031967; /* 10 byte match */
/* md380_spiflash_disable has bad match of 6 points at 0x08031983*/
md380_spiflash_wait = 0x08031945; /* 44 byte match */
md380_spiflash_block_erase64k = 0x080316e7; /* 538 byte match */
md380_spiflash_sektor_erase4k = 0x080316b3; /* 590 byte match */
/* md380_spi_sendrecv has bad match of 8 points at 0x080318f9*/

/* i2c */
md380_I2C_GenerateSTART = 0x080535d1; /* 212 byte match */
md380_I2C_GenerateSTOP = 0x080535ed; /* 184 byte match */
md380_I2C_ReceiveData = 0x08053625; /* 128 byte match */
md380_I2C_Send7bitAddress = 0x08053609; /* 156 byte match */
md380_I2C_SendData = 0x0805361f; /* 134 byte match */

/* Function that handles uC/OS-II settings */

OSTaskCreateExt = 0x0804f3ad; /* 26 byte match */
OSTaskNameSet = 0x0804f479; /* 22 byte match */

OS_ENTER_CRITICAL = 0x08044925; /* 146 byte match */
OS_EXIT_CRITICAL = 0x0804492d; /* 138 byte match */

/* OSSem Create Hook used the place from 2 OSSemCreate Calls */
OSSemCreate = 0x08040221; /* 18 byte match */
OSSemPend = 0x0804026d; /* 50 byte match */
OSSemPost = 0x0804035d; /* 16 byte match */

md380_OSMboxPost = 0x080315f1; /* 16 byte match */

/* //! Functions and Variabes regarding the menu */
main_menu = 0x0803beb3; /* 12 byte match */
md380_create_menu_entry = 0x0800c72f; /* 24 byte match */
/* md380_create_main_meny_entry has bad match of 2 points at 0x0800c189*/
/* md380_menu_numerical_input has bad match of 4 points at 0x0803d76e*/
md380_create_menu_entry = 0x0800c72f; /* 24 byte match */
/* md380_menu_entry_back has bad match of 4 points at 0x08013c20*/
/* md380_menu_entry_programradio has bad match of 4 points at 0x0800fe74*/

/* md380_menu_0x200011e4 is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3c1 is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3ed is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3ee is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3ef is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3f0 is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3f1 is a RAM address and cannot be converted. */
/* md380_menu_0x2001d3f4 is a RAM address and cannot be converted. */
/* md380_menu_depth is a RAM address and cannot be converted. */
/* md380_menu_entry_selected is a RAM address and cannot be converted. */
/* md380_menu_id is a RAM address and cannot be converted. */
/* Unparsed line: md380_program_radio_unprohibited = 0x2001d030 + 4;
*/
md380_wt_programradio = 0x080d0df0; /* 150 byte match */
/* md380_menu_0x20001114 is a RAM address and cannot be converted. */

/* c5000 */
/* c5000_spi0_readreg has bad match of 4 points at 0x0801c88d*/
/* c5000_spi0_writereg has bad match of 4 points at 0x0801c88d*/

/* aes */
aes_loadkey = 0x080377d9; /* 630 byte match */
aes_cipher = 0x08037751; /* 766 byte match */
/* aes_startup_check has bad match of 6 points at 0x08022847*/

/* Unknown AMBE2+ thing. */
/* ambe_encode_thing has bad match of 4 points at 0x0802bb51*/
/* Decodes an AMBE2+ frame into bits. */
ambe_unpack = 0x0804c061; /* 38 byte match */

/* Populates the audio buffer */
/* ambe_decode_wav has bad match of 2 points at 0x0800e399*/


/* useful md380 firmware functions */
md380_itow = 0x08018c5d; /* 238 byte match */
md380_RTC_GetDate = 0x0802b7e9; /* 552 byte match */
md380_RTC_GetTime = 0x0802b6d3; /* 830 byte match */
/* read_channel_switch has bad match of 8 points at 0x08050a75*/

/* useful md380 variables */
/* md380_dmr_id is a RAM address and cannot be converted. */

/* md380_radio_config is a RAM address and cannot be converted. */
/* Functions and Variabes from the "RTC Timer" - task */
/* md380_f_4137 has bad match of 2 points at 0x0800df1b*/
/* md380_f_4520 has bad match of 4 points at 0x0800e539*/
/* md380_f_4098 has bad match of 2 points at 0x0800de65*/
/* md380_f_4102 has bad match of 2 points at 0x0800e02b*/
/* md380_f_4225 has bad match of 4 points at 0x0800e539*/

/* relevant display functions */
/* Write_Command_2display has bad match of 6 points at 0x08034045*/
/* Write_Data_2display has bad match of 2 points at 0x08014073*/


/* Chinese font region. */
chinese_font = 0x0809c694; /* 1024 byte match */


14 changes: 11 additions & 3 deletions applet/src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ int usb_dnld_hook(){
break;

//SPI-FLASH commands
#ifdef SPIFLASH
case TDFU_SPIFLASHGETID:
//Re-uses the dmesg transmit buffer.
*dfu_target_adr=dmesg_tx_buf;
Expand Down Expand Up @@ -216,8 +217,9 @@ int usb_dnld_hook(){
0,
3*256);
break;

#endif //SPIFLASH

#ifdef SPIC5000
//Radio Commands
case TDFU_C5000_READREG:
//Re-uses the dmesg transmit buffer.
Expand All @@ -235,14 +237,18 @@ int usb_dnld_hook(){
c5000_spi0_writereg(packet[1],packet[2]);
OS_EXIT_CRITICAL(state);
break;
#endif //SPIC5000

#ifdef GRAPHICS
//Graphics commands.
case TDFU_PRINT: // 0x80, u8 x, u8 y, u8 str[].
drawtext((wchar_t *) (packet+3),
packet[1],packet[2]);
break;

case TDFU_BOX:
#endif //GRAPHICS

default:
printf("Unhandled DFU packet type 0x%02x.\n",packet[0]);
}
Expand Down Expand Up @@ -297,7 +303,7 @@ const char *loadusbstr(char *usbstring,
const char *getmfgstr(int speed, long *len){
//This will be turned off by another thread,
//but when we call it often the light becomes visible.
green_led(1);
//green_led(1);

//Hook the USB DNLOAD handler.
hookusb();
Expand All @@ -307,9 +313,11 @@ const char *getmfgstr(int speed, long *len){
char *usbstring=(char*) 0x2001c080; //2.032
char buffer[]="@________ : ________";

#ifdef SPIFLASH
//Read four bytes from SPI Flash.
md380_spiflash_read(&val,adr,4);

#endif SPIFLASH

//Print them into the manufacturer string.
strhex(buffer+1, adr);
strhex(buffer+12, val);
Expand Down

0 comments on commit 851d4e3

Please sign in to comment.