Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Select Git revision
Loading items
Show changes
Showing
with 1258 additions and 1107 deletions
source init.gdb
set confirm off
echo #### BOOTLOADER ####\n
load build/bootloader/bootloader.elf
reset
quit
source init.gdb
set confirm off
echo #### EPICARDIUM ####\n
load build/epicardium/epicardium.elf
echo #### PYCARDIUM ####\n
load build/pycardium/pycardium.elf
reset
quit
source init.gdb
set confirm off
echo #### EPICARDIUM ####\n
load build/epicardium/epicardium.elf
reset
quit
source init.gdb
set confirm off
echo #### PYCARDIUM ####\n
load build/pycardium/pycardium.elf
reset
quit
......@@ -6,7 +6,8 @@
void *api_call_start(uint32_t id, void *args, uint32_t size)
{
// aquire semaphore
while (E_BUSY == SEMA_GetSema (API_CALL_SEMA)) ;
while (E_BUSY == SEMA_GetSema(API_CALL_SEMA))
;
ApiCallSpace->id = id;
ApiCallSpace->returning = 0;
......@@ -20,7 +21,8 @@ void* api_call_bother_dispatcher (void* buf)
while (1) {
// aquire semaphore
while (E_BUSY == SEMA_GetSema (API_CALL_SEMA)) ;
while (E_BUSY == SEMA_GetSema(API_CALL_SEMA))
;
if (ApiCallSpace->returning == 1) {
break;
}
......
......@@ -17,7 +17,8 @@ void __api_dispatch_call(uint32_t id, void*buffer);
void api_dispatcher()
{
while (SEMA_GetSema(API_CALL_SEMA) == E_BUSY) {}
while (SEMA_GetSema(API_CALL_SEMA) == E_BUSY) {
}
if (ApiCallSpace->returning == 1) {
SEMA_FreeSema(API_CALL_SEMA);
......
......@@ -7,7 +7,9 @@
#include "api/api_dispatcher.h"
static const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
static const gpio_cfg_t motor_pin = {
PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE
};
void api_set_buzzer(uint8_t state)
{
......@@ -23,7 +25,10 @@ void api_set_buzzer(uint8_t state)
void api_set_led(uint8_t led, led_color_t color)
{
printf("API: Changing color of led %d.\n", led);
printf("Color { r: %3d, g: %3d, b: %3d }\n", color.red, color.green, color.blue);
printf("Color { r: %3d, g: %3d, b: %3d }\n",
color.red,
color.green,
color.blue);
leds_set(led, color.red, color.green, color.blue);
leds_update();
}
......@@ -31,7 +36,10 @@ void api_set_led(uint8_t led, led_color_t color)
void api_test(char test0, short test1, int test2, long test3)
{
printf("test0: %x, test1: %d, test2: %x, test3: %lx\n",
test0, (int)test1, test2, test3);
test0,
(int)test1,
test2,
test3);
}
int main(void)
......@@ -44,7 +52,6 @@ int main(void)
TMR_Delay(MXC_TMR1, MSEC(100), 0);
}
#if 0
// Enable rxev on core1
MXC_GCR->evten |= 0x20;
......
......@@ -50,18 +50,19 @@ def main():
f_client = cx.enter_context(open(args.client, "w"))
f_server = cx.enter_context(open(args.server, "w"))
print('#include "{}"\n'.format(
os.path.basename(args.header)
), file=f_client)
print('#include "{}"\n'.format(os.path.basename(args.header)), file=f_client)
print("""\
print(
"""\
#include "{}"
void __api_dispatch_call(uint32_t id, void*buffer)
{{
switch (id) {{""".format(
os.path.basename(args.header)
), file=f_server)
),
file=f_server,
)
for match in matcher.finditer(source):
api_id = match.group("id")
......@@ -100,9 +101,12 @@ void {cdecl}({cargs})
file=f_client,
)
print("""\
print(
"""\
case {id}:
{cdecl}(""".format(id=api_id, cdecl=api_decl),
{cdecl}(""".format(
id=api_id, cdecl=api_decl
),
file=f_server,
)
......@@ -122,18 +126,17 @@ void {cdecl}({cargs})
print(
"""\
*({type}*)(buffer + {offset})""".format(
type=ty,
offset=" + ".join(api_args_sizes[:i]) if i > 0 else "0",
type=ty, offset=" + ".join(api_args_sizes[:i]) if i > 0 else "0"
),
file=f_server,
end="",
)
print("""
print(
"""
);
break;""".format(
cdecl=api_decl,
args=", ".join(api_args_names),
cdecl=api_decl, args=", ".join(api_args_names)
),
file=f_server,
)
......@@ -154,14 +157,17 @@ void {cdecl}({cargs})
file=f_client,
)
print("""\
print(
"""\
default:
printf("Error: API function %x is unknown!!\\n", {id});
break;
}}
}}""".format(
id=api_id,
), file=f_server)
id=api_id
),
file=f_server,
)
if __name__ == "__main__":
......
......@@ -64,7 +64,6 @@ int main(void)
uint32_t poll_period = 5, test_dur_ms = 30000;
uint16_t int_status;
bma.intf_ptr = NULL; /* To attach your interface device reference */
bma.delay_ms = card10_bosch_delay;
bma.dev_id = BMA400_I2C_ADDRESS_SDO_LOW;
......@@ -77,7 +76,6 @@ int main(void)
printf("BMA400 found with chip ID 0x%X\r\n", bma.chip_id);
}
print_rslt(rslt);
rslt = bma400_soft_reset(&bma);
......@@ -138,6 +136,5 @@ int main(void)
test_dur_ms -= poll_period;
}
}
}
......@@ -11,7 +11,9 @@
#include "gpio.h"
#include "bme680.h"
#include "bosch.h"
#include "GUI_DEV/GUI_Paint.h"
#include "gfx.h"
#include "framebuffer.h"
#include "display.h"
#include "Fonts/fonts.h"
#include "card10.h"
......@@ -63,8 +65,9 @@ int main(void)
gas_sensor.power_mode = BME680_FORCED_MODE;
/* Set the required sensor settings needed */
set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_FILTER_SEL
| BME680_GAS_SENSOR_SEL;
set_required_settings = BME680_OST_SEL | BME680_OSP_SEL |
BME680_OSH_SEL | BME680_FILTER_SEL |
BME680_GAS_SENSOR_SEL;
/* Set the desired sensor configuration */
rslt = bme680_set_sensor_settings(set_required_settings, &gas_sensor);
......@@ -72,25 +75,28 @@ int main(void)
/* Set the power mode */
rslt = bme680_set_sensor_mode(&gas_sensor);
Color white = gfx_color(&display_screen, WHITE);
Color black = gfx_color(&display_screen, BLACK);
while (1) {
TMR_Delay(MXC_TMR0, MSEC(1000), 0);
struct bme680_field_data data;
rslt = bme680_get_sensor_data(&data, &gas_sensor);
printf("T: %.2Lf degC, P: %.2Lf hPa, H %.2Lf %%rH ", data.temperature / 100.0l,
data.pressure / 100.0l, data.humidity / 1000.0l );
printf("T: %.2Lf degC, P: %.2Lf hPa, H %.2Lf %%rH ",
data.temperature / 100.0l,
data.pressure / 100.0l,
data.humidity / 1000.0l);
char buf[128];
sprintf(buf, "T: %.2Lf degC", data.temperature / 100.0l);
Paint_DrawString_EN(0, 0, buf, &Font16, 0x0000, 0xffff);
gfx_puts(&Font16, &display_screen, 0, 0, buf, white, black);
sprintf(buf, "P: %.2Lf hPa", data.pressure / 100.0l);
Paint_DrawString_EN(0, 16, buf, &Font16, 0x0000, 0xffff);
gfx_puts(&Font16, &display_screen, 0, 16, buf, white, black);
sprintf(buf, "H: %.2Lf %%rH", data.humidity / 1000.0l);
Paint_DrawString_EN(0, 32, buf, &Font16, 0x0000, 0xffff);
gfx_puts(&Font16, &display_screen, 0, 32, buf, white, black);
//printf("%.2f,%.2f,%.2f\n", data.temperature / 100.0f,
// data.pressure / 100.0f, data.humidity / 1000.0f );
......@@ -98,10 +104,18 @@ int main(void)
if (data.status & BME680_GASM_VALID_MSK) {
printf(", G: %ld ohms", data.gas_resistance);
sprintf(buf, "G: %ld ohms", data.gas_resistance);
Paint_DrawString_EN(0, 48, buf, &Font16, 0x0000, 0xffff);
gfx_puts(
&Font16,
&display_screen,
0,
48,
buf,
white,
black
);
}
LCD_Update();
gfx_update(&display_screen);
printf("\n");
......
......@@ -6,10 +6,9 @@
#include "card10.h"
#include "bootloader-9251ea6.h"
#include "display.h"
#include "GUI_Paint.h"
#include "gfx.h"
#include "pmic.h"
#include "flc.h"
#include "icc.h"
#include "tmr_utils.h"
......@@ -37,45 +36,43 @@ static void pmic_button(bool falling)
}
}
int main(void)
{
card10_init();
pmic_set_button_callback(pmic_button);
printf("Erasing bootloader.\n");
Paint_DrawString_EN(0, 16*0, "Erasing bootloader", &Font16, 0x0000, 0xffff);
LCD_Update();
txt_puts(&display_textb, "Erasing bootloader.\n");
ICC_Disable();
int ret = FLC_MultiPageErase(0x10000000, 0x10000000 + 1024 * 64 - 1);
if (ret != E_NO_ERROR) {
printf("FLC_MultiPageErase failed with %d\n", ret);
Paint_DrawString_EN(0, 16*1, "Fail.", &Font16, 0x0000, 0xffff);
LCD_Update();
while(1);
txt_puts(&display_textb, "Fail.\n");
while (1)
;
}
printf("Writing bootloader.\n");
Paint_DrawString_EN(0, 16*0, "Writing bootloader ", &Font16, 0x0000, 0xffff);
LCD_Update();
txt_puts(&display_textb, "Writing bootloader.\n");
ret = FLC_Write(0x10000000, sizeof(bootloader_data), (uint32_t *)bootloader_data);
ret = FLC_Write(
0x10000000,
sizeof(bootloader_data),
(uint32_t *)bootloader_data
);
if (ret != E_NO_ERROR) {
printf("FLC_Write failed with %d\n", ret);
Paint_DrawString_EN(0, 16*1, "Fail.", &Font16, 0x0000, 0xffff);
LCD_Update();
while(1);
txt_puts(&display_textb, "Fail.\n");
while (1)
;
}
ICC_Enable();
printf("Done.\n");
Paint_DrawString_EN(0, 16*1, "Done.", &Font16, 0x0000, 0xffff);
Paint_DrawString_EN(0, 16*2, "Please restart", &Font16, 0x0000, 0xffff);
LCD_Update();
txt_puts(&display_textb, "Done.\n");
txt_puts(&display_textb, "Please restart.\n");
while (1) {
card10_poll();
......
......@@ -2,7 +2,8 @@
#include "gpio.h"
#include "mxc_delay.h"
static const __attribute__((unused)) gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
static const __attribute__((unused))
gpio_cfg_t motor_pin = { PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE };
int main(void)
{
......
......@@ -3,45 +3,42 @@
******************************************************************************/
/***** Includes *****/
#include "pmic.h"
#include "leds.h"
#include "card10.h"
#include "leds.h"
#include "pmic.h"
#include "GUI_Paint.h"
#include "display.h"
#include "gfx.h"
#include "tmr_utils.h"
#include <stdio.h>
#include <Heart.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <Heart.h>
int main(void)
{
card10_init();
card10_diag();
Paint_DrawImage(Heart, 0, 0, 160, 80);
LCD_Update();
for(int i=0; i<11; i++) {
leds_set_dim(i, 1);
}
int h = 0;
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RGB565,
(const void *)(Heart)
);
gfx_update(&display_screen);
// Release core1
core1_start();
core1_start((void *)0x10080000);
int h = 0;
while (1) {
#define NUM 15
for(int i=0; i<NUM; i++) {
if(i < 12) {
leds_set_hsv(i, (h + 360/NUM * i) % 360, 1., 1./8);
} else {
leds_set_hsv(i, (h + 360/NUM * i) % 360, 1., 1.);
}
}
leds_update();
TMR_Delay(MXC_TMR0, MSEC(10), 0);
......
......@@ -3,7 +3,7 @@ executable(
name + '.elf',
'main.c',
dependencies: [libcard10, max32665_startup_core0],
link_whole: [max32665_startup_core0_lib, board_card10_lib],
link_whole: [max32665_startup_core0_lib, board_card10_lib, newlib_heap_lib],
link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
],
......@@ -14,7 +14,7 @@ executable(
name + '.elf',
'core1.c',
dependencies: [periphdriver, board_card10, max32665_startup_core1],
link_whole: [max32665_startup_core1_lib, board_card10_lib],
link_whole: [max32665_startup_core1_lib, board_card10_lib, newlib_heap_lib],
link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
],
......
......@@ -16,7 +16,9 @@
#include "spi.h"
#include "pb.h"
#include "MAX30003.h"
#include "GUI_DEV/GUI_Paint.h"
#include "gfx.h"
#include "LCD_Driver.h"
#include "display.h"
#include "pmic.h"
#include "card10.h"
#include <stdbool.h>
......@@ -56,7 +58,9 @@ static void ecg_write_reg(uint8_t reg, uint32_t data)
{
printf("write %02x %06lx\n", reg, data);
spi_req_t req;
uint8_t tx_data[] = {(reg << 1) | 0 , data >> 16, (data >> 8 ) & 0xFF, data & 0xFF};
uint8_t tx_data[] = {
(reg << 1) | 0, data >> 16, (data >> 8) & 0xFF, data & 0xFF
};
uint8_t rx_data[] = { 0, 0, 0, 0 };
req.tx_data = tx_data;
req.rx_data = rx_data;
......@@ -81,12 +85,16 @@ static void ecg_config(bool enable_internal_pull)
union GeneralConfiguration_u CNFG_GEN_r;
CNFG_GEN_r.bits.en_ecg = 1; // Enable ECG channel
if (enable_internal_pull) {
CNFG_GEN_r.bits.rbiasn = 1; // Enable resistive bias on negative input
CNFG_GEN_r.bits.rbiasp = 1; // Enable resistive bias on positive input
CNFG_GEN_r.bits.rbiasn =
1; // Enable resistive bias on negative input
CNFG_GEN_r.bits.rbiasp =
1; // Enable resistive bias on positive input
CNFG_GEN_r.bits.en_rbias = 1; // Enable resistive bias
} else {
CNFG_GEN_r.bits.rbiasn = 0; // Enable resistive bias on negative input
CNFG_GEN_r.bits.rbiasp = 0; // Enable resistive bias on positive input
CNFG_GEN_r.bits.rbiasn =
0; // Enable resistive bias on negative input
CNFG_GEN_r.bits.rbiasp =
0; // Enable resistive bias on positive input
CNFG_GEN_r.bits.en_rbias = 0; // Enable resistive bias
}
......@@ -94,7 +102,6 @@ static void ecg_config(bool enable_internal_pull)
CNFG_GEN_r.bits.en_dcloff = 1; // Enable DC lead-off detection
ecg_write_reg(CNFG_GEN, CNFG_GEN_r.all);
// ECG Config register setting
union ECGConfiguration_u CNFG_ECG_r;
CNFG_ECG_r.bits.dlpf = 1; // Digital LPF cutoff = 40Hz
......@@ -105,20 +112,17 @@ static void ecg_config(bool enable_internal_pull)
//CNFG_ECG_r.bits.rate = 1; // Sample rate = 256 sps
ecg_write_reg(CNFG_ECG, CNFG_ECG_r.all);
//R-to-R configuration
union RtoR1Configuration_u CNFG_RTOR_r;
CNFG_RTOR_r.bits.en_rtor = 1; // Enable R-to-R detection
ecg_write_reg(CNFG_RTOR1, CNFG_RTOR_r.all);
//Manage interrupts register setting
union ManageInterrupts_u MNG_INT_r;
MNG_INT_r.bits.efit = 0b00011; // Assert EINT w/ 4 unread samples
MNG_INT_r.bits.clr_rrint = 0b01; // Clear R-to-R on RTOR reg. read back
ecg_write_reg(MNGR_INT, MNG_INT_r.all);
//Enable interrupts register setting
union EnableInterrupts_u EN_INT_r;
EN_INT_r.all = 0;
......@@ -127,7 +131,6 @@ static void ecg_config(bool enable_internal_pull)
EN_INT_r.bits.intb_type = 3; // Open-drain NMOS with internal pullup
ecg_write_reg(EN_INT, EN_INT_r.all);
//Dyanmic modes config
union ManageDynamicModes_u MNG_DYN_r;
MNG_DYN_r.bits.fast = 0; // Fast recovery mode disabled
......@@ -149,16 +152,16 @@ static uint8_t prev;
static void clear(void)
{
Paint_Clear(BLACK);
gfx_clear(&display_screen);
prev = Y_OFFSET;
}
static void set(uint8_t index, int8_t val)
{
if(val < -Y_SCALE) val = -Y_SCALE;
if(val > Y_SCALE) val = Y_SCALE;
if (val < -Y_SCALE)
val = -Y_SCALE;
if (val > Y_SCALE)
val = Y_SCALE;
int8_t pos = Y_OFFSET + val;
......@@ -172,7 +175,7 @@ static void set(uint8_t index, int8_t val)
}
for (int i = min; i < max + 1; i++) {
LCD_SetUWORD(SIZE_X - index - 1, i, RED);
LCD_SetUWORD(SIZE_X - index - 1, i, 0xf800);
}
prev = pos;
......@@ -193,9 +196,20 @@ void update(void)
int16_t scale = max / Y_SCALE + 1;
char buf[128];
sprintf(buf, "Switch: %d Pull: %d Scale: %d", ecg_switch, internal_pull, scale);
Paint_DrawString_EN(0, 0, buf, &Font8, 0x0000, 0xffff);
sprintf(buf,
"Switch: %d Pull: %d Scale: %d",
ecg_switch,
internal_pull,
scale);
gfx_puts(
&Font8,
&display_screen,
0,
0,
buf,
gfx_color(&display_screen, WHITE),
gfx_color(&display_screen, BLACK)
);
for (int i = 0; i < SIZE_X; i++) {
set(i, (samples[i] / scale));
......@@ -274,76 +288,41 @@ sampling frequency: 200 Hz
#define FILTER_TAP_NUM 71
static double filter_taps[FILTER_TAP_NUM] = {
0.0057445089465822975,
0.007451288673767406,
-0.0011523652638272097,
-0.0030609271459832005,
-0.002596310763437956,
0.004452951934981218,
0.003740429140762826,
-0.002351310203707235,
-0.00638990322759006,
0.000013108391204023357,
0.007226767366250225,
0.003994033360879168,
-0.00665189327484351,
-0.008058131222070393,
0.0035814528837470965,
0.011450459869389184,
0.0016796020911726648,
-0.012657785603199918,
-0.008611714082779583,
0.010587105712461298,
0.01581354994840992,
-0.0044174953741535905,
-0.021419548904285074,
-0.005927897725436821,
0.023159558089340265,
0.01973520678092361,
-0.018604692334579287,
-0.035495574517452874,
0.004958680854279203,
0.05116349477789529,
0.02244341207607204,
-0.06449371846227892,
-0.0790927656214483,
0.07342794634140555,
0.3089023630319309,
0.42341742792869774,
0.3089023630319309,
0.07342794634140555,
-0.0790927656214483,
-0.06449371846227892,
0.02244341207607204,
0.05116349477789529,
0.004958680854279203,
-0.035495574517452874,
-0.018604692334579287,
0.01973520678092361,
0.023159558089340265,
-0.005927897725436821,
-0.021419548904285074,
-0.0044174953741535905,
0.01581354994840992,
0.010587105712461298,
-0.008611714082779583,
-0.012657785603199918,
0.0016796020911726648,
0.011450459869389184,
0.0035814528837470965,
-0.008058131222070393,
-0.00665189327484351,
0.003994033360879168,
0.007226767366250225,
0.000013108391204023357,
-0.00638990322759006,
-0.002351310203707235,
0.003740429140762826,
0.004452951934981218,
-0.002596310763437956,
-0.0030609271459832005,
-0.0011523652638272097,
0.007451288673767406,
0.0057445089465822975, 0.007451288673767406,
-0.0011523652638272097, -0.0030609271459832005,
-0.002596310763437956, 0.004452951934981218,
0.003740429140762826, -0.002351310203707235,
-0.00638990322759006, 0.000013108391204023357,
0.007226767366250225, 0.003994033360879168,
-0.00665189327484351, -0.008058131222070393,
0.0035814528837470965, 0.011450459869389184,
0.0016796020911726648, -0.012657785603199918,
-0.008611714082779583, 0.010587105712461298,
0.01581354994840992, -0.0044174953741535905,
-0.021419548904285074, -0.005927897725436821,
0.023159558089340265, 0.01973520678092361,
-0.018604692334579287, -0.035495574517452874,
0.004958680854279203, 0.05116349477789529,
0.02244341207607204, -0.06449371846227892,
-0.0790927656214483, 0.07342794634140555,
0.3089023630319309, 0.42341742792869774,
0.3089023630319309, 0.07342794634140555,
-0.0790927656214483, -0.06449371846227892,
0.02244341207607204, 0.05116349477789529,
0.004958680854279203, -0.035495574517452874,
-0.018604692334579287, 0.01973520678092361,
0.023159558089340265, -0.005927897725436821,
-0.021419548904285074, -0.0044174953741535905,
0.01581354994840992, 0.010587105712461298,
-0.008611714082779583, -0.012657785603199918,
0.0016796020911726648, 0.011450459869389184,
0.0035814528837470965, -0.008058131222070393,
-0.00665189327484351, 0.003994033360879168,
0.007226767366250225, 0.000013108391204023357,
-0.00638990322759006, -0.002351310203707235,
0.003740429140762826, 0.004452951934981218,
-0.002596310763437956, -0.0030609271459832005,
-0.0011523652638272097, 0.007451288673767406,
0.0057445089465822975
};
#endif
......@@ -376,28 +355,31 @@ static void add_sample(int16_t sample)
}
static volatile bool ecgFIFOIntFlag = false;
static void ecgFIFO_callback(void *data) {
static void ecgFIFO_callback(void *data)
{
ecgFIFOIntFlag = true;
}
// *****************************************************************************
int main(void)
{
card10_init();
card10_diag();
const gpio_cfg_t interrupt_pin = {PORT_1, PIN_12, GPIO_FUNC_IN, GPIO_PAD_PULL_UP};
const gpio_cfg_t interrupt_pin = {
PORT_1, PIN_12, GPIO_FUNC_IN, GPIO_PAD_PULL_UP
};
GPIO_Config(&interrupt_pin);
GPIO_RegisterCallback(&interrupt_pin, ecgFIFO_callback, NULL);
GPIO_IntConfig(&interrupt_pin, GPIO_INT_EDGE, GPIO_INT_FALLING);
GPIO_IntEnable(&interrupt_pin);
NVIC_EnableIRQ(MXC_GPIO_GET_IRQ(PORT_1));
const gpio_cfg_t analog_switch = {PORT_0, PIN_31, GPIO_FUNC_OUT, GPIO_PAD_NONE};
const gpio_cfg_t analog_switch = {
PORT_0, PIN_31, GPIO_FUNC_OUT, GPIO_PAD_NONE
};
GPIO_Config(&analog_switch);
ecg_switch = false;
GPIO_OutClr(&analog_switch); // Wrist
......@@ -417,16 +399,13 @@ int main(void)
max86150_setup(0x1F, 4, 3, 400, 411, 4096);
#endif
uint32_t ecgFIFO, readECGSamples, idx, ETAG[32], status;
int16_t ecgSample[32];
const int EINT_STATUS_MASK = 1 << 23;
const int FIFO_OVF_MASK = 0x7;
const int FIFO_VALID_SAMPLE_MASK = 0x0;
const int FIFO_FAST_SAMPLE_MASK = 0x1;
const int ETAG_BITS_MASK = 0x7;
const uint32_t EINT_STATUS_MASK = 1 << 23;
const uint32_t FIFO_OVF_MASK = 0x7;
const uint32_t FIFO_VALID_SAMPLE_MASK = 0x0;
const uint32_t FIFO_FAST_SAMPLE_MASK = 0x1;
const uint32_t ETAG_BITS_MASK = 0x7;
while (1) {
#if 1
......@@ -436,7 +415,8 @@ int main(void)
if (PB_Get(3)) {
ecg_switch = !ecg_switch;
while(PB_Get(0));
while (PB_Get(0))
;
if (ecg_switch) {
GPIO_OutSet(&analog_switch); // USB
} else {
......@@ -446,31 +426,40 @@ int main(void)
if (PB_Get(4)) {
internal_pull = !internal_pull;
while(PB_Get(2));
while (PB_Get(2))
;
ecg_config(internal_pull);
}
//printf("Int\n");
status = ecg_read_reg( STATUS ); // Read the STATUS register
status = ecg_read_reg(
STATUS); // Read the STATUS register
// Check if EINT interrupt asserted
if ((status & EINT_STATUS_MASK) == EINT_STATUS_MASK) {
readECGSamples = 0; // Reset sample counter
do {
ecgFIFO = ecg_read_reg(ECG_FIFO ); // Read FIFO
ecgSample[readECGSamples] = ecgFIFO >> 8; // Isolate voltage data
ETAG[readECGSamples] = ( ecgFIFO >> 3 ) & ETAG_BITS_MASK; // Isolate ETAG
ecgFIFO = ecg_read_reg(
ECG_FIFO); // Read FIFO
ecgSample[readECGSamples] =
ecgFIFO >>
8; // Isolate voltage data
ETAG[readECGSamples] =
(ecgFIFO >> 3) &
ETAG_BITS_MASK; // Isolate ETAG
readECGSamples++; // Increment sample counter
// Check that sample is not last sample in FIFO
} while ( ETAG[readECGSamples-1] == FIFO_VALID_SAMPLE_MASK ||
ETAG[readECGSamples-1] == FIFO_FAST_SAMPLE_MASK );
} while (ETAG[readECGSamples - 1] ==
FIFO_VALID_SAMPLE_MASK ||
ETAG[readECGSamples - 1] ==
FIFO_FAST_SAMPLE_MASK);
// Check if FIFO has overflowed
if (ETAG[readECGSamples - 1] == FIFO_OVF_MASK) {
ecg_write_reg(FIFO_RST , 0); // Reset FIFO
ecg_write_reg(
FIFO_RST, 0); // Reset FIFO
//printf("OV\n");
// notifies the user that an over flow occured
//LED_On(0);
......
......@@ -187,7 +187,8 @@ void vTickTockTask(void *pvParameters)
while (1) {
ticks = xTaskGetTickCount();
printf("Uptime is 0x%08lx (%lu seconds), tickless-idle is %s\n",
ticks, ticks / configTICK_RATE_HZ,
ticks,
ticks / configTICK_RATE_HZ,
disable_tickless ? "disabled" : "ENABLED");
vTaskDelayUntil(&xLastWakeTime, (configTICK_RATE_HZ * 60));
}
......@@ -274,7 +275,8 @@ void vCmdLineTask(void *pvParameters)
fflush(stdout);
while (1) {
/* Register async read request */
if (UART_ReadAsync(ConsoleUART, &async_read_req) != E_NO_ERROR) {
if (UART_ReadAsync(ConsoleUART, &async_read_req) !=
E_NO_ERROR) {
printf("Error registering async request. Command line unavailable.\n");
vTaskDelay(portMAX_DELAY);
}
......@@ -297,18 +299,26 @@ void vCmdLineTask(void *pvParameters)
printf("^C");
printf("\ncmd> ");
fflush(stdout);
} else if ((tmp == '\r') ||
(tmp == '\n')) {
} else if ((tmp == '\r') || (tmp == '\n')) {
printf("\r\n");
/* Null terminate for safety */
buffer[index] = 0x00;
/* Evaluate */
do {
xMore = FreeRTOS_CLIProcessCommand(buffer, output, OUTPUT_BUF_SIZE);
xMore = FreeRTOS_CLIProcessCommand(
buffer,
output,
OUTPUT_BUF_SIZE
);
/* If xMore == pdTRUE, then output buffer contains no null termination, so
* we know it is OUTPUT_BUF_SIZE. If pdFALSE, we can use strlen.
*/
for (x = 0; x < (xMore == pdTRUE ? OUTPUT_BUF_SIZE : strlen(output)) ; x++) {
for (x = 0;
x <
(xMore == pdTRUE ?
OUTPUT_BUF_SIZE :
strlen(output));
x++) {
putchar(*(output + x));
}
} while (xMore != pdFALSE);
......@@ -326,8 +336,14 @@ void vCmdLineTask(void *pvParameters)
fflush(stdout);
}
/* If more characters are ready, process them here */
} while ((UART_NumReadAvail(MXC_UART_GET_UART(CONSOLE_UART)) > 0) &&
UART_Read(MXC_UART_GET_UART(CONSOLE_UART), (uint8_t *)&tmp, 1, NULL));
} while ((UART_NumReadAvail(MXC_UART_GET_UART(
CONSOLE_UART)) > 0) &&
UART_Read(
MXC_UART_GET_UART(CONSOLE_UART),
(uint8_t *)&tmp,
1,
NULL)
);
}
}
}
......@@ -365,15 +381,13 @@ void RTC_IRQHandler(void)
int main(void)
{
#if configUSE_TICKLESS_IDLE
uart_cfg_t uart_cfg = {
.parity = UART_PARITY_DISABLE,
uart_cfg_t uart_cfg = { .parity = UART_PARITY_DISABLE,
.size = UART_DATA_SIZE_8_BITS,
.stop = UART_STOP_1,
.flow = UART_FLOW_CTRL_DIS,
.pol = UART_FLOW_POL_DIS,
.baud = 115200,
.clksel = UART_CLKSEL_SYSTEM
};
.clksel = UART_CLKSEL_SYSTEM };
sys_cfg_uart_t uart_sys_cfg = { MAP_A, Enable };
/* The RTC must be enabled for tickless operation */
......@@ -389,7 +403,9 @@ int main(void)
#endif
/* Print banner (RTOS scheduler not running) */
printf("\n-=- %s FreeRTOS (%s) Demo -=-\n", STRING(TARGET), tskKERNEL_VERSION_NUMBER);
printf("\n-=- %s FreeRTOS (%s) Demo -=-\n",
STRING(TARGET),
tskKERNEL_VERSION_NUMBER);
#if configUSE_TICKLESS_IDLE
printf("Tickless idle is configured. Type 'tickless 1' to enable.\n");
#endif
......@@ -400,14 +416,35 @@ int main(void)
printf("xSemaphoreCreateMutex failed to create a mutex.\n");
} else {
/* Configure task */
if ((xTaskCreate(vTask0, (const char *)"Task0",
configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) ||
(xTaskCreate(vTask1, (const char *)"Task1",
configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) ||
(xTaskCreate(vTickTockTask, (const char *)"TickTock",
2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+2, NULL) != pdPASS) ||
(xTaskCreate(vCmdLineTask, (const char *)"CmdLineTask",
configMINIMAL_STACK_SIZE+CMD_LINE_BUF_SIZE+OUTPUT_BUF_SIZE, NULL, tskIDLE_PRIORITY+1, &cmd_task_id) != pdPASS)) {
if ((xTaskCreate(
vTask0,
(const char *)"Task0",
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 1,
NULL) != pdPASS) ||
(xTaskCreate(
vTask1,
(const char *)"Task1",
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 1,
NULL) != pdPASS) ||
(xTaskCreate(
vTickTockTask,
(const char *)"TickTock",
2 * configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 2,
NULL) != pdPASS) ||
(xTaskCreate(
vCmdLineTask,
(const char *)"CmdLineTask",
configMINIMAL_STACK_SIZE + CMD_LINE_BUF_SIZE +
OUTPUT_BUF_SIZE,
NULL,
tskIDLE_PRIORITY + 1,
&cmd_task_id) != pdPASS)) {
printf("xTaskCreate() failed to create a task.\n");
} else {
/* Start scheduler */
......
......@@ -7,7 +7,8 @@
#include "leds.h"
#include "card10.h"
#include "GUI_Paint.h"
#include "gfx.h"
#include "display.h"
#include "tmr_utils.h"
......@@ -19,7 +20,8 @@
/***** Definitions *****/
/***** Globals *****/
static __attribute__((unused)) const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
static __attribute__((unused))
const gpio_cfg_t motor_pin = { PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE };
int main(void)
{
......@@ -28,11 +30,19 @@ int main(void)
card10_init();
card10_diag();
Paint_DrawImage(Heart, 0, 0, 160, 80);
LCD_Update();
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RGB565,
(const void *)(Heart)
);
gfx_update(&display_screen);
for (int i = 0; i < 11; i++) {
leds_set_dim(i, 1);
// leds_set_dim(i, 1);
}
int __attribute__((unused)) h = 0;
......
......@@ -3,38 +3,40 @@
******************************************************************************/
/***** Includes *****/
#include "mxc_config.h"
#include "led.h"
#include "bhy_uc_driver.h"
#include "board.h"
#include "tmr_utils.h"
#include "display.h"
#include "gfx.h"
#include "gpio.h"
#include "i2c.h"
#include "led.h"
#include "mxc_config.h"
#include "pmic.h"
#include "rtc.h"
#include "spi.h"
#include "gpio.h"
#include "bhy_uc_driver.h"
#include "pmic.h"
#include "GUI_DEV/GUI_Paint.h"
#include "tmr_utils.h"
#include "card10.h"
#include <math.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define M_PI 3.1415
/***** Definitions *****/
/* should be greater or equal to 69 bytes, page size (50) + maximum packet size(18) + 1 */
/* should be greater or equal to 69 bytes, page size (50) + maximum packet
* size(18) + 1 */
#define FIFO_SIZE 300
#define ROTATION_VECTOR_SAMPLE_RATE 10
#define MAX_PACKET_LENGTH 18
#define OUT_BUFFER_SIZE 60
/***** Globals *****/
char out_buffer[OUT_BUFFER_SIZE] = " W: 0.999 X: 0.999 Y: 0.999 Z: 0.999 \r";
char out_buffer[OUT_BUFFER_SIZE] =
" W: 0.999 X: 0.999 Y: 0.999 Z: 0.999 \r";
uint8_t fifo[FIFO_SIZE];
void draw_arrow(int angle, int color)
......@@ -48,7 +50,7 @@ void draw_arrow(int angle, int color)
int x2 = x1 - sin * 30;
int y2 = y1 - cos * 30;
Paint_DrawLine(x1, y1, x2, y2, color, LINE_STYLE_SOLID, DOT_PIXEL_2X2);
gfx_line(&display_screen, x1, y1, x2, y2, 2, color);
sin = sinf((angle - 140) * 2 * M_PI / 360.);
cos = cosf((angle - 140) * 2 * M_PI / 360.);
......@@ -56,7 +58,7 @@ void draw_arrow(int angle, int color)
int x3 = x2 - sin * 10;
int y3 = y2 - cos * 10;
Paint_DrawLine(x2, y2, x3, y3, color, LINE_STYLE_SOLID, DOT_PIXEL_2X2);
gfx_line(&display_screen, x2, y2, x3, y3, 2, color);
sin = sinf((angle + 140) * 2 * M_PI / 360.);
cos = cosf((angle + 140) * 2 * M_PI / 360.);
......@@ -64,25 +66,29 @@ void draw_arrow(int angle, int color)
int x4 = x2 - sin * 10;
int y4 = y2 - cos * 10;
Paint_DrawLine(x2, y2, x4, y4, color, LINE_STYLE_SOLID, DOT_PIXEL_2X2);
gfx_line(&display_screen, x2, y2, x4, y4, 2, color);
}
/***** Functions *****/
static void sensors_callback_orientation(bhy_data_generic_t * sensor_data, bhy_virtual_sensor_t sensor_id)
{
static void sensors_callback_orientation(
bhy_data_generic_t *sensor_data, bhy_virtual_sensor_t sensor_id
) {
static int prev = -1;
printf("azimuth=%05d, pitch=%05d, roll=%05d status=%d\n",
sensor_data->data_vector.x * 360 / 32768,
sensor_data->data_vector.y * 360 / 32768,
sensor_data->data_vector.z * 360 / 32768,
sensor_data->data_vector.status
);
sensor_data->data_vector.status);
int angle = sensor_data->data_vector.x * 360 / 32768;
if (angle != prev) {
Paint_Clear(BLACK);
int colors[] = {RED, YELLOW, YELLOW, GREEN};
gfx_clear(&display_screen);
int colors[] = { gfx_color(&display_screen, RED),
gfx_color(&display_screen, YELLOW),
gfx_color(&display_screen, YELLOW),
gfx_color(&display_screen, GREEN) };
int color = colors[sensor_data->data_vector.status];
draw_arrow(sensor_data->data_vector.x * 360 / 32768, color);
......@@ -91,45 +97,51 @@ static void sensors_callback_orientation(bhy_data_generic_t * sensor_data, bhy_v
// Paint_DrawString_EN(0, 0, buf, &Font12, BLACK, color);
sprintf(buf, "%3d", angle);
Paint_DrawString_EN(0, 30, buf, &Font24, BLACK, color);
Paint_DrawCircle(57,35, 4, color, DRAW_FILL_EMPTY, DOT_PIXEL_1X1);
gfx_puts(
&Font24,
&display_screen,
0,
30,
buf,
color,
gfx_color(&display_screen, BLACK)
);
gfx_circle(&display_screen, 57, 35, 4, 2, color);
LCD_Update();
gfx_update(&display_screen);
prev = angle;
}
}
static __attribute__((unused)) void sensors_callback_vector(bhy_data_generic_t * sensor_data, bhy_virtual_sensor_t sensor_id)
{
static __attribute__((unused)) void sensors_callback_vector(
bhy_data_generic_t *sensor_data, bhy_virtual_sensor_t sensor_id
) {
printf("x=%05d, y=%05d, z=%05d status=%d\n",
sensor_data->data_vector.x,
sensor_data->data_vector.y,
sensor_data->data_vector.z,
sensor_data->data_vector.status
);
sensor_data->data_vector.status);
}
static __attribute__((unused)) void sensors_callback_vector_uncalib(bhy_data_generic_t * sensor_data, bhy_virtual_sensor_t sensor_id)
{
static __attribute__((unused)) void sensors_callback_vector_uncalib(
bhy_data_generic_t *sensor_data, bhy_virtual_sensor_t sensor_id
) {
printf("x=%05d, y=%05d, z=%05d status=%d\n",
sensor_data->data_uncalib_vector.x,
sensor_data->data_uncalib_vector.y,
sensor_data->data_uncalib_vector.z,
sensor_data->data_uncalib_vector.status
);
sensor_data->data_uncalib_vector.status);
}
/*!
* @brief This function is callback function for acquring sensor datas
*
* @param[in] sensor_data
* @param[in] sensor_id
*/
static __attribute__((unused)) void sensors_callback_rotation_vector(bhy_data_generic_t * sensor_data, bhy_virtual_sensor_t sensor_id)
{
static __attribute__((unused)) void sensors_callback_rotation_vector(
bhy_data_generic_t *sensor_data, bhy_virtual_sensor_t sensor_id
) {
#if 0
float temp;
uint8_t index;
......@@ -183,8 +195,7 @@ static __attribute__((unused)) void sensors_callback_rotation_vector(bhy_data_ge
sensor_data->data_quaternion.x,
sensor_data->data_quaternion.y,
sensor_data->data_quaternion.z,
sensor_data->data_quaternion.w
);
sensor_data->data_quaternion.w);
}
// *****************************************************************************
......@@ -210,12 +221,18 @@ int main(void)
}
#endif
//if(bhy_install_sensor_callback(VS_TYPE_GEOMAGNETIC_FIELD, VS_WAKEUP, sensors_callback_vector))
//if(bhy_install_sensor_callback(VS_TYPE_GRAVITY, VS_WAKEUP, sensors_callback_vector))
//if(bhy_install_sensor_callback(VS_TYPE_ACCELEROMETER, VS_WAKEUP, sensors_callback_vector))
//if(bhy_install_sensor_callback(VS_TYPE_MAGNETIC_FIELD_UNCALIBRATED, VS_WAKEUP, sensors_callback_vector_uncalib))
if(bhy_install_sensor_callback(VS_TYPE_ORIENTATION, VS_WAKEUP, sensors_callback_orientation))
{
// if(bhy_install_sensor_callback(VS_TYPE_GEOMAGNETIC_FIELD, VS_WAKEUP,
// sensors_callback_vector))
// if(bhy_install_sensor_callback(VS_TYPE_GRAVITY, VS_WAKEUP,
// sensors_callback_vector))
// if(bhy_install_sensor_callback(VS_TYPE_ACCELEROMETER, VS_WAKEUP,
// sensors_callback_vector))
// if(bhy_install_sensor_callback(VS_TYPE_MAGNETIC_FIELD_UNCALIBRATED,
// VS_WAKEUP, sensors_callback_vector_uncalib))
if (bhy_install_sensor_callback(
VS_TYPE_ORIENTATION,
VS_WAKEUP,
sensors_callback_orientation)) {
printf("Fail to install sensor callback\n");
}
......@@ -227,52 +244,73 @@ int main(void)
}
#endif
/* enables the virtual sensor */
//if(bhy_enable_virtual_sensor(VS_TYPE_GEOMAGNETIC_FIELD, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
//if(bhy_enable_virtual_sensor(VS_TYPE_GRAVITY, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
//if(bhy_enable_virtual_sensor(VS_TYPE_ACCELEROMETER, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
//if(bhy_enable_virtual_sensor(VS_TYPE_MAGNETIC_FIELD_UNCALIBRATED, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
if(bhy_enable_virtual_sensor(VS_TYPE_ORIENTATION, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
{
printf("Fail to enable sensor id=%d\n", VS_TYPE_GEOMAGNETIC_FIELD);
// if(bhy_enable_virtual_sensor(VS_TYPE_GEOMAGNETIC_FIELD, VS_WAKEUP,
// ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
// if(bhy_enable_virtual_sensor(VS_TYPE_GRAVITY, VS_WAKEUP,
// ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
// if(bhy_enable_virtual_sensor(VS_TYPE_ACCELEROMETER, VS_WAKEUP,
// ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
// if(bhy_enable_virtual_sensor(VS_TYPE_MAGNETIC_FIELD_UNCALIBRATED,
// VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
if (bhy_enable_virtual_sensor(
VS_TYPE_ORIENTATION,
VS_WAKEUP,
ROTATION_VECTOR_SAMPLE_RATE,
0,
VS_FLUSH_NONE,
0,
0)) {
printf("Fail to enable sensor id=%d\n",
VS_TYPE_GEOMAGNETIC_FIELD);
}
while(1)
{
while (1) {
/* wait until the interrupt fires */
/* unless we already know there are bytes remaining in the fifo */
while (!GPIO_InGet(&bhi_interrupt_pin) && !bytes_remaining);
bhy_read_fifo(fifo + bytes_left_in_fifo, FIFO_SIZE - bytes_left_in_fifo, &bytes_read, &bytes_remaining);
while (!GPIO_InGet(&bhi_interrupt_pin) && !bytes_remaining)
;
bhy_read_fifo(
fifo + bytes_left_in_fifo,
FIFO_SIZE - bytes_left_in_fifo,
&bytes_read,
&bytes_remaining
);
bytes_read += bytes_left_in_fifo;
fifoptr = fifo;
packet_type = BHY_DATA_TYPE_PADDING;
do
{
do {
/* this function will call callbacks that are registered */
result = bhy_parse_next_fifo_packet(&fifoptr, &bytes_read, &fifo_packet, &packet_type);
result = bhy_parse_next_fifo_packet(
&fifoptr,
&bytes_read,
&fifo_packet,
&packet_type
);
/* prints all the debug packets */
if (packet_type == BHY_DATA_TYPE_DEBUG)
{
bhy_print_debug_packet(&fifo_packet.data_debug, bhy_printf);
if (packet_type == BHY_DATA_TYPE_DEBUG) {
bhy_print_debug_packet(
&fifo_packet.data_debug, bhy_printf
);
}
/* the logic here is that if doing a partial parsing of the fifo, then we should not parse */
/* the last 18 bytes (max length of a packet) so that we don't try to parse an incomplete */
/* the logic here is that if doing a partial parsing of the fifo, then we
* should not parse */
/* the last 18 bytes (max length of a packet) so that we don't try to
* parse an incomplete */
/* packet */
} while ((result == BHY_SUCCESS) && (bytes_read > (bytes_remaining ? MAX_PACKET_LENGTH : 0)));
} while ((result == BHY_SUCCESS) &&
(bytes_read >
(bytes_remaining ? MAX_PACKET_LENGTH : 0)));
bytes_left_in_fifo = 0;
if (bytes_remaining)
{
if (bytes_remaining) {
/* shifts the remaining bytes to the beginning of the buffer */
while (bytes_left_in_fifo < bytes_read)
{
while (bytes_left_in_fifo < bytes_read) {
fifo[bytes_left_in_fifo++] = *(fifoptr++);
}
}
......
......@@ -3,20 +3,21 @@
******************************************************************************/
/***** Includes *****/
#include "tmr_utils.h"
#include "gpio.h"
#include "GUI_DEV/GUI_Paint.h"
#include "DEV_Config.h"
#include "Fonts/fonts.h"
#include "display.h"
#include "gfx.h"
#include "gpio.h"
#include "image/image.h"
#include "tmr.h"
#include "tmr_utils.h"
#include "card10.h"
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
// *****************************************************************************
int main(void)
{
......@@ -25,17 +26,37 @@ int main(void)
card10_init();
card10_diag();
Paint_DrawString_EN(0, 0, "123", &Font24, 0x000f, 0xfff0);
Paint_DrawString_EN(0, 23, "ABC", &Font24, BLUE, CYAN);
Paint_DrawString_CN(20,42, "΢ѩµç×Ó", &Font24CN, WHITE, RED);
Paint_DrawRectangle(70, 10, 100, 40, RED,DRAW_FILL_EMPTY, DOT_PIXEL_2X2 );
Paint_DrawLine(70, 10, 100, 40, MAGENTA, LINE_STYLE_SOLID, DOT_PIXEL_2X2);
Paint_DrawLine(100, 10, 70, 40, MAGENTA, LINE_STYLE_SOLID, DOT_PIXEL_2X2);
Paint_DrawCircle(85,25, 22, GREEN, DRAW_FILL_EMPTY, DOT_PIXEL_2X2);
Paint_DrawImage(gImage_40X40,120, 0,40, 40);
Paint_DrawImage(gImage_160X80,0, 0, 160, 80);
LCD_Update();
Color red = gfx_color(&display_screen, RED);
Color green = gfx_color(&display_screen, GREEN);
Color yellow = gfx_color(&display_screen, YELLOW);
gfx_puts(&Font24, &display_screen, 0, 0, "123", 0x000f, 0xfff8);
gfx_puts(&Font24, &display_screen, 23, 0, "ABC", 0x000f, 0xfff8);
gfx_rectangle(&display_screen, 70, 10, 100, 40, 2, red);
gfx_line(&display_screen, 70, 10, 100, 40, 2, green);
gfx_line(&display_screen, 100, 10, 70, 40, 2, yellow);
gfx_circle(&display_screen, 85, 25, 22, 2, green);
gfx_copy_region(
&display_screen,
120,
0,
40,
40,
GFX_RGB565,
(const void *)(gImage_40X40)
);
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RGB565,
(const void *)(gImage_160X80)
);
gfx_update(&display_screen);
DEV_Delay_ms(3000);
while (1) {
......