diff --git a/.vscode/launch.json b/.vscode/launch.json index af0bac21c1f8c5e7a503da49ecdfac68b71f68d3..4e2f8b18ab6584b66baa1fd5c176c992ef17cb27 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,7 +25,7 @@ "svdFile": "CMSIS/Device/PY32F0xx/py32f030axx.svd", "preLaunchTask": "Build", "showDevDebugOutput":"raw", - "serverArgs": ["-speed", "100"] + "serverArgs": ["-speed", "1000"] } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 1869ce24078e4128c9d46f609848bf5ba102b2e1..2897ab35ff067ad8790e809ea854a07cdece4946 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,8 @@ "files.associations": { "py32f030x8.h": "c", "stdio.h": "c", - "main.h": "c" + "main.h": "c", + "memory": "c" }, "cortex-debug.variableUseNaturalFormat": false, "makefile.configureOnOpen": true diff --git a/inc/display.h b/inc/display.h index 31d2687a6fdeb0a6628459afbeb44ee330dccdb8..b6703ab743c72ca13f67ee345fb6c6c7da91e33a 100644 --- a/inc/display.h +++ b/inc/display.h @@ -51,9 +51,9 @@ const uint8_t * flag[20] = {Frame0, Frame1, Frame2, Frame3, Frame4, Frame5, Frame6, Frame7, Frame8, Frame9, Frame10, \ Frame11, Frame12, Frame13, Frame14, Frame15, Frame16, Frame17, Frame18, Frame19}; -const uint8_t * gif[18] = {gif1, gif2, gif3, gif4, gif5, gif6, gif7, gif8, gif9, gif10, \ - gif11, gif12, gif13, gif14, gif15, gif16, gif17, gif18}; -const uint8_t * pointers[9] = {gbr0, gbr1, gbr2, gbr3, gbr4, gbr5, gbr6, gbr7, gbr8}; +const uint8_t * herbie[18] = {herbie1, herbie2, herbie3, herbie4, herbie5, herbie6, herbie7, herbie8, herbie9, herbie10, \ + herbie11, herbie12, herbie13, herbie14, herbie15, herbie16, herbie17, herbie18}; +const uint8_t * gbr[9] = {gbr0, gbr1, gbr2, gbr3, gbr4, gbr5, gbr6, gbr7, gbr8}; uint8_t init1[5] = {0x00, 0xAE, 0xD5, 0x80, 0xA8}; uint8_t init2[2] = {0x00, 0x3F}; diff --git a/inc/frames.h b/inc/frames.h index 1261f92e21361442a35445dd2161e5d81f6fcb7c..171193be52bba16b221817c0568cd083f4708cbe 100644 --- a/inc/frames.h +++ b/inc/frames.h @@ -2178,7 +2178,7 @@ const uint8_t apply_qr[1024] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const uint8_t gif0[1024] = { +const uint8_t herbie0[1024] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xb8, 0x00, 0x00, 0x00, 0x20, 0x30, 0x7e, 0x7e, 0x78, 0x03, 0x47, 0xdf, 0xff, 0xff, 0xff, 0xff, 0x79, 0x00, 0x21, 0x0f, 0xff, 0x01, 0x00, 0x7f, 0xf0, 0x80, 0xc8, 0x00, 0x18, 0x70, 0xb8, 0x9c, 0xfc, 0xf0, 0xf0, 0xe0, 0x00, 0x00, 0xe7, 0xe8, 0xe8, 0xe0, @@ -2244,7 +2244,7 @@ const uint8_t gif0[1024] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1c}; -const uint8_t gif1[1024] = { +const uint8_t herbie1[1024] = { 0x6d, 0xfe, 0xd4, 0x7a, 0xcc, 0xfa, 0xa4, 0x51, 0x2a, 0x80, 0x13, 0x44, 0x72, 0xac, 0xf1, 0xaa, 0x04, 0xde, 0x3e, 0xed, 0x76, 0xdc, 0x76, 0xad, 0xc0, 0x0b, 0x5e, 0xff, 0x02, 0xbd, 0xf7, 0x40, 0x90, 0x44, 0x10, 0xe1, 0x54, 0x30, 0xf0, 0xe2, 0xd1, 0x46, 0x90, 0x00, 0xe9, 0x92, 0x64, 0xcb, @@ -2310,7 +2310,7 @@ const uint8_t gif1[1024] = { 0x88, 0x52, 0x25, 0x88, 0x52, 0x25, 0x88, 0x52, 0x25, 0x88, 0x52, 0x25, 0x48, 0x91, 0x2e, 0xf1, 0xaf, 0xfe, 0xad, 0xf7, 0xbf, 0xea, 0xbf, 0xeb, 0xbe, 0x2b, 0x80, 0x76, 0x89, 0x52, 0xad, 0x72}; -const uint8_t gif2[1024] = { +const uint8_t herbie2[1024] = { 0xff, 0xa7, 0xfb, 0xb0, 0x68, 0xd1, 0x76, 0x81, 0x4e, 0x11, 0xa2, 0x0c, 0x51, 0xa4, 0xd5, 0xa0, 0x8a, 0x30, 0x7a, 0xf1, 0x7a, 0xd0, 0xba, 0xf0, 0x0b, 0x90, 0x7e, 0xfd, 0x16, 0xab, 0xfe, 0x87, 0x00, 0x49, 0x80, 0x92, 0x40, 0xc4, 0xc0, 0x08, 0x96, 0x20, 0x49, 0x00, 0x44, 0x99, 0xa2, 0x1c, @@ -2376,7 +2376,7 @@ const uint8_t gif2[1024] = { 0x82, 0x29, 0x54, 0x82, 0x29, 0x54, 0x82, 0x29, 0x54, 0x82, 0x29, 0x54, 0x02, 0xe8, 0x17, 0xe8, 0xbf, 0xeb, 0xbe, 0xfb, 0xae, 0xf7, 0xbe, 0xeb, 0xbe, 0x4b, 0x90, 0x2b, 0xa4, 0x49, 0xb6, 0xc9}; -const uint8_t gif3[1024] = { +const uint8_t herbie3[1024] = { 0xdf, 0x7a, 0xce, 0xc0, 0xa9, 0x44, 0xc9, 0x1a, 0xa5, 0x0a, 0x34, 0x41, 0x94, 0x4a, 0x90, 0x24, 0x01, 0xe8, 0xc2, 0xe8, 0xa5, 0xe0, 0xa8, 0xe4, 0x0a, 0xf5, 0xea, 0x78, 0x95, 0xfc, 0x18, 0x49, 0x02, 0x50, 0x00, 0x04, 0x50, 0x02, 0x01, 0x5c, 0x83, 0x24, 0x81, 0x00, 0xb5, 0x48, 0x12, 0x70, @@ -2442,7 +2442,7 @@ const uint8_t gif3[1024] = { 0xa2, 0x48, 0x14, 0xa2, 0x49, 0x14, 0xa2, 0x48, 0x15, 0xa2, 0x48, 0x14, 0x42, 0xb5, 0x4a, 0xf5, 0xbf, 0xea, 0xbf, 0xed, 0xb7, 0xfe, 0xab, 0xfe, 0x9b, 0x22, 0x4d, 0xa3, 0x5d, 0x83, 0x7b, 0x85}; -const uint8_t gif4[1024] = { +const uint8_t herbie4[1024] = { 0xf8, 0x60, 0x02, 0x48, 0x01, 0x74, 0xc9, 0x14, 0xe9, 0x06, 0xa8, 0x11, 0xa0, 0x00, 0x52, 0x80, 0x09, 0x52, 0x04, 0x50, 0x01, 0x20, 0x4a, 0x90, 0x65, 0x9a, 0xe0, 0x44, 0xf0, 0xc5, 0x20, 0x09, 0x40, 0x00, 0x24, 0x00, 0x8a, 0x20, 0xaf, 0x1a, 0x20, 0x04, 0x81, 0x36, 0xc1, 0x0b, 0xd0, 0x07, @@ -2508,7 +2508,7 @@ const uint8_t gif4[1024] = { 0x91, 0x2a, 0x40, 0x95, 0x28, 0x42, 0x95, 0x28, 0x41, 0x94, 0x2a, 0x40, 0x10, 0xdf, 0x20, 0xff, 0xd5, 0xbf, 0xed, 0xb7, 0xfd, 0xaf, 0xfa, 0xef, 0x35, 0x4b, 0x92, 0x4e, 0xb2, 0x06, 0xfb, 0x06}; -const uint8_t gif5[1024] = { +const uint8_t herbie5[1024] = { 0x80, 0x08, 0x42, 0xa0, 0x05, 0xb2, 0x44, 0xa9, 0x52, 0x84, 0x20, 0x40, 0x11, 0x40, 0x0a, 0x81, 0x14, 0xa0, 0x04, 0x20, 0x80, 0x15, 0xc0, 0x15, 0xea, 0x05, 0x90, 0x41, 0x82, 0x14, 0x41, 0x01, 0x12, 0x40, 0x04, 0x00, 0x5a, 0xa1, 0x7e, 0x01, 0x02, 0x55, 0x23, 0x8c, 0x4a, 0x15, 0x4a, 0x95, @@ -2574,7 +2574,7 @@ const uint8_t gif5[1024] = { 0xa5, 0x50, 0x09, 0xa4, 0x52, 0x08, 0xa4, 0x51, 0x0a, 0x50, 0x84, 0x21, 0x54, 0xab, 0x54, 0xff, 0xd5, 0xbf, 0xf5, 0xbf, 0xea, 0xbf, 0xf5, 0x6f, 0x9a, 0x25, 0x4c, 0xbb, 0x44, 0x9e, 0x65, 0x0a}; -const uint8_t gif6[1024] = { +const uint8_t herbie6[1024] = { 0x00, 0x12, 0x40, 0x82, 0x29, 0x92, 0x64, 0x89, 0x52, 0xa4, 0x01, 0x40, 0x80, 0x2a, 0x00, 0x42, 0x14, 0x40, 0x10, 0x82, 0x00, 0x55, 0x80, 0x29, 0xd6, 0x20, 0x8a, 0x80, 0x22, 0x08, 0x42, 0x05, 0x90, 0x01, 0x40, 0x0a, 0x91, 0x76, 0x89, 0x22, 0x15, 0xc2, 0x1d, 0x22, 0x8c, 0x1b, 0x40, 0x04, @@ -2640,7 +2640,7 @@ const uint8_t gif6[1024] = { 0x55, 0x20, 0x89, 0x52, 0x24, 0x88, 0x51, 0x22, 0x84, 0x50, 0x0a, 0x60, 0x8f, 0x78, 0xd7, 0xbb, 0xed, 0xbf, 0xeb, 0xbe, 0xd7, 0xfd, 0xb7, 0x6b, 0x0c, 0xd9, 0x2a, 0x9a, 0x69, 0x9e, 0x24, 0x49}; -const uint8_t gif7[1024] = { +const uint8_t herbie7[1024] = { 0x40, 0x04, 0x20, 0x82, 0x49, 0x12, 0xe4, 0x12, 0xa4, 0x50, 0x05, 0x40, 0x80, 0x0a, 0x20, 0x02, 0x95, 0x40, 0x10, 0x82, 0x20, 0x04, 0x49, 0x90, 0x4b, 0x94, 0x22, 0x80, 0x25, 0x0a, 0x40, 0x03, 0x24, 0x81, 0x08, 0x01, 0xb2, 0xcd, 0x32, 0x85, 0x12, 0x46, 0x51, 0x0e, 0xb1, 0x0e, 0x50, 0x00, @@ -2706,7 +2706,7 @@ const uint8_t gif7[1024] = { 0x08, 0x54, 0xa2, 0x04, 0x51, 0xaa, 0x00, 0x55, 0xa0, 0x0a, 0x40, 0x2d, 0xd2, 0x2d, 0xfb, 0xd6, 0xbf, 0xed, 0xbb, 0xff, 0xaa, 0xff, 0xbb, 0x4c, 0x19, 0xea, 0x13, 0xbc, 0x49, 0x9a, 0x35, 0x48}; -const uint8_t gif8[1024] = { +const uint8_t herbie8[1024] = { 0x50, 0xc4, 0xa0, 0x00, 0x04, 0x51, 0x82, 0x54, 0x89, 0x72, 0x84, 0x29, 0x40, 0x82, 0x00, 0x48, 0x02, 0x48, 0x04, 0x50, 0x02, 0x90, 0x01, 0x2a, 0x40, 0x8d, 0x52, 0x25, 0x80, 0x0b, 0x20, 0x8b, 0x02, 0x45, 0x00, 0x13, 0x40, 0x05, 0xab, 0x6d, 0x01, 0x26, 0x95, 0x22, 0x4e, 0x18, 0xb3, 0x44, @@ -2772,7 +2772,7 @@ const uint8_t gif8[1024] = { 0x12, 0x44, 0x90, 0x25, 0x48, 0x91, 0x22, 0x44, 0x28, 0x81, 0x54, 0x01, 0x5e, 0xa0, 0x5f, 0xf5, 0xdf, 0xb5, 0xff, 0xaa, 0xff, 0xb6, 0xed, 0xbf, 0x69, 0x12, 0xf4, 0x2a, 0xb1, 0x56, 0xb9, 0x22}; -const uint8_t gif9[1024] = { +const uint8_t herbie9[1024] = { 0xa0, 0xe5, 0x88, 0xe0, 0x82, 0x10, 0x01, 0xa4, 0x49, 0x92, 0x64, 0x92, 0x24, 0x41, 0x80, 0x12, 0x40, 0x05, 0x10, 0x45, 0x90, 0x00, 0x49, 0x00, 0xa2, 0x08, 0xc5, 0x3a, 0x40, 0x05, 0x11, 0x84, 0x23, 0x04, 0x23, 0x88, 0x01, 0x11, 0xa2, 0x0d, 0xb2, 0x05, 0x02, 0xad, 0x42, 0x1e, 0x91, 0x36, @@ -2838,7 +2838,7 @@ const uint8_t gif9[1024] = { 0x22, 0x48, 0x25, 0x90, 0x49, 0x22, 0x94, 0x40, 0x29, 0x42, 0x90, 0x0a, 0x21, 0x54, 0xab, 0x54, 0xff, 0xd5, 0xbf, 0xeb, 0xbe, 0xfb, 0xaf, 0xf5, 0x5f, 0xf3, 0x14, 0x71, 0xaa, 0x35, 0xd2, 0x35}; -const uint8_t gif10[1024] = { +const uint8_t herbie10[1024] = { 0xf0, 0x62, 0xd4, 0xa1, 0xe8, 0x00, 0x84, 0x21, 0x52, 0x88, 0x72, 0x85, 0x28, 0x52, 0x80, 0x40, 0x04, 0x50, 0x01, 0x0a, 0xa0, 0x09, 0xa0, 0x04, 0x20, 0x82, 0x24, 0xc9, 0x36, 0x00, 0x01, 0x2a, 0x00, 0xa5, 0x02, 0x48, 0x01, 0x14, 0x01, 0x44, 0xb9, 0x02, 0x85, 0x12, 0xca, 0x15, 0x4a, 0x34, @@ -2904,7 +2904,7 @@ const uint8_t gif10[1024] = { 0x48, 0x22, 0x94, 0x40, 0x15, 0x48, 0xa2, 0x08, 0x52, 0x24, 0x80, 0x29, 0x42, 0x10, 0xae, 0x51, 0xae, 0xfb, 0xae, 0xfb, 0xaf, 0xfa, 0xaf, 0xfe, 0xab, 0xff, 0x10, 0x55, 0xba, 0x21, 0xde, 0x31}; -const uint8_t gif11[1024] = { +const uint8_t herbie11[1024] = { 0xf0, 0xdd, 0xf0, 0x68, 0x51, 0x00, 0x64, 0x12, 0xe5, 0x18, 0xa5, 0x48, 0x12, 0xa0, 0x41, 0x24, 0x80, 0x02, 0x48, 0x22, 0x10, 0x44, 0x00, 0x50, 0x04, 0x60, 0x95, 0x4a, 0x10, 0x05, 0x50, 0x02, 0x11, 0x82, 0x00, 0x12, 0x40, 0x05, 0x10, 0xa7, 0x98, 0x01, 0x82, 0x2d, 0xc1, 0x1e, 0x01, 0x5e, @@ -2970,7 +2970,7 @@ const uint8_t gif11[1024] = { 0x50, 0x89, 0x22, 0x54, 0x00, 0xa9, 0x52, 0x04, 0x50, 0x85, 0x10, 0x49, 0x22, 0xcd, 0x32, 0xed, 0xdf, 0xba, 0xf7, 0xad, 0xff, 0xba, 0xd7, 0xfe, 0x2b, 0x54, 0x99, 0x52, 0xb9, 0x16, 0xe9, 0x1a}; -const uint8_t gif12[1024] = { +const uint8_t herbie12[1024] = { 0xe8, 0x40, 0xa2, 0x60, 0x88, 0x62, 0x95, 0x68, 0x85, 0x58, 0x21, 0x44, 0xa0, 0x01, 0x88, 0x22, 0x00, 0x4a, 0x10, 0x42, 0x10, 0x40, 0x84, 0x50, 0xa7, 0x90, 0x25, 0x88, 0x82, 0x20, 0x02, 0x11, 0x82, 0x08, 0xa0, 0x05, 0x00, 0xaa, 0x55, 0x02, 0x81, 0x2e, 0x41, 0x9e, 0x01, 0x5e, 0x08, 0xb3, @@ -3036,7 +3036,7 @@ const uint8_t gif12[1024] = { 0x44, 0x12, 0x48, 0xa2, 0x14, 0x41, 0x2a, 0x80, 0x54, 0x01, 0x64, 0x9a, 0x65, 0xde, 0xbb, 0xf7, 0xad, 0xff, 0xaa, 0xff, 0xb5, 0xef, 0x9b, 0x30, 0x55, 0xba, 0x21, 0xde, 0x31, 0x56, 0x90, 0x35}; -const uint8_t gif13[1024] = { +const uint8_t herbie13[1024] = { 0x40, 0x02, 0x50, 0x04, 0xa9, 0x52, 0xa4, 0x4a, 0x90, 0x24, 0x40, 0x80, 0x14, 0x41, 0x00, 0x95, 0x20, 0x8a, 0x20, 0x80, 0x10, 0xc1, 0x28, 0x57, 0x80, 0x2a, 0x80, 0x14, 0x43, 0x00, 0x13, 0x04, 0x41, 0x08, 0x42, 0x00, 0xab, 0x52, 0x04, 0x12, 0x4a, 0x95, 0x12, 0x4d, 0x30, 0x8f, 0x30, 0xad, @@ -3102,7 +3102,7 @@ const uint8_t gif13[1024] = { 0x15, 0x48, 0xa2, 0x08, 0x52, 0x24, 0x80, 0x49, 0x14, 0x42, 0xb5, 0x4a, 0xbd, 0xf7, 0xae, 0xfb, 0xae, 0xfb, 0xbf, 0xea, 0xbf, 0x55, 0xb2, 0x25, 0x68, 0xb7, 0x28, 0xf3, 0x14, 0x29, 0xd2, 0x35}; -const uint8_t gif14[1024] = { +const uint8_t herbie14[1024] = { 0x00, 0x21, 0x54, 0x02, 0x79, 0x84, 0x2a, 0x50, 0x85, 0x40, 0x00, 0xa4, 0x00, 0x45, 0x08, 0x51, 0x80, 0x24, 0x01, 0xa0, 0x00, 0xd5, 0x2a, 0x14, 0x81, 0x24, 0x01, 0x52, 0x01, 0x0a, 0x05, 0x81, 0x50, 0x05, 0x00, 0xaa, 0x42, 0x15, 0x00, 0x5f, 0x82, 0x18, 0xb7, 0x08, 0xb5, 0x22, 0x5d, 0xa2, @@ -3168,7 +3168,7 @@ const uint8_t gif14[1024] = { 0x11, 0xa8, 0x42, 0x14, 0x41, 0xa8, 0x02, 0x29, 0x44, 0x9a, 0x65, 0xdb, 0xbe, 0xf7, 0xae, 0xfb, 0xad, 0xff, 0xaa, 0xff, 0xa6, 0x59, 0x24, 0xe9, 0x26, 0xe9, 0x34, 0xab, 0x40, 0x3c, 0xe3, 0x34}; -const uint8_t gif15[1024] = { +const uint8_t herbie15[1024] = { 0x80, 0x52, 0x04, 0xb1, 0x4a, 0x94, 0x21, 0x54, 0x81, 0x40, 0x00, 0x4a, 0x80, 0x22, 0x14, 0x40, 0x22, 0x88, 0x00, 0x41, 0x28, 0xc5, 0x2a, 0x11, 0x44, 0x02, 0xa9, 0x02, 0x03, 0x44, 0x03, 0x28, 0xc2, 0x01, 0x08, 0xa7, 0x48, 0x03, 0x14, 0xa6, 0x19, 0x46, 0x39, 0x84, 0x7b, 0x84, 0x00, 0x49, @@ -3234,7 +3234,7 @@ const uint8_t gif15[1024] = { 0x45, 0x90, 0x2a, 0x40, 0x15, 0xa0, 0x09, 0x52, 0x04, 0xe9, 0x16, 0xed, 0xbb, 0xef, 0xbb, 0xee, 0xbf, 0xea, 0xbf, 0xf5, 0x9f, 0x30, 0x65, 0xaa, 0x34, 0xd3, 0x2c, 0xb2, 0x45, 0x38, 0xd3, 0x34}; -const uint8_t gif16[1024] = { +const uint8_t herbie16[1024] = { 0x00, 0xa5, 0x12, 0xa8, 0x25, 0xca, 0x10, 0x25, 0xc0, 0x04, 0x00, 0x8a, 0x20, 0x05, 0x50, 0x84, 0x20, 0x84, 0x20, 0x81, 0xa4, 0x15, 0x62, 0x14, 0x81, 0x24, 0x01, 0x25, 0x02, 0x89, 0x06, 0x21, 0xc4, 0x01, 0x90, 0x0b, 0xd4, 0x01, 0x16, 0xc5, 0x2a, 0x92, 0x44, 0x1b, 0xb4, 0x5f, 0xf0, 0x5f, @@ -3300,7 +3300,7 @@ const uint8_t gif16[1024] = { 0x10, 0x45, 0xa8, 0x01, 0x54, 0x22, 0x88, 0x42, 0x09, 0x72, 0x85, 0x7a, 0xd7, 0xbe, 0xf7, 0xad, 0xff, 0xab, 0xfe, 0xb7, 0xed, 0x1b, 0x70, 0x95, 0x66, 0xb8, 0x13, 0xf4, 0x15, 0x20, 0xde, 0x31}; -const uint8_t gif17[1024] = { +const uint8_t herbie17[1024] = { 0x20, 0x08, 0x42, 0x29, 0x92, 0x64, 0x09, 0x54, 0xa1, 0x08, 0x40, 0x81, 0x08, 0xa2, 0x00, 0x2a, 0x40, 0x91, 0x04, 0x40, 0xa0, 0x02, 0xf5, 0x0a, 0x20, 0x95, 0x00, 0x45, 0x12, 0x00, 0x47, 0x00, 0x07, 0xf0, 0x01, 0x00, 0x2a, 0xd5, 0x00, 0x2a, 0x84, 0x49, 0x13, 0xa6, 0x07, 0xaa, 0x0d, 0x43, @@ -3366,7 +3366,7 @@ const uint8_t gif17[1024] = { 0x22, 0x54, 0x00, 0xaa, 0x50, 0x05, 0x50, 0x85, 0x10, 0x29, 0x44, 0x9b, 0x64, 0xdb, 0xbe, 0xf7, 0xad, 0xff, 0xab, 0xfd, 0xaf, 0xfa, 0x97, 0x38, 0x52, 0xa5, 0x3a, 0xd4, 0x33, 0x5c, 0x81, 0x3a}; -const uint8_t gif18[1024] = { +const uint8_t herbie18[1024] = { 0x00, 0xa0, 0x08, 0x42, 0x99, 0x22, 0x4c, 0x21, 0x4a, 0x94, 0x20, 0xc1, 0x10, 0x40, 0x09, 0xa0, 0x05, 0x28, 0x42, 0x10, 0x40, 0x24, 0x40, 0x30, 0xc7, 0x18, 0xa4, 0x01, 0x50, 0x05, 0x00, 0x51, 0x02, 0x01, 0xc2, 0xb8, 0x42, 0x90, 0x25, 0x80, 0x24, 0x11, 0x44, 0x00, 0x15, 0x40, 0x04, 0x11, diff --git a/inc/lis3dh_regs.h b/inc/lis3dh_regs.h deleted file mode 100644 index a31570dcca1848e418ec4fef3080df150483db9c..0000000000000000000000000000000000000000 --- a/inc/lis3dh_regs.h +++ /dev/null @@ -1,45 +0,0 @@ -#define LIS3DH_I2C_ADDRESS 0x18 << 1 -#define STATUS_REG_AUX 0x07 -#define OUT_ADC1_L 0x08 -#define OUT_ADC1_H 0x09 -#define OUT_ADC2_L 0x0A -#define OUT_ADC2_H 0x0B -#define OUT_ADC3_L 0x0C -#define OUT_ADC3_H 0x0D -#define WHO_AM_I 0x0F -#define CTRL_REG0 0x1E -#define TEMP_CFG_REG 0x1F -#define CTRL_REG1 0x20 -#define CTRL_REG2 0x21 -#define CTRL_REG3 0x22 -#define CTRL_REG4 0x23 -#define CTRL_REG5 0x24 -#define CTRL_REG6 0x25 -#define REFERENCE 0x26 -#define STATUS_REG 0x27 -#define OUT_X_L 0x28 -#define OUT_X_H 0x29 -#define OUT_Y_L 0x2A -#define OUT_Y_H 0x2B -#define OUT_Z_L 0x2C -#define OUT_Z_H 0x2D -#define FIFO_CTRL_REG 0x2E -#define FIFO_SRC_REG 0x2F -#define INT1_CFG 0x30 -#define INT1_SRC 0x31 -#define INT1_THS 0x32 -#define INT1_DURATION 0x33 -#define INT2_CFG 0x34 -#define INT2_SRC 0x35 -#define INT2_THS 0x36 -#define INT2_DURATION 0x37 -#define CLICK_CFG 0x38 -#define CLICK_SRC 0x39 -#define CLICK_THS 0x3A -#define TIME_LIMIT 0x3B -#define TIME_LATENCY 0x3C -#define TIME_WINDOW 0x3D -#define ACT_THS 0x3E -#define INACT_DUR 0x3F - - diff --git a/inc/sc7a20.h b/inc/sc7a20.h new file mode 100644 index 0000000000000000000000000000000000000000..bf58140d74f09b6f1db6549b5fe57137e6a4ba88 --- /dev/null +++ b/inc/sc7a20.h @@ -0,0 +1,36 @@ +#define SC7A20_I2C_ADDRESS 0x19 << 1 +#define SPI_CTRL 0x0E +#define WHO_AM_I 0x0F +#define CTRL_REG0 0x1F +#define CTRL_REG1 0x20 +#define CTRL_REG2 0x21 +#define CTRL_REG3 0x22 +#define CTRL_REG4 0x23 +#define CTRL_REG5 0x24 +#define CTRL_REG6 0x25 +#define DRDY_STATUS_REG 0x27 +#define OUT_X_L 0x28 +#define OUT_X_H 0x29 +#define OUT_Y_L 0x2A +#define OUT_Y_H 0x2B +#define OUT_Z_L 0x2C +#define OUT_Z_H 0x2D +#define FIFO_CTRL_REG 0x2E +#define FIFO_SRC_REG 0x2F +#define INT1_CFG 0x30 +#define INT1_SRC 0x31 +#define INT1_THS 0x32 +#define INT1_DURATION 0x33 +#define INT2_CFG 0x34 +#define INT2_SRC 0x35 +#define INT2_THS 0x36 +#define INT2_DURATION 0x37 +#define CLICK_CTRL_REG 0x38 +#define CLICK_SRC 0x39 +#define CLICK_COEFF1 0x3A +#define CLICK_COEFF2 0x3B +#define CLICK_COEFF3 0x3C +#define CLICK_COEFF4 0x3D +#define Soft_Reset 0x68 +#define FIFO_DATA 0x69 +#define I2C_CTRL 0x6F diff --git a/src/main.c b/src/main.c index f952c89541d0f3fbbf3bef7787e03f2b059daf2c..cfcd5fc6180c344fd2843d276b93b68ee6abb748 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ #include <py32f0xx_hal_gpio_ex.h> #include <py32f0xx_hal.h> #include "display.h" -#include <lis3dh_regs.h> +#include <sc7a20.h> #include <string.h> #define I2C_SPEEDCLOCK 400000 // Communication speed 400K @@ -22,12 +22,13 @@ volatile uint8_t standby = 0; // if device is on charger, but charging complete, volatile uint8_t lptim_ovf = 0; //0 if the lptimer has not overflowed (finished counting), 1 if so // ************** Prototypes ************** +void system_reset(void); void APP_ErrorHandler(void); -void ssd1306_bitmap(const uint8_t *bitmap); +void Put_Image(const uint8_t *bitmap); void Display_On(void); void ssd1306_clear(void); -void ssd1306_init(void); -void displayArray(const uint8_t **image, int repeat, int frames, int reverse, int delayTime); +void Display_Init(void); +void Put_GIF(const uint8_t **image, int repeat, int frames, int reverse, int delayTime); void SysTick_Handler(void); static void APP_SystemClockConfig(void); static void LPTIMInit(void); @@ -51,21 +52,31 @@ void Accel_Init(void); void EXTI_Init(void); void Stop_Mode_EXTI_Init(void); void EXTI4_15_IRQHandler(void); -void Display_UNL_Info(void); +void Put_UNL_Info(void); void Sleep(void); void ssd1306_rotate_180(void); // ************** End Prototypes ************** +void system_reset(void) { + //HAL_NVIC_SystemReset(); + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk); + while(1); +} + void APP_ErrorHandler(void) { - /* Infinite loop */ - while (1) - { - } + system_reset(); +} + +void I2C_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout){ + if (HAL_I2C_Master_Transmit(hi2c, DevAddress, pData, Size, Timeout) != HAL_OK){ + APP_ErrorHandler(); + } } -void ssd1306_bitmap(const uint8_t *bitmap){ +void Put_Image(const uint8_t *bitmap){ // This if block is used to overide the bitmap displayed if the device is charging + /* if (HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_0) == GPIO_PIN_SET && HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_1) == GPIO_PIN_SET){ // if device is off the charger, continue priting the regular bitmap charge = 0; @@ -82,54 +93,55 @@ void ssd1306_bitmap(const uint8_t *bitmap){ standby = 0; } } + */ transmit[0] = 0x40; memcpy(transmit + 1, bitmap, 1024); - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, bitmap1, 6, 5000); - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, bitmap2, 2, 5000); - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, transmit, 1025, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, bitmap1, 6, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, bitmap2, 2, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, transmit, 1025, 5000); } void Display_On(void){ - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, software_on, 2, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, software_on, 2, 5000); } void ssd1306_clear(void) { - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, bitmap1, 6, 5000); - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, bitmap2, 2, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, bitmap1, 6, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, bitmap2, 2, 5000); for(int i =0; i < 32; i++) { - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, clear, 33, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, clear, 33, 5000); } } -void ssd1306_init(void) +void Display_Init(void) { for(int i = 0; i < 12; i++) { - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, arr[i], init_len[i], 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, arr[i], init_len[i], 5000); } ssd1306_clear(); ssd1306_rotate_180(); - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, ram_mode, 2, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, ram_mode, 2, 5000); Display_On(); } -void displayArray(const uint8_t ** image, int repeat, int frames, int reverse, int delayTime) +void Put_GIF(const uint8_t ** image, int repeat, int frames, int reverse, int delayTime) { for(int i = 0; i < repeat; i++){ for(int j = 0; j < frames; j++){ - ssd1306_bitmap(image[j]); + Put_Image(image[j]); //HAL_Delay(delayTime); LPTIM_Delay(delayTime); } if(reverse > 0){ for(int j = 0; j < frames; j++){ - ssd1306_bitmap(image[frames-j]); + Put_Image(image[frames-j]); //HAL_Delay(delayTime); LPTIM_Delay(delayTime); } @@ -241,7 +253,7 @@ void GPIO_Charger_EXTI_Init(void){ GPIO_InitTypeDef GPIO_InitStruct = {0}; __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; // Open Drain for I2C + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; // Pull-up resistor GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; // High speed HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); @@ -308,6 +320,7 @@ void display_Power_Off(void){ } void I2C_Init(void) { + GPIO_I2C_Init(); hi2c1.Instance = I2C1; // Choose the appropriate I2C instance hi2c1.Init.ClockSpeed = I2C_SPEEDCLOCK; hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; // Duty cycle @@ -320,30 +333,36 @@ void I2C_Init(void) { uint8_t I2C_Scan(void) { uint8_t deviceFound = 0; - printf("Scanning I2C addresses...\n"); - for (uint8_t address = 1; address < 128; address++) { // I2C addresses 1 to 127 + //printf("Scanning I2C addresses...\n"); + //for (uint8_t address = 1; address < 128; address++) { // I2C addresses 1 to 127 + for (uint8_t address = 0x19; address <= 0x19; address++) { HAL_StatusTypeDef result = HAL_I2C_IsDeviceReady(&hi2c1, address << 1, 5, 10); // Shift address for 7-bit addressing if (result == HAL_OK) { - printf("Device found at address: 0x%02X\n", address); + //printf("Device found at address: 0x%02X\n", address); deviceFound++; } } + if (deviceFound == 1){ + Put_Image(dept); + LPTIM_Delay(3000); + } + if (deviceFound == 0) { - printf("No I2C devices found.\n"); + //printf("No I2C devices found.\n"); return 0; } return 1; } void Accel_WriteReg(uint8_t reg, uint8_t value){ - HAL_I2C_Mem_Write(&hi2c1, LIS3DH_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, &value, 1, HAL_MAX_DELAY); + HAL_I2C_Mem_Write(&hi2c1, SC7A20_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, &value, 1, HAL_MAX_DELAY); } uint8_t Accel_ReadReg(uint8_t reg){ uint8_t reg_value; - HAL_I2C_Mem_Read(&hi2c1, LIS3DH_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, ®_value, 1, HAL_MAX_DELAY); + HAL_I2C_Mem_Read(&hi2c1, SC7A20_I2C_ADDRESS, reg, I2C_MEMADD_SIZE_8BIT, ®_value, 1, HAL_MAX_DELAY); return reg_value; } @@ -362,23 +381,26 @@ void Toggle_LED(void){ } void Accel_Init(void){ - // Inits the accelerometer to send an interrupt signal on any axis movement. - HAL_Delay(10); - Accel_WriteReg(CTRL_REG1, 0x5F); // Turn on the sensor and enable X, Y, and Z, low power mode - HAL_Delay(15); - Accel_WriteReg(CTRL_REG2, 0x00); // High-pass filter disabled - Accel_WriteReg(CTRL_REG3, 0x40); // Interrupt activity 1 driven to INT1 pad - Accel_WriteReg(CTRL_REG4, 0x00); // FS = ±2 g - Accel_WriteReg(CTRL_REG5, 0x00); // Interrupt 1 pin not latched, sends pulse (bit 3) - Accel_WriteReg(INT1_THS, 0x10); // Threshold = 250 mg (0x10) - Accel_WriteReg(INT1_DURATION, 0x00); // Duration = 0 - //Accel_WriteReg(INT1_CFG, 0x3F); // Enable interupts on all axis (not working) - Accel_WriteReg(INT1_CFG, 0x0A); - //Accel_WriteReg(INT1_CFG, 0x7F); + // Inits the accelerometer to send an interrupt signal on any axis movement. + // First disable all output + Accel_WriteReg(CTRL_REG1, 0x00); // Disable all axes and power down + Accel_WriteReg(CTRL_REG2, 0x00); // Reset/clear any filters + Accel_WriteReg(CTRL_REG3, 0x00); // Disable interrupts during setup + Accel_WriteReg(CTRL_REG4, 0x00); // 2g range + Accel_WriteReg(CTRL_REG5, 0x00); + Accel_WriteReg(CTRL_REG6, 0x00); // Active low interrupt + // Set up interrupt configuration + Accel_WriteReg(INT1_THS, 0x33); + Accel_WriteReg(INT1_DURATION, 0x01); // Longer duration + Accel_WriteReg(INT1_CFG, 0x2A); // Only high interrupts on XYZ (2a) + // enable interrupts + Accel_WriteReg(CTRL_REG3, 0x40); // Enable INT1 + // enable output and set ODR + Accel_WriteReg(CTRL_REG1, 0x3F); // 25Hz, Low power, XYZ enabled + EXTI_Init(); } void EXTI_Init(void){ - /* Configure GPIO pin */ GPIO_InitTypeDef GPIO_InitStruct={0}; __HAL_RCC_GPIOA_CLK_ENABLE(); // Enable GPIOA clock GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; // GPIO mode set to falling edge interrupt @@ -408,62 +430,52 @@ void Stop_Mode_EXTI_Init(void){ // Handles the EXTI on PA5 void EXTI4_15_IRQHandler(void) { - //Toggle_LED(); __NOP(); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); } -void Display_UNL_Info(void){ - displayArray(gif, 4, 18, 0, 63); - ssd1306_bitmap(dept); - LPTIM_Delay(4000); - displayArray(flag, 2, 20, 0, 10); - displayArray(pointers, 2, 8, 1, 7); - ///ssd1306_bitmap((const uint8_t *)dept); - //LPTIM_Delay(4000); - //ssd1306_bitmap((const uint8_t *)apply_qr); - //LPTIM_Delay(5000); - //displayArray(gif, 4, 18, 0, 63); +void ssd1306_rotate_180(void){ + uint8_t rotate[] = {0x00,0xA1,0xC8}; + I2C_Transmit(&hi2c1, SSD1306_ADDR, rotate, 3, 5000); } void Sleep(void){ - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, software_off, 2, 5000); + I2C_Transmit(&hi2c1, SSD1306_ADDR, software_off, 2, 5000); display_Power_Off(); HAL_SuspendTick(); - /// Enter STOP mode + // Enter STOP mode HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // After waking up HAL_ResumeTick(); APP_SystemClockConfig(); // Must reconfig the clock after waking up display_Power_On(); - ssd1306_init(); + Display_Init(); } -void ssd1306_rotate_180(void){ - uint8_t rotate[] = {0x00,0xA1,0xC8}; - HAL_I2C_Master_Transmit(&hi2c1, SSD1306_ADDR, rotate, 3, 5000); +void Put_UNL_Info(void){ + Put_GIF(herbie, 4, 18, 0, 63); + Put_Image(dept); + LPTIM_Delay(4000); + Put_GIF(flag, 2, 20, 0, 10); + Put_GIF(gbr, 2, 8, 1, 7); } - int main (void) { - // Add check for charging after deivce died (interrupt missed) HAL_Init(); APP_SystemClockConfig(); LPTIMInit(); - display_Switch_Init(); // for new hw version + display_Switch_Init(); display_Power_On(); - GPIO_Charger_EXTI_Init(); - GPIO_I2C_Init(); + //GPIO_Charger_EXTI_Init(); I2C_Init(); Accel_Init(); - EXTI_Init(); - //LED_Init(); - ssd1306_init(); + Display_Init(); while (1) { - Display_UNL_Info(); + Put_UNL_Info(); // Add more frames here + Sleep(); }