From 144f8f1b4079593b00cded5db9b7f2b2da5ecc87 Mon Sep 17 00:00:00 2001 From: asterix Date: Fri, 10 Sep 2010 09:53:23 +0000 Subject: [PATCH] Some fix to comply to new bertos version. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4229 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/ek-lm3s1968/examples/gps/cfg/cfg_adc.h | 9 ++- .../examples/gps/cfg/cfg_dc_motor.h | 45 ++++++++++++ .../examples/gps/cfg/cfg_emb_flash.h | 73 +++++++++++++++++++ boards/ek-lm3s1968/examples/gps/cfg/cfg_fat.h | 17 +++++ .../examples/gps/cfg/cfg_formatwr.h | 1 - .../examples/gps/cfg/cfg_lcd_hd44.h | 14 ++++ .../examples/gps/cfg/cfg_pocketbus.h | 24 +++++- .../ek-lm3s1968/examples/gps/cfg/cfg_thermo.h | 14 ++++ .../ek-lm3s1968/examples/gps/cfg/cfg_xmodem.h | 15 +++- boards/ek-lm3s1968/examples/gps/gps.mk | 16 ++-- boards/ek-lm3s1968/examples/gps/main.c | 42 +++++++---- .../ek-lm3s1968/examples/gps/project.bertos | 69 ++++++++++-------- 12 files changed, 281 insertions(+), 58 deletions(-) create mode 100644 boards/ek-lm3s1968/examples/gps/cfg/cfg_emb_flash.h diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_adc.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_adc.h index 90aeb7bd..df2587be 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_adc.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_adc.h @@ -56,9 +56,12 @@ /** * Clock Frequency for ADC conversion. + * This frequency will be rounded down to an integer + * submultiple of CPU_FREQ. * * $WIZ$ type = "int" * $WIZ$ supports = "at91" + * $WIZ$ max = 5000000 */ #define CONFIG_ADC_CLOCK 4800000UL @@ -66,16 +69,16 @@ * Minimum time for starting up a conversion [us]. * * $WIZ$ type = "int" - * $WIZ$ min = 0 + * $WIZ$ min = 20 * $WIZ$ supports = "at91" */ #define CONFIG_ADC_STARTUP_TIME 20 /** - * Minimum time for sample and hold [us]. + * Minimum time for sample and hold [ns]. * * $WIZ$ type = "int" - * $WIZ$ min = 0 + * $WIZ$ min = 600 * $WIZ$ supports = "at91" */ #define CONFIG_ADC_SHTIME 834 diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_dc_motor.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_dc_motor.h index 05af01b8..59650e43 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_dc_motor.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_dc_motor.h @@ -63,4 +63,49 @@ */ #define DC_MOTOR_LOG_FORMAT LOG_FMT_TERSE + +/** + * Min value of DC motor speed. + * \note Generally this value is the min value of the ADC conversion, + * if you use it. + * + * $WIZ$ type = "int" + */ +#define CONFIG_DC_MOTOR_MIN_SPEED 0 + + +/** + * Max value of DC motor speed. + * \note Generally this value is the max value of the ADC conversion, + * if you use it. + * + * $WIZ$ type = "int" + * $WIZ$ max = 65535 + */ +#define CONFIG_DC_MOTOR_MAX_SPEED 65535 + + +/** + * Sampling period in millisecond. + * $WIZ$ type = "int" + */ +#define CONFIG_DC_MOTOR_SAMPLE_PERIOD 40 + +/** + * Amount of millisecond before to read sample. + * $WIZ$ type = "int" + */ +#define CONFIG_DC_MOTOR_SAMPLE_DELAY 2 + +/** + * This control set which mode the driver use to lock share + * resources when we use the preempitive kernel. + * If we set to 1 we use the semaphore module otherwise the + * driver disable the switch context every time we need to access + * to shared sources. + * + * $WIZ$ type = "int" + */ +#define CONFIG_DC_MOTOR_USE_SEM 1 + #endif /* CFG_DC_MOTOR_H */ diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_emb_flash.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_emb_flash.h new file mode 100644 index 00000000..9378552f --- /dev/null +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_emb_flash.h @@ -0,0 +1,73 @@ +/** + * \file + * + * + * \author Daniele Basile + * + * \brief Configuration file for embedded flash module. + */ + +#ifndef CFG_EMB_FLASH_H +#define CFG_EMB_FLASH_H + +/** + * Module logging level. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_level" + */ +#define CONFIG_FLASH_EMB_LOG_LEVEL LOG_LVL_INFO + +/** + * module logging format. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_format" + */ +#define CONFIG_FLASH_EMB_LOG_FORMAT LOG_FMT_TERSE + + +/** + * Write emb flash timeout. + * For how many milliseconds the cpu wait + * to complete write operation. + * + * $WIZ$ type = "int" + */ +#define CONFIG_FLASH_WR_TIMEOUT 100 + +/** + * Check this to disable embedded flash deprecated API support. + * + * $WIZ$ type = "boolean" + */ +#define CONFIG_FLASH_DISABLE_OLD_API 1 + +#endif /* CFG_FLASH_AT91_H */ diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_fat.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_fat.h index 83772f45..fcd717af 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_fat.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_fat.h @@ -40,6 +40,23 @@ #ifndef CFG_FAT_H #define CFG_FAT_H +/** + * Module logging level. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_level" + */ +#define FAT_LOG_LEVEL LOG_LVL_ERR + +/** + * Module logging format. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_format" + */ +#define FAT_LOG_FORMAT LOG_FMT_VERBOSE + + /** * Use word alignment to access FAT structure. * $WIZ$ type = "boolean" diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_formatwr.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_formatwr.h index ec13eaaf..bac8aca7 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_formatwr.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_formatwr.h @@ -32,7 +32,6 @@ * * \brief Configuration file for formatted write module. * - * * \author Daniele Basile */ diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_lcd_hd44.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_lcd_hd44.h index 78f1f20b..7bea4376 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_lcd_hd44.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_lcd_hd44.h @@ -51,5 +51,19 @@ */ #define CONFIG_LCD_ADDRESS_FAST 1 +/** + * Number of columns in LCD display. + * $WIZ$ type = "enum" + * $WIZ$ value_list = "lcd_hd44_cols" + */ +#define CONFIG_LCD_COLS LCD_HD44_COLS_16 + +/** + * Number of rows in LCD display. + * $WIZ$ type = "enum" + * $WIZ$ value_list = "lcd_hd44_rows" + */ +#define CONFIG_LCD_ROWS LCD_HD44_ROWS_2 + #endif /* CFG_LCD_H */ diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_pocketbus.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_pocketbus.h index 4ea13843..aa0b090b 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_pocketbus.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_pocketbus.h @@ -32,13 +32,29 @@ * * \brief Configuration file for pocketbus module. * - * * \author Daniele Basile */ #ifndef CFG_POCKETBUS_H #define CFG_POCKETBUS_H +/** + * Module logging level. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_level" + */ +#define POCKETBUS_LOG_LEVEL LOG_LVL_ERR + +/** + * Module logging format. + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_format" + */ +#define POCKETBUS_LOG_FORMAT LOG_FMT_TERSE + + /** *Buffer len for pockebus protocol. * $WIZ$ type = "int" @@ -46,4 +62,10 @@ */ #define CONFIG_POCKETBUS_BUFLEN 128 +/** + * Command replay timeout in milliseconds. + * $WIZ$ type = "int" + */ +#define CONFIG_POCKETBUS_CMD_REPLY_TIMEOUT 50 + #endif /* CFG_POCKETBUS_H */ diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_thermo.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_thermo.h index 0099fa87..2734f899 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_thermo.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_thermo.h @@ -38,6 +38,20 @@ #ifndef CFG_THERMO_H #define CFG_THERMO_H +/** + * Module logging level. + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_level" + */ +#define CONFIG_THERMO_LOG_LEVEL LOG_LVL_ERR +/** + * Module logging format. + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_format" + */ +#define CONFIG_THERMO_LOG_FORMAT LOG_FMT_TERSE + + /** * Interval at which thermo control is performed [ms]. * diff --git a/boards/ek-lm3s1968/examples/gps/cfg/cfg_xmodem.h b/boards/ek-lm3s1968/examples/gps/cfg/cfg_xmodem.h index a7bff930..38db7359 100644 --- a/boards/ek-lm3s1968/examples/gps/cfg/cfg_xmodem.h +++ b/boards/ek-lm3s1968/examples/gps/cfg/cfg_xmodem.h @@ -32,13 +32,26 @@ * * \brief Configuration file for xmodem module. * - * * \author Daniele Basile */ #ifndef CFG_XMODEM_H #define CFG_XMODEM_H +/** + * Module logging level. + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_level" + */ +#define CONFIG_XMODEM_LOG_LEVEL LOG_LVL_ERR +/** + * Module logging format. + * $WIZ$ type = "enum" + * $WIZ$ value_list = "log_format" + */ +#define CONFIG_XMODEM_LOG_FORMAT LOG_FMT_TERSE + + /// Enable Rx. $WIZ$ type = "boolean" #define CONFIG_XMODEM_RECV 1 diff --git a/boards/ek-lm3s1968/examples/gps/gps.mk b/boards/ek-lm3s1968/examples/gps/gps.mk index 99c68f36..752fe65e 100644 --- a/boards/ek-lm3s1968/examples/gps/gps.mk +++ b/boards/ek-lm3s1968/examples/gps/gps.mk @@ -21,21 +21,23 @@ gps_HW_PATH = boards/ek-lm3s1968 gps_WIZARD_CSRC = \ bertos/kern/sem.c \ bertos/mware/formatwr.c \ + bertos/io/kblock.c \ bertos/net/nmea.c \ + bertos/io/kfile_block.c \ bertos/drv/kbd.c \ bertos/gfx/line.c \ bertos/drv/lcd_rit128x96.c \ bertos/cpu/cortex-m3/hw/switch_ctx_cm3.c \ - bertos/kern/kfile.c \ + bertos/kern/signal.c \ + bertos/io/kfile.c \ bertos/gfx/text_format.c \ - bertos/struct/heap.c \ + bertos/drv/timer.c \ bertos/drv/ser.c \ bertos/mware/hex.c \ bertos/net/nmeap/src/nmeap01.c \ bertos/gfx/text.c \ bertos/cpu/cortex-m3/drv/timer_cm3.c \ - bertos/drv/timer.c \ - bertos/kern/signal.c \ + bertos/struct/heap.c \ bertos/kern/proc.c \ bertos/mware/event.c \ bertos/gfx/bitmap.c \ @@ -91,13 +93,13 @@ gps_ASRC = $(gps_CPU_ASRC) $(gps_WIZARD_ASRC) $(gps_USER_ASRC) gps_CPU_CPPASRC = bertos/cpu/cortex-m3/hw/crt_cm3.S bertos/cpu/cortex-m3/hw/vectors_cm3.S gps_CPU_CPPAFLAGS = -g -gdwarf-2 -mthumb -mno-thumb-interwork gps_CPU_CPPFLAGS = -O0 -g3 -gdwarf-2 -mthumb -mno-thumb-interwork -fno-strict-aliasing -fwrapv -fverbose-asm -Ibertos/cpu/cortex-m3/ -D__ARM_LM3S1968__ -gps_CPU_CSRC = bertos/cpu/cortex-m3/hw/init_lm3s.c bertos/cpu/cortex-m3/drv/irq_cm3.c bertos/cpu/cortex-m3/drv/gpio_lm3s.c bertos/cpu/cortex-m3/drv/clock_lm3s.c +gps_CPU_CSRC = bertos/cpu/cortex-m3/hw/init_cm3.c bertos/cpu/cortex-m3/drv/irq_cm3.c bertos/cpu/cortex-m3/drv/gpio_lm3s.c bertos/cpu/cortex-m3/drv/clock_lm3s.c gps_PROGRAMMER_CPU = lm3s +gps_CPU_LDFLAGS = -mthumb -mno-thumb-interwork -nostartfiles -Wl,--no-warn-mismatch -T bertos/cpu/cortex-m3/scripts/lm3s1968_rom.ld gps_STOPFLASH_SCRIPT = bertos/prg_scripts/arm/stopopenocd.sh gps_CPU = cortex-m3 gps_STOPDEBUG_SCRIPT = bertos/prg_scripts/arm/stopopenocd.sh gps_DEBUG_SCRIPT = bertos/prg_scripts/arm/debug.sh -gps_CPU_LDFLAGS = -mthumb -mno-thumb-interwork -nostartfiles -Wl,--no-warn-mismatch -T bertos/cpu/cortex-m3/scripts/lm3s1968_rom.ld -gps_FLASH_SCRIPT = bertos/prg_scripts/arm/flash-cortex.sh +gps_FLASH_SCRIPT = bertos/prg_scripts/arm/flash-lm3s.sh include $(gps_SRC_PATH)/gps_user.mk diff --git a/boards/ek-lm3s1968/examples/gps/main.c b/boards/ek-lm3s1968/examples/gps/main.c index 5e32dc5e..0c2f4e6a 100644 --- a/boards/ek-lm3s1968/examples/gps/main.c +++ b/boards/ek-lm3s1968/examples/gps/main.c @@ -45,6 +45,9 @@ #include #include +#include +#include + #include #include @@ -83,29 +86,39 @@ static long target_lat, target_lon; /* Storage stuff */ #define GPS_POS_MAGIC 0xdeadbeef -static Flash flash; +static Flash flash_blk; +static KFileBlock flash; -static void flash_load_target(void) +struct SettingsData { uint32_t magic; + long target_lat, target_lon; +}; + +static void flash_load_target(void) +{ + struct SettingsData data; - kfile_seek(&flash.fd, -FLASH_PAGE_SIZE_BYTES, KSM_SEEK_END); - kfile_read(&flash.fd, &magic, sizeof(magic)); - if (magic == GPS_POS_MAGIC) + kfile_seek(&flash.fd, -sizeof(data), KSM_SEEK_END); + kfile_read(&flash.fd, &data, sizeof(data)); + + if (data.magic == GPS_POS_MAGIC) { - kfile_read(&flash.fd, &target_lat, sizeof(target_lat)); - kfile_read(&flash.fd, &target_lon, sizeof(target_lon)); + target_lat = data.target_lat; + target_lon = data.target_lon; } } static void flash_save_target(void) { - const uint32_t magic = GPS_POS_MAGIC; + struct SettingsData data; + + data.magic = GPS_POS_MAGIC; + data.target_lat = target_lat; + data.target_lon = target_lon; - kfile_seek(&flash.fd, -FLASH_PAGE_SIZE_BYTES, KSM_SEEK_END); - kfile_write(&flash.fd, &magic, sizeof(magic)); - kfile_write(&flash.fd, &target_lat, sizeof(target_lat)); - kfile_write(&flash.fd, &target_lon, sizeof(target_lon)); + kfile_seek(&flash.fd, -sizeof(data), KSM_SEEK_END); + kfile_write(&flash.fd, &data, sizeof(data)); kfile_flush(&flash.fd); } @@ -451,7 +464,7 @@ static void gps_data(Bitmap *bm) ABS(lon) % 1000000L, lon >= 0 ? 'E' : 'W'); text_xprintf(bm, 2, 0, TEXT_FILL, - "Alt. %d", gga.altitude); + "Alt. %ld", gga.altitude); text_xprintf(bm, 3, 0, TEXT_FILL, "Speed: %d", vtg.km_speed); if (gga.quality < countof(gps_fix)) @@ -531,7 +544,8 @@ static void init(void) scrsvr_timestamp = ticks_to_ms(timer_clock_unlocked()); LED_INIT(); - flash_init(&flash); + flash_init(&flash_blk, 0); + kfileblock_init(&flash, &flash_blk.blk); flash_load_target(); ser_init(&ser_port, SER_UART1); diff --git a/boards/ek-lm3s1968/examples/gps/project.bertos b/boards/ek-lm3s1968/examples/gps/project.bertos index 4e4b40a1..8737046d 100644 --- a/boards/ek-lm3s1968/examples/gps/project.bertos +++ b/boards/ek-lm3s1968/examples/gps/project.bertos @@ -17,78 +17,85 @@ p7 sS'TOOLCHAIN' p8 (dp9 -Vtarget +S'target' p10 Varm-none-eabi p11 -sVthread +sS'thread' p12 Vsingle p13 -sVconfigured +sS'configured' p14 -V/scratch/sandra/lite/src/gcc-4.2/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --disable-shared --with-newlib --with-pkgversion=Sourcery G++ Lite 2008q1-126 --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/sandra/lite/eabi/install/arm-none-eabi --enable-poison-system-directories --with-build-time-tools=/scratch/sandra/lite/eabi/install/arm-none-eabi/bin --with-build-time-tools=/scratch/sandra/lite/eabi/install/arm-none-eabi/bin +V/scratch/julian/2010q1-release-eabi-lite/src/gcc-4.4-2010q1/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shared --disable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite 2010q1-188' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/julian/2010q1-release-eabi-lite/install/arm-none-eabi --with-gmp=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2010q1-release-eabi-lite/install/arm-none-eabi/bin --with-build-time-tools=/scratch/julian/2010q1-release-eabi-lite/install/arm-none-eabi/bin p15 -sVversion +sS'version' p16 -V4.2.3 +V4.4.1 p17 -sVbuild +sS'build' p18 -VSourcery G++ Lite 2008q1-126 +VSourcery G++ Lite 2010q1-188 p19 -sVpath +sS'path' p20 -V/usr/local/arm-2008q1/bin/arm-none-eabi-gcc +V/localhome/toolchain/arm/bin/arm-none-eabi-gcc p21 ssS'ENABLED_MODULES' p22 (lp23 -S'kernel' +S'ser' p24 -aS'ser' +aS'kernel' p25 aS'text' p26 aS'kbd' p27 -aS'formatwr' +aS'semaphores' p28 -aS'text_format' +aS'kblock' p29 -aS'sprintf' +aS'formatwr' p30 -aS'semaphores' -p31 aS'kfile' +p31 +aS'text_format' p32 aS'lcd_rit128x96' p33 aS'heap' p34 -aS'timer' +aS'sprintf' p35 -aS'debug' +aS'signal' p36 -aS'nmea' +aS'timer' p37 -aS'signal' +aS'debug' p38 -asS'CPU_NAME' +aS'kfile_block' p39 -VLM3S1968 +aS'nmea' p40 -sS'PROJECT_HW_PATH' +asS'CPU_NAME' p41 -S'../..' +VLM3S1968 p42 -sS'PROJECT_SRC_PATH' +sS'PROJECT_HW_PATH' p43 -S'.' +S'../..' p44 -sS'PRESET' +sS'PROJECT_SRC_PATH' p45 -NsS'OUTPUT' +S'.' p46 -(lp47 -s. \ No newline at end of file +sS'PRESET' +p47 +I01 +sS'OUTPUT' +p48 +(lp49 +S'codelite' +p50 +as. \ No newline at end of file -- 2.25.1