Skip to content

Commit

Permalink
Add interfaces for crypt and rtc. Streamlinging on uart.
Browse files Browse the repository at this point in the history
  • Loading branch information
chintal committed Oct 11, 2024
1 parent 8604d49 commit 0594604
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .piopm
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type": "library", "name": "ebs-hal-uc", "version": "0.1.3", "spec": {"owner": "chintal", "id": 17231, "name": "ebs-hal-uc", "requirements": null, "uri": null}}
{"type": "library", "name": "ebs-hal-uc", "version": "9.9.9", "spec": {"owner": "chintal", "id": 17231, "name": "ebs-hal-uc", "requirements": null, "uri": null}}
9 changes: 7 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ebs-hal-uc",
"version": "0.2.1",
"version": "0.2.2",
"description": "uC HAL interface for EBS Projects",
"keywords": "ebs",
"repository": {
Expand All @@ -26,6 +26,11 @@
"name": "ebs-ds",
"version": "^0.2.0"
},
{
"owner": "chintal",
"name": "ebs-time",
"version": "^0.3.0"
},
{
"owner": "chintal",
"name": "ebs-hal-uc-avr",
Expand All @@ -35,7 +40,7 @@
{
"owner": "chintal",
"name": "ebs-hal-uc-stm32",
"version": "^0.1.1",
"version": "^0.1.2",
"platforms": ["ststm32"]
}
]
Expand Down
1 change: 1 addition & 0 deletions src/hal/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "constants/all.h"
5 changes: 5 additions & 0 deletions src/hal/constants/all.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#include "common.h"
#include "crypto.h"
#include "rtc.h"
#include "uart.h"
14 changes: 14 additions & 0 deletions src/hal/constants/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


#ifndef HAL_CONSTANTS_COMMON_H
#define HAL_CONSTANTS_COMMON_H

#define EBS_FALSE 0
#define EBS_TRUE 1

typedef enum {
_EBS_FALSE = EBS_FALSE,
_EBS_TRUE = EBS_TRUE
} EBS_BOOL_t;

#endif
57 changes: 57 additions & 0 deletions src/hal/constants/crypto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

#ifndef HAL_CONSTANTS_CRYPTO_H
#define HAL_CONSTANTS_CRYPTO_H

typedef enum{
CRYPTO_HW_NEVER,
CRYPTO_HW_IFAVAIL,
CRYPTO_HW_ALWAYS
} CRYPTO_HARDWARE_t;

typedef enum{
CRYPTO_AES_ECB,
CRYPTO_AES_CBC,
CRYPTO_AES_CTR,
CRYPTO_AES_GCM,
CRYPTO_AES_GMAC,
CRYPTO_AES_CCM,
} CRYPTO_ALG_t;

typedef enum{
CRYPTO_PREINIT,
CRYPTO_IDLE,
CRYPTO_READY,
CRYPTO_BUSY
} CRYPTO_ST_t;

// Swap operations to deal with endianness differences.
typedef enum{
CRYPTO_SWAP_1B,
CRYPTO_SWAP_8B,
CRYPTO_SWAP_16B,
CRYPTO_SWAP_NONE
} CRYPTO_SWAP_t;

typedef enum{
CRYPTO_CTX_MODE_IDLE,
CRYPTO_CTX_MODE_ENCRYPTION,
CRYPTO_CTX_MODE_DECRYPTION,
CRYPTO_CTX_MODE_SUSPENDED,
} CRYPTO_CTX_MODE_t;

typedef enum{
CRYPTO_CTX_PHASE_INIT,
CRYPTO_CTX_PHASE_PREPKEY,
CRYPTO_CTX_PHASE_DERIVATION,
CRYPTO_CTX_PHASE_HEADER,
CRYPTO_CTX_PHASE_PAYLOAD,
CRYPTO_CTX_PHASE_FINAL
} CRYPTO_CTX_PHASE_t;

typedef enum{
CRYPTO_TR_PENDING,
CRYPTO_TR_INPROGRESS,
CRYPTO_TR_DONE
} CRYPTO_TR_STATE_t;

#endif
13 changes: 13 additions & 0 deletions src/hal/constants/rtc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#ifndef HAL_CONSTANTS_RTC_H
#define HAL_CONSTANTS_RTC_H

typedef enum{
RTC_ST_PREINIT,
RTC_ST_IDLE,
RTC_ST_WAIT_READ,
RTC_ST_WAIT_WRITE,
RTC_ST_SYNC
} RTC_ST_t;

#endif
5 changes: 5 additions & 0 deletions src/hal/constants/uart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#ifndef HAL_CONSTANTS_UART_H
#define HAL_CONSTANTS_UART_H

#endif
4 changes: 3 additions & 1 deletion src/hal/types/all.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


#include "crypto.h"
#include "crypto.h"
#include "rtc.h"
#include "uart.h"
54 changes: 1 addition & 53 deletions src/hal/types/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,7 @@
#define HAL_TYPES_CRYPTO_H

#include <stdint.h>


typedef enum{
CRYPTO_HW_NEVER,
CRYPTO_HW_IFAVAIL,
CRYPTO_HW_ALWAYS
} CRYPTO_HARDWARE_t;

typedef enum{
CRYPTO_AES_ECB,
CRYPTO_AES_CBC,
CRYPTO_AES_CTR,
CRYPTO_AES_GCM,
CRYPTO_AES_GMAC,
CRYPTO_AES_CCM,
} CRYPTO_ALG_t;

typedef enum{
CRYPTO_PREINIT,
CRYPTO_IDLE,
CRYPTO_READY,
CRYPTO_BUSY
} CRYPTO_ST_t;

// Swap operations to deal with endianness differences.
typedef enum{
CRYPTO_SWAP_1B,
CRYPTO_SWAP_8B,
CRYPTO_SWAP_16B,
CRYPTO_SWAP_NONE
} CRYPTO_SWAP_t;

typedef enum{
CRYPTO_CTX_MODE_IDLE,
CRYPTO_CTX_MODE_ENCRYPTION,
CRYPTO_CTX_MODE_DECRYPTION,
CRYPTO_CTX_MODE_SUSPENDED,
} CRYPTO_CTX_MODE_t;

typedef enum{
CRYPTO_CTX_PHASE_INIT,
CRYPTO_CTX_PHASE_PREPKEY,
CRYPTO_CTX_PHASE_DERIVATION,
CRYPTO_CTX_PHASE_HEADER,
CRYPTO_CTX_PHASE_PAYLOAD,
CRYPTO_CTX_PHASE_FINAL
} CRYPTO_CTX_PHASE_t;

typedef enum{
CRYPTO_TR_PENDING,
CRYPTO_TR_INPROGRESS,
CRYPTO_TR_DONE
} CRYPTO_TR_STATE_t;
#include <hal/constants/crypto.h>

typedef struct CRYPTO_PROFILE_t{
const CRYPTO_ALG_t alg;
Expand Down
16 changes: 16 additions & 0 deletions src/hal/types/rtc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


#ifndef HAL_TYPES_RTC_H
#define HAL_TYPES_RTC_H

#include <stdint.h>
#include <hal/constants/rtc.h>
#include <time/time.h>

typedef struct RTC_STATE_t {
RTC_ST_t state;
tm_real_t * iobuffer;
void (*cb)(void);
}rtc_state_t;

#endif
8 changes: 8 additions & 0 deletions src/hal/types/uart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


#ifndef HAL_TYPES_UART_H
#define HAL_TYPES_UART_H

#include <platform/types.h>

#endif
3 changes: 2 additions & 1 deletion src/hal/uc/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#include "uart.h"
#include "spi.h"
#include "usb.h"
#include "usbcdc.h"
#include "usbcdc.h"
#include "rtc.h"

#endif
Loading

0 comments on commit 0594604

Please sign in to comment.