Skip to content

Commit 5dc0138

Browse files
committed
Adjust atmega measurement structure to the others
This adjusts the folder structure in the measurement examples to include an atmega subfolder, just as we have an nRF and ESP subfolder. It also splits the GPIO implementations in the respective microcontroller parts. Furthermore, this implements the noop for the atmega HW crypto.
1 parent 6ed1cf4 commit 5dc0138

File tree

15 files changed

+96
-76
lines changed

15 files changed

+96
-76
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ target_link_libraries(nfc_simulator ${PRODUCT_NAME})
1313
#######################################
1414
# Test applications
1515

16-
add_subdirectory(measurements)
16+
add_subdirectory(measurements/atmega)

examples/measurements/CMakeLists.txt renamed to examples/measurements/atmega/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
include(../../cmake/linker-map.cmake)
1+
include(../../../cmake/linker-map.cmake)
22

33
function(add_measurement name)
4-
add_executable(${name} "common/${name}.c" common/gpio.c)
5-
target_include_directories(${name} PRIVATE common/)
4+
add_executable(${name} "common/${name}.c" gpio.c hw_crypto.c)
5+
target_include_directories(${name} PRIVATE common/ .)
66
add_linker_map_for_target(${name})
77
target_link_libraries(${name} ${PRODUCT_NAME})
88
endfunction()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../common
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2022 Felix Gohla, Konrad Hanff, Tobias Kantusch,
3+
* Quentin Kuth, Felix Roth. All rights reserved.
4+
*
5+
* Use of this source code is governed by a BSD-style
6+
* license that can be found in the LICENSE file.
7+
*/
8+
9+
#include <avr/io.h>
10+
#include <util/delay.h>
11+
12+
#define PIN PB5
13+
14+
void setup_pin() {
15+
DDRB |= _BV(PIN);
16+
}
17+
18+
void pin_on() {
19+
PORTB |= _BV(PIN);
20+
}
21+
22+
void pin_off() {
23+
PORTB &= ~_BV(PIN);
24+
}
25+
26+
void delay(double ms) {
27+
for (double i = 0; i < ms; i++) {
28+
_delay_ms(1);
29+
}
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (c) 2022 Felix Gohla, Konrad Hanff, Tobias Kantusch,
3+
* Quentin Kuth, Felix Roth. All rights reserved.
4+
*
5+
* Use of this source code is governed by a BSD-style
6+
* license that can be found in the LICENSE file.
7+
*/
8+
9+
int init_hw_crypto() {
10+
return 0;
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2022 Felix Gohla, Konrad Hanff, Tobias Kantusch,
3+
* Quentin Kuth, Felix Roth. All rights reserved.
4+
*
5+
* Use of this source code is governed by a BSD-style
6+
* license that can be found in the LICENSE file.
7+
*/
8+
9+
/**
10+
* @brief Initialize cryptography module (if hardware cryptography is enabled).
11+
*
12+
* @return int 0 on success.
13+
*/
14+
int init_hw_crypto();

examples/measurements/common/aes_gcm_measure.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ int main(void) {
3333

3434
uint8_t plain[576] = {0};
3535

36-
#ifdef CONFIG_USE_HW_CRYPTO
3736
init_hw_crypto();
38-
#endif
3937

4038
setup_pin();
4139
pin_off();

examples/measurements/common/ed25519_measure.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "fido.h"
1010
#include "gpio.h"
11+
#include "hw_crypto.h"
1112

1213
#include <stdio.h>
1314
#include <string.h>
@@ -31,9 +32,7 @@ int main(void) {
3132
// Wait until the microcontroller booted up to remove increased power consumption in the measurements at the beginning.
3233
delay(3000);
3334

34-
#ifdef CONFIG_USE_HW_CRYPTO
3535
init_hw_crypto();
36-
#endif
3736

3837
setup_pin();
3938
pin_off();

examples/measurements/common/gpio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* license that can be found in the LICENSE file.
77
*/
88

9+
#pragma once
10+
911
/**
1012
* @brief Setup the logical PPK2 output pin.
1113
*/

examples/measurements/common/sha256_measure.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ int main(void) {
3030

3131
uint8_t hash[32] = {0};
3232

33-
#ifdef CONFIG_USE_HW_CRYPTO
3433
init_hw_crypto();
35-
#endif
3634

3735
setup_pin();
3836
pin_off();

0 commit comments

Comments
 (0)