Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
d1b04bca
Commit
d1b04bca
authored
Aug 20, 2019
by
Martin Ling
Committed by
Rahix
Aug 20, 2019
Browse files
feat(trng): Add TRNG read to Epicardium API
parent
6c2d7e47
Changes
5
Hide whitespace changes
Inline
Side-by-side
epicardium/ble/ble.c
View file @
d1b04bca
...
...
@@ -8,7 +8,6 @@
#include
"ble_api.h"
#include
"hci_vs.h"
#include
"att_api.h"
#include
"trng.h"
#include
"FreeRTOS.h"
#include
"timers.h"
...
...
@@ -101,7 +100,7 @@ static void setAddress(void)
bdAddr
[
0
]
=
0xCA
;
bdAddr
[
1
]
=
0x4D
;
bdAddr
[
2
]
=
0x10
;
TRNG_Read
(
MXC_TRNG
,
bdAddr
+
3
,
3
);
epic_trng_read
(
bdAddr
+
3
,
3
);
sprintf
(
buf
,
"%02x:%02x:%02x:%02x:%02x:%02x
\n
"
,
bdAddr
[
0
],
...
...
epicardium/epicardium.h
View file @
d1b04bca
...
...
@@ -98,6 +98,9 @@ typedef _Bool bool;
#define API_GPIO_GET_PIN_MODE 0xA1
#define API_GPIO_WRITE_PIN 0xA2
#define API_GPIO_READ_PIN 0xA3
#define API_TRNG_READ 0xB0
/* clang-format on */
typedef
uint32_t
api_int_id_t
;
...
...
@@ -1209,4 +1212,21 @@ API(API_RTC_SCHEDULE_ALARM, int epic_rtc_schedule_alarm(uint32_t timestamp));
*/
API_ISR
(
EPIC_INT_RTC_ALARM
,
epic_isr_rtc_alarm
);
/**
* TRNG
* ====
*/
/**
* Read random bytes from the TRNG.
*
* :param uint8_t * dest: Destination buffer
* :param size: Number of bytes to read.
* :return: `0` on success or a negative value if an error occured. Possible
* errors:
*
* - ``-EFAULT``: Invalid destination address.
*/
API
(
API_TRNG_READ
,
int
epic_trng_read
(
uint8_t
*
dest
,
size_t
size
));
#endif
/* _EPICARDIUM_H */
epicardium/modules/hardware.c
View file @
d1b04bca
...
...
@@ -18,6 +18,7 @@
#include
"gpio.h"
#include
"i2c.h"
#include
"spi.h"
#include
"trng.h"
/*
* Early init is called at the very beginning and is meant for modules which
...
...
epicardium/modules/meson.build
View file @
d1b04bca
...
...
@@ -13,5 +13,6 @@ module_sources = files(
'rtc.c',
'serial.c',
'stream.c',
'trng.c',
'vibra.c',
)
epicardium/modules/trng.c
0 → 100644
View file @
d1b04bca
#include
"epicardium.h"
#include
"trng.h"
int
epic_trng_read
(
uint8_t
*
dest
,
size_t
size
)
{
if
(
dest
==
NULL
)
return
-
EFAULT
;
TRNG_Read
(
MXC_TRNG
,
dest
,
size
);
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment