12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "ch.h"
- #include "hal.h"
- #include "chprintf.h"
- #include "portab.h"
- static THD_WORKING_AREA(waThread1, 128);
- static THD_FUNCTION(Thread1, arg) {
- (void)arg;
- chRegSetThreadName("blinker");
- while (true) {
- palToggleLine(PORTAB_LINE_LED1);
- chThdSleepMilliseconds(500);
- palToggleLine(PORTAB_LINE_LED1);
- chThdSleepMilliseconds(500);
- }
- }
- int main(void) {
-
- halInit();
- chSysInit();
-
- portab_setup();
-
- sdStart(&PORTAB_SD1, NULL);
-
- cryStart(&CRYD1, NULL);
-
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- while (true) {
- uint8_t digest[32];
- if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
- SHA256Context ctx256;
- crySHA256Init(&CRYD1, &ctx256);
- crySHA256Update(&CRYD1, &ctx256, 0U, (const uint8_t *)"");
- crySHA256Final(&CRYD1, &ctx256, digest);
- crySHA256Init(&CRYD1, &ctx256);
- crySHA256Update(&CRYD1, &ctx256, 3U, (const uint8_t *)"abc");
- crySHA256Final(&CRYD1, &ctx256, digest);
- crySHA256Init(&CRYD1, &ctx256);
- crySHA256Update(&CRYD1, &ctx256, 56U, (const uint8_t *)"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
- crySHA256Final(&CRYD1, &ctx256, digest);
- }
- chThdSleepMilliseconds(500);
- }
- return 0;
- }
|