In this blog, I will explain how a owner or a senior management can connect and know all the setup of his/her factory on AWS IoT Cloud.
I will use 'The Infineon IFW956810 AIROC Cloud Connectivity Manager Eval Kit', the same one which I have used this in the Road Test - Evaluating The Infineon AIROC Cloud Connectivity Manager. For more details, what Infineon AIROC IFW956810 is, pls go through my Road Test but here as part of challenge and the audience who is going to look for solution through this blog, I will mention some of the things which I have explained in the Road Test.
You can use any other competitive products like USB-NORA-W256AWS, NORA-W256AWS,NORA-W251AWS,AWS IoT ExpressLink SARA-R5 Starter Kit V2,Bravo LE910C1-WWXD with AWS IoT ExpressLink,ESP32-C3 AWS IoT ExpressLink Module,Telit LE910C1-WWXD AWS IoT ExpressLink,Realtek Ameba Z2 AWS IoT ExpressLink,SARA-R5 AWS IoT ExpressLink Module.
Note : The content of this blog is similar to my RoadTest but as it is Road Test, everything must be there as it is a product review.
1. Basics
1. What is AWS IoT Cloud ?
AWS is Amazon Web Services,
2. What is Infineon AIROC IFW956810 ?
It is like a USB dongle, and a Wi-Fi networking system for connecting IoT products to AWS IoT ExpressLink with in-built security features. In general or it might now have become past, such connectivies required software programming, extensive firmware development, testing and maintenance. But with these competitive products, it is now only a plug and a play thing.
It should be noticed that this Infineon AIROC IFW956810 has its own 32-bit PSOC 64 line asymmetric dual-core Arm® Cortex®-M4 and Arm Cortex-M0+ micro-processors with integrated printed antenna.
3. Can you connect to AWS without this Infineon AIROC IFW956810 ?
No, you cannot connect to AWS Cloud without Infineon AIROC IFW956810. You will need anyone of the AWS compliant which I have mentioned in the Road Test.
4. How will I use Infineon AIROC IFW956810 with Microchip SAM E51 Curiosity Nano Evaluation Kit
Though Microchip SAM E51 Curiosity Nano Evaluation Kit has some of the features which can be used, but I will use following features from Infineon AIROC IFW956810,
- Cloud Management Features, AWS IoT compliant
- Networking Features
- Wireless Connectivity Features
- On-Board Security Features
All the four features would be used and extremely important to provide secure business while being on AWS Cloud.
The Cloud Management feature will allow Microchip SAM E51 and the clickboards, other sensors displays etc over to the Cloud, as it is AWS compliant and powered by AWS IoT ExpressLink.
The networking features like TCP/IP, TLS, DNS, HTTP, and MQTT are available.
The wireless connectivity features like IEEE 802.11b/g/n,Wi Fi 4,2.4-GHz band with different modulation techniques like DSSS (Direct Sequence Spread Spectrum), DBPSK(Differential Binary Phase Shift Keying), DQPSK(Differential Quadrature Phase Shift Keying), CCK(Complementary Code Keying), OFDM (Orthogonal Frequency Division Multiplexing), BPSK (Binary Phase Shift Keying), QPSK (Quadrature Phase Shift Keying),16-QAM (16-Quadrature Amplitude Modulation), 64-QAM (64-Quadrature Amplitude Modulation), are on the board.
The On-Board security features like WPA/WPA2 (Personal), WPA3, AES and TKIP acceleration hardware, Cisco compatible extension, TLS 1.2, Arm® Platform Security Architecture (PSA) Level 2 certified, CIRRENT Cloud ID, Wi-Fi Protected Setup (WPS) , WEP (Wired Equivalent Privacy), WMM (Wireless Multimedia Extensions), WMM-SA, CKIP.
2. Block Diagram,Hardware SetUp and Circuit Diagram
2.1 Circuits Diagram
Below is different connections gallery
{gallery}connections gallayaw |
---|
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
2.2 Pin Choices on Jumper of Header J61
There is jumper on J61, where by default the jumper settings connect pin 1 to pin 2, that is pins VDD_33 and VBACKUP are connected. You can connect to pin 2 and pin 3 as I have shown in Roadtest but you should use 3.3 V for J61 only as the J60 need 3.3 V, and this 3.3 VDC I have taken from AVNET's Ultra96V2G along with 'click Megazzine click 2'.
a) Pin 1 and Pin 2 on J61
b) Original Infineon AIROC on delivery
c) Bare Pins ; Jumpers from J61 and J60 removed
d) Below two jumpers which will be used
e) Jumper on J61 , note all the jumpers from J60 must be removed
f) Lets see what pins on J60 are and which pin row will be used. J60 has 2 pin in 1 row.
So, in this experiment, I will use one side with golden/yellow of odd pin numbers in connection with Micrpchip SAM E51.
2.3 Configuration : 2-wire + 2 wire 3.3VDC supply
2.4 Configuration : 3-wire + 2 wire 3.3VDC supply
2.5 Configuration : 4-wire + 2 wire 3.3VDC supply
2.6 Configuration : 5-wire + 2 wire 3.3VDC supply
3. Programming of Infineon AIROC IFW956810
As I will use the Wi-Fi module of AIROC IFW956810, and the USB cable would be disconnected from PC/Laptop, the Infineon will be programmed with Wi-Fi username and password.
After the registration on Infineon of AIROC IFW956810 and programming with Wi-Fi password, the Microchip's SAM E51 can use the Infineon AIROC IFW956810 AWS compliant capability to connect to AWS Console.
From the Road Test, Section IV- the Registration of Kit & Connection Settings, and Section V- AWS Free Tier, is used for this.
3.1 Registration of Kit & Connection Settings
Step 1 Product Registration
1) Firstly, the kit has to be registered on Infineon Developer Center, www.infineon.com, with the unique ID (which I have masked in white).
The complete URL printed in Fig.1 will be different than the URL printed on anyone's evaluation board as it is unique module ID. Also, this URL (in Fig.1) is same as mentioned in the printed 'Quick start guide', which comes with the module.
However the online version with new datasheet and overview (also online) has other URLs mentioned instead of https://ifxcloud.io/<unique_module_id> . There are 4 different URL versions and all work.
- URL 1 : https://ifxcloud.io/<unique_module_id> .
- URL 2 : https://qr.infineon.io/<unique_module_id>
- URL 3 : https://softwaretools.infineon.com/projects/create/details
- URL 4 : www.infineon.com
Note :
a) The module identifier is case-sensitive
b) If the https://qr.infineon.io/ is seeked without unique module ID, the screen prompts message -{"message":"Missing Authentication Token"}
c) Similarly, if the https://ifxcloud.io/ is seeked without unique module ID, the screen prompts message -{"message":"Missing Authentication Token"}
2) Now, lets see what the URLs displays page
1) URL 3 : https://softwaretools.infineon.com/projects/create/details
2) URL 4 : www.infineon.com
3) URL 2 : https://qr.infineon.io/<unique_module_id>
The device id is masked
{gallery}Registration |
---|
Note : In case the complete registration is not showing up, check email and click on "Go To Your Project Space"
(This problem I faced and resolved after wasting 30 min, after clicking on "Go To Your Project Space" , link of the email.)
Step 2 Set up AWS Account
{gallery}AWS |
---|
Step 3 Connect the kit to the PC & Setting up Serial Terminal
Ubuntu
1) The user manual has given settings for Windows but I will try for Ubuntu and GTKTerm. GTKTerm is a simple GTK+ terminal used to communicate with the serial port. It can be installed from https://github.com/Jeija/gtkterm .
Ubuntu Specifications Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy Kernel : 6.2.0-36-generic x86_64 x86_64 x86_64 GNU/Linux GTKTerm version : 1.1.1
2) As soon as the Infineon AIROC is connected using USB, there is blue light which flashes momemtarily
3) Now type lsusb in the terminal.
Here, instead of the COM port number, here in Ubuntu, the port is /dev/tty/USB1. Now do serial terminal settings in GTKTerm
Port : /dev/tty/USB1 Speed: 115200 − Data: 8 bit − Parity: none − Stop bits: 1 bit − Flow control: none
{gallery} Serial Terminal, USB |
---|
Step 4 Login, Manage AWS account
AWS Management or IOT Console
{gallery}AWS Management Console |
---|
Step 5 Change Region
You will need to change location as per your region. As I m from India, I changed code from eu-north-1 to ap-south-1, which is for Asia Pacific (Mumbai). Following are other regions
{gallery}Regions |
---|
Step 6 Create the policy
1) Now open http://console.aws.amazon.com/iot
2) From the left pane, under Manage, select Security, and then select policies. Click Create to create a policy.
3) Enter the policy name - “TestPolicy”
4) Click JSON under policy statements tab , which is in 'Policy document tab'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
Here, if the version is changed to latest date of 2024 instead of "Version": "2012-10-17", it gives error.
{gallery}Policy |
---|
Step 7 Configure AWS Thing
1) Now open http://console.aws.amazon.com/iot
2) From the left pane, under Manage, select All devices, and then select Things.
3) Click Create Things.
4) On the Create things page, select Create single thing, and then click Next.
5) Now come back to computer and open GTKTerm. After connecting the kit using GTKTerm, type " AT+CONF? ThingName"
Note : here the "ThingName" is not setted yet (I will soon name on AWS IoT Console as TestThing in the coming steps). Here you have to type word ThingName only.
6) On typing " AT+CONF? ThingName", a string (a sequence of alphanumeric characters) is returned from the terminal. Copy this returned string.
7) Now come to AWS Thing , point 4 http://console.aws.amazon.com/iot . The returned string (a sequence of alphanumeric characters) of the previous point will be the "ThingName".
So, paste this returned string of point 6 into Thing name field under Thing properties of the AWS Thing.
8) Leave other fields at their default values, and then click Next.
9) After entering the "string" and after clicking on Next, "Configure device certificate - optional" , window appears. Though it's optional but you will have to "Configure device certificate".
10) To configure Device certificate, four options are given but instead auto generate, we will upload certificate.
- Auto-generate a new certificate (recommended)
- Use my certificate
- Upload CSR
- Skip creating a certificate at this time
11) Before uploading certificate, we will have to retrieve from the kit and prepare certificate. Now, again come back to computer and open GTKTerm. After connecting the kit using GTKTerm, type " AT+CONF? Certificate pem"
12) This " AT+CONF? Certificate pem" will return certificate on the terminal, and is a longer sequence of alphanumeric symbols, as shown in gallery. Copy the entire certificate from "Begin Certificate - End certificate" and paste it into a text file.
13) Save this certificate file as “ThingName.cert.pem”. Copy the "ThingName" from point 6.
14) It automatically creates certicates with fields
Subject Name
C (Country): DE
ST (State): Bavaria
L (Locality): Neubiberg
O (Organization): Infineon Technologies AG
OU (Organizational Unit): CCM
CN (Common Name):
Issuer Name
C (Country): DE
ST (State): Bavaria
L (Locality): Neubiberg
O (Organization): Infineon Technologies AG
OU (Organizational Unit): CCM
CN (Common Name): AIROC(TM) IFW56810 Intermediate CA
Issued Certificate
Version:
Serial Number:
Not Valid Before: 2022-07-12
Not Valid After: 2042-07-07
Certificate Fingerprints
SHA1:
MD5:
Public Key Info
Key Algorithm: Elliptic Curve
Key Parameters:
Key Size: 256
Key SHA1 Fingerprint:
Public Key:
Subject Key Identifier
Key Identifier:
Critical: No
Extension
Identifier:
Value:
Critical: No
Basic Constraints
Certificate Authority: No
Max Path Length: Unlimited
Critical: No
Extension
Identifier:
Value:
Critical: No
Signature
Signature Algorithm:
Signature:
15) Now come to point 9, "Configure device certificate - optional", window .
16) Select Use my certificate, and then choose CA is not registered with AWS IoT.
17) Under Certificate, select Choose file. Upload this ThingName.cert.pem file created
18) Under Certificate Status, select Active. Then click Next.
19) Now, window "Attach policies to certificate - optional" appears.
20) Select the Policy created in "Step 6 Create the policy" with name “TestPolicy”
21) Click "Create thing".
22) Now, window appears
You successfully created thing Inineon_...
You successfully created certificate ..........
{gallery}Things |
---|
Step 8 Configure Endpoint
1) Now open http://console.aws.amazon.com/iot
2) From the left pane, below Manage, select Settings, and then select Settings.
3) Copy your account endpoint string under "Device data endpoint".
4) Now come back to computer and open GTKTerm. After connecting the kit using GTKTerm, type " AT+CONF Endpoint= copied endpoint string under Device data endpoint", that is
type " AT+CONF Endpoint= ............iot.ap-south-1.amazonaws.com" (Complete endpoint string under Device data endpoint)
5) The previous step replaces the configured default endpoint.
{gallery}Configure Endpoint |
---|
Step 9 Connect the kit to Wi-Fi
Now, the kit has to be connected to WiFi. As this kit has no user interface to click to select Wi-Fi connection, again GTKTerm will used to set the Wi-Fisettings with password. This will be accomplished like earlier, and typing following commands
- AT+CONF SSID=<your router or Wifi ssid>
- AT+CONF Passphrase=<your router or Wifi passphrase>
Here, SSID is simple word is the name of your Wi-Fi Connection,
and Passphrase is simply the password
Thus, type in GTKTerm terminal
AT+CONF SSID= Abhishek
AT+CONF Passphrase=Abhishek
Note : For debugging purposes, the SSID or Wifi name can be retrieved but one can feel relieved as the password or passphrase cannot be retrieved. If one tried to hack password or retrieve password, kit will return an error.
One can check whether the kit is successfully connected or not by using ping command
ping endpoint This endpoint is same as of Step 8 Configure endpoint, that is,
............iot.ap-south-1.amazonaws.com" (Complete endpoint string under Device data endpoint)
ping ............iot.ap-south-1.amazonaws.com
Step 10 Connect Device
1) Now open http://console.aws.amazon.com/iot
2) From the left pane, under Connect, there is "Connect one device".
3) Similarly, on the right side, under "Get started with AWS IoT", there is "Connect device".
4) Both point 2 and 3 directs to same page as shown in gallery.
7) You can see its showing "connected".
8) I disconnected it and is shown in gallery.
9) I reconnected
{gallery}Connect Device |
---|
3.2. AWS Free Tier
3.2.1 Three Types of Offers
AWS provides three types of offers in Free Tier :
- 12 Months Free
- Always Free
- Trials
3.2.2 AWS Free Tier Categories
AWS categorizes these free tiers as following product categories
- Analytics
- Application Integration
- Business Productivity
- Compute
- Containers
- Customer Engagement
- Database
- Developer tools
- End User Computing
- Front-End Web & Mobile
- Game Tech
- Internet of Things
- Machine Learning
- Management & Governance
- Media Services
- Migration & Transfer
- Networking & Content Delivery
- Robotics
- Security, Identity, & Compliance
- Serverless
- Storage
More details on these free services can be seen at https://aws.amazon.com/free/
3.2.3 AWS IoT Services Pricing
As I will use AWS IoT,so I am mentioning free tier limits after which cost will apply. Following is copy and paste from https://aws.amazon.com/iot-core/pricing/
AWS Free Tier is available to AWS IoT Core customers for 12 months starting with the date you create your AWS account. When your free usage expires or if your application use exceeds the free usage tiers as outlined below, you pay the AWS IoT Core pricing rates.
- 2,250,000 minutes of connection
- 500,000 messages
- 225,000 Registry or Device Shadow operations
- 250,000 rules triggered and 250,000 actions applied
For example, the AWS Free Tier would help you run a 50-device workload, where each device:
- Connects for 24 hours a day
- Exchanges 300 messages per day (message size 5 KB or smaller)
- Makes 130 registry or Device Shadow operations per day (registry or Device Shadow record size 1 KB or smaller)
- Initiates 150 rule executions per day that invoke one action (processed message size 5 KB or smaller)
The free usage tier applies across all AWS Regions except the AWS GovCloud (US) Region. Your usage is calculated each month across all Regions and is automatically applied to your bill. Free usage does not accumulate from one billing period to the next.
a) Connectivity pricing: $0.092 (per million minutes of connection)
b) MQTT and HTTP messaging pricing
- Up to 1 billion messages: $1.05 (per million messages)
- Next 4 billion messages: $0.84 (per million messages)
- Over 5 billion messages: $0.74 (per million messages)
c) Device Shadow and Registry pricing: $1.31 (per million operations)
- Rules initiated: $0.158 (per million rules triggered / per million actions applied)
- Actions applied: $0.158 (per million rules triggered / per million actions applied)
B) Following services are not available for all regions, including Asia Pacific (Mumbai), ap-south-1
- LoRaWAN messaging pricing
- Sidewalk messaging pricing
- LoRaWAN FUOTA pricing
- AWS IoT Core for LoRaWAN Public Network Support
- Device Shadow and registry
- Device Location,Location Solvers pricing
More can be looked here : https://aws.amazon.com/iot-core/pricing/
C) You can also calculate using AWS Cost calculator
4. Setup on AWS Console
Once the settings done as in the previous section, I will login to AWS IoT Console, and Create Things and Application
4.1 Create thing gallery
{gallery} Create thing gallery |
---|
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
4.2 Policy
In the policy, I have masked id by xxxxxx
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
{
"Version": "2024-02-06",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/client1"
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/${iot:Connection.Thing.ThingName}"
},
{
"Effect": "Allow",
"Action": "iot:Publish",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/${iot:Connection.Thing.ThingName}"
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/${iot:Connection.Thing.ThingName}"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:topicfilter/${iot:Connection.Thing.ThingName}/room*"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:topic/${iot:Connection.Thing.ThingName}/room*"
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/${iot:Connection.Thing.ThingName}"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": [
"arn:aws:iot:ap-south-1:5xxxxxxx:topicfilter/my/topic",
"arn:aws:iot:ap-south-1:5xxxxxxx:topicfilter/my/othertopic"
]
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/${iot:Connection.Thing.ThingName}"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:topicfilter/my/topic"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:topic/my/topic"
},
{
"Condition": {
"ForAllValues:StringEquals": {
"iot:ConnectAttributes": [
"LastWill"
]
}
},
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:client/*"
},
{
"Effect": "Allow",
"Action": [
"iot:Publish",
"iot:RetainPublish"
],
"Resource": "arn:aws:iot:ap-south-1:5xxxxxxx:topic/will"
}
]
}
4.3 Cryptography, digital certifcate, elliptic curve cryptography, sha certicate, fingerprints
{gallery}elliptic curve cryptography |
---|
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
IMAGE TITLE: THEN IMAGE DESCRIPTION |
5. Code Snippets
One need not do so much programming, as the APIs may be available, anyway I m taking hard route for this experiment.
Below are not pseduo codes, but working codes. I still have to write full code. This is the same code on which I will work on if given project.
a) Basic Microcontroller. Microchip SAM E 51 setting
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
#define CPU_CLOCK_FREQUENCY 120000000
#pragma config BOD33_DIS = SET
#pragma config BOD33USERLEVEL = 0x1cU
#pragma config BOD33_ACTION = RESET
#pragma config BOD33_HYST = 0x2U
#pragma config NVMCTRL_BOOTPROT = 0
#pragma config NVMCTRL_SEESBLK = 0x0U
#pragma config NVMCTRL_SEEPSZ = 0x0U
#pragma config RAMECC_ECCDIS = SET
#pragma config WDT_ENABLE = CLEAR
#pragma config WDT_ALWAYSON = CLEAR
#pragma config WDT_PER = CYC8192
#pragma config WDT_WINDOW = CYC8192
#pragma config WDT_EWOFFSET = CYC8192
#pragma config WDT_WEN = CLEAR
#pragma config NVMCTRL_REGION_LOCKS = 0xffffffffU
b) Infineon AIROC setting
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
#define SERCOM4_USART_INT_BAUD_VALUE (63522UL) /*baud = 115200 Hz */
const DeviceVectors exception_table=
{
.pvStack = &_stack,
.pfnReset_Handler = Reset_Handler,
.pfnNonMaskableInt_Handler = NonMaskableInt_Handler,
.pfnHardFault_Handler = HardFault_Handler,
.pfnMemoryManagement_Handler = MemoryManagement_Handler,
.pfnSVCall_Handler = SVCall_Handler,
.pfnDebugMonitor_Handler = DebugMonitor_Handler,
.pfnSysTick_Handler = SysTick_Handler,
.pfnWDT_Handler = WDT_Handler,
.pfnRTC_Handler = RTC_InterruptHandler,
.pfnEIC_EXTINT_14_Handler = EIC_EXTINT_14_Handler,
.pfnEIC_EXTINT_15_Handler = EIC_EXTINT_15_Handler,
.pfnDMAC_3_Handler = DMAC_3_InterruptHandler,
.pfnSERCOM4_0_Handler = SERCOM4_USART_InterruptHandler,
.pfnSERCOM4_1_Handler = SERCOM4_USART_InterruptHandler,
.pfnSERCOM4_2_Handler = SERCOM4_USART_InterruptHandler,
.pfnSERCOM4_OTHER_Handler = SERCOM4_USART_InterruptHandler,
.pfnAES_Handler = AES_Handler,
.pfnTRNG_Handler = TRNG_InterruptHandler,
.pfnPUKCC_Handler = PUKCC_Handler,
};
typedef uint16_t USART_ERROR;
typedef enum
{ USART_DATA_5_BIT = SERCOM_USART_INT_CTRLB_CHSIZE_5_BIT,
USART_DATA_6_BIT = SERCOM_USART_INT_CTRLB_CHSIZE_6_BIT,
USART_DATA_7_BIT = SERCOM_USART_INT_CTRLB_CHSIZE_7_BIT,
USART_DATA_8_BIT = SERCOM_USART_INT_CTRLB_CHSIZE_8_BIT,
USART_DATA_9_BIT = SERCOM_USART_INT_CTRLB_CHSIZE_9_BIT,
USART_DATA_INVALID = 0xFFFFFFFFU
} USART_DATA;
typedef enum
{ USART_PARITY_EVEN = SERCOM_USART_INT_CTRLB_PMODE_EVEN,
USART_PARITY_ODD = SERCOM_USART_INT_CTRLB_PMODE_ODD,
USART_PARITY_NONE = 0x2,
USART_PARITY_INVALID = 0xFFFFFFFFU
} USART_PARITY;
typedef enum
{ USART_STOP_1_BIT = SERCOM_USART_INT_CTRLB_SBMODE_1_BIT,
USART_STOP_2_BIT = SERCOM_USART_INT_CTRLB_SBMODE_2_BIT,
USART_STOP_INVALID = 0xFFFFFFFFU
} USART_STOP;
SERCOM4_REGS->USART_INT.SERCOM_CTRLA = SERCOM_USART_INT_CTRLA_MODE_USART_INT_CLK | SERCOM_USART_INT_CTRLA_RXPO(0x0UL) | SERCOM_USART_INT_CTRLA_TXPO(0x0UL) | SERCOM_USART_INT_CTRLA_DORD_Msk | SERCOM_USART_INT_CTRLA_IBON_Msk | SERCOM_USART_INT_CTRLA_FORM(0x0UL) | SERCOM_USART_INT_CTRLA_SAMPR(0UL) ;
SERCOM4_REGS->USART_INT.SERCOM_BAUD = (uint16_t)SERCOM_USART_INT_BAUD_BAUD(SERCOM4_USART_INT_BAUD_VALUE);
SERCOM4_REGS->USART_INT.SERCOM_CTRLB = SERCOM_USART_INT_CTRLB_CHSIZE_8_BIT | SERCOM_USART_INT_CTRLB_SBMODE_1_BIT | SERCOM_USART_INT_CTRLB_RXEN_Msk | SERCOM_USART_INT_CTRLB_TXEN_Msk;
c) External Interrupt Controller (EIC)
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
typedef void (*EIC_CALLBACK) (uintptr_t context);
typedef struct
{ EIC_CALLBACK callback;
uintptr_t context;
EIC_PIN eicPinNo;
} EIC_CALLBACK_OBJ;
EIC_REGS->EIC_CTRLA |= (uint8_t)EIC_CTRLA_SWRST_Msk;
while((EIC_REGS->EIC_SYNCBUSY & EIC_SYNCBUSY_SWRST_Msk) == EIC_SYNCBUSY_SWRST_Msk)
{
}
EIC_REGS->EIC_CONFIG[1] = EIC_CONFIG_SENSE0_NONE ;
EIC_REGS->EIC_INTENSET = (1UL << (uint32_t)pin);
EIC_REGS->EIC_INTENCLR = (1UL << (uint32_t)pin);
EIC_REGS->EIC_INTENSET = 0x6e0U;
eicCallbackObject[14].eicPinNo = EIC_PIN_MAX;
EIC_REGS->EIC_CTRLA |= (uint8_t)EIC_CTRLA_ENABLE_Msk;
while((EIC_REGS->EIC_SYNCBUSY & EIC_SYNCBUSY_ENABLE_Msk) == EIC_SYNCBUSY_ENABLE_Msk)
{
}
d) Direct Memory Access Controller (DMAC)
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
#define DMAC_CHANNEL_6 (6U)
#define DMAC_CHANNEL_7 (7U)
typedef uint32_t DMAC_CHANNEL;
typedef enum
{ DMAC_TRANSFER_EVENT_NONE = 0,
DMAC_TRANSFER_EVENT_COMPLETE = 1,
DMAC_TRANSFER_EVENT_ERROR = 2
} DMAC_TRANSFER_EVENT;
typedef enum
{
DMAC_CRC_TYPE_16 = 0x0,
DMAC_CRC_TYPE_32 = 0x1
} DMAC_CRC_POLYNOMIAL_TYPE;
typedef enum
{
DMAC_CRC_MODE_DEFAULT = 0x0,
DMAC_CRC_MODE_RESERVED = 0x1,
DMAC_CRC_MODE_MEMORY_MONITOR = 0x2,
DMAC_CRC_MODE_MEMORY_GEN = 0x3
} DMAC_CRC_MODE;
typedef struct
{ DMAC_CRC_POLYNOMIAL_TYPE polynomial_type;
DMAC_CRC_MODE crc_mode;
uint32_t seed;
} DMAC_CRC_SETUP;
typedef struct
{
bool inUse;
DMAC_CHANNEL_CALLBACK callback;
uintptr_t context;
bool isBusy;
} DMAC_CH_OBJECT ;
volatile DMAC_CH_OBJECT *dmacChObj = &dmacChannelObj[0];
uint32_t channel = 0U;
DMAC_REGS->DMAC_BASEADDR = (uint32_t) descriptor_section;
DMAC_REGS->DMAC_WRBADDR = (uint32_t) write_back_section;
dmacChannelObj[6].inUse = true;
dmacChannelObj[7].inUse = true;
uint8_t beat_size = 0U;
bool returnStatus = false;
bool isBusy = dmacChannelObj[channel].isBusy;
const uint32_t* pu32srcAddr = (const uint32_t*)srcAddr;
const uint32_t* pu32dstAddr = (const uint32_t*)destAddr;
DMAC_REGS->CHANNEL[6].DMAC_CHCTRLA = DMAC_CHCTRLA_TRIGACT(2U) | DMAC_CHCTRLA_TRIGSRC(12U) | DMAC_CHCTRLA_THRESHOLD(0U) | DMAC_CHCTRLA_BURSTLEN(0U) ;
DMAC_REGS->CHANNEL[7].DMAC_CHCTRLA = DMAC_CHCTRLA_TRIGACT(2U) | DMAC_CHCTRLA_TRIGSRC(13U) | DMAC_CHCTRLA_THRESHOLD(0U) | DMAC_CHCTRLA_BURSTLEN(0U) ;
descriptor_section[6].DMAC_BTCTRL = DMAC_BTCTRL_BLOCKACT_INT | DMAC_BTCTRL_BEATSIZE_BYTE | DMAC_BTCTRL_VALID_Msk | DMAC_BTCTRL_DSTINC_Msk ;
descriptor_section[7].DMAC_BTCTRL = DMAC_BTCTRL_BLOCKACT_INT | DMAC_BTCTRL_BEATSIZE_BYTE | DMAC_BTCTRL_VALID_Msk | DMAC_BTCTRL_SRCINC_Msk ;
DMAC_REGS->CHANNEL[7].DMAC_CHPRILVL = DMAC_CHPRILVL_PRILVL(0U);
DMAC_REGS->CHANNEL[6].DMAC_CHPRILVL = DMAC_CHPRILVL_PRILVL(0U);
DMAC_REGS->CHANNEL[6].DMAC_CHINTENSET = (DMAC_CHINTENSET_TERR_Msk | DMAC_CHINTENSET_TCMPL_Msk);
DMAC_REGS->CHANNEL[7].DMAC_CHINTENSET = (DMAC_CHINTENSET_TERR_Msk | DMAC_CHINTENSET_TCMPL_Msk);
DMAC_REGS->DMAC_CTRL = DMAC_CTRL_DMAENABLE_Msk | DMAC_CTRL_LVLEN0_Msk | DMAC_CTRL_LVLEN1_Msk | DMAC_CTRL_LVLEN2_Msk | DMAC_CTRL_LVLEN3_Msk;
if ((length & 0x3U) == 0U)
{ beatSize = (uint8_t)DMAC_CRC_BEAT_SIZE_WORD;
length = length >> 0x2U; }
else if ((length & 0x1U) == 0U)
{ beatSize = (uint8_t)DMAC_CRC_BEAT_SIZE_HWORD;
length = length >> 0x1U; }
e) Data Watchpoint and Trace (DWT)
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0U;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
f) System timer (SysTick)
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
#define SYSTICK_FREQ 120000000U
#define SYSTICK_INTERRUPT_PERIOD_IN_US (1000U)
void SYSTICK_EventHandler(uintptr_t context)
typedef struct
{
uint32_t start;
uint32_t count;
}SYSTICK_TIMEOUT;
typedef struct
{
SYSTICK_CALLBACK callback;
uintptr_t context;
volatile uint32_t tickCounter;
} SYSTICK_OBJECT ;
g) True Random Number Generator (TRNG)
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
typedef struct
{
TRNG_CALLBACK callback;
uintptr_t context;
uint32_t data;
} TRNG_OBJECT ;
TRNG_REGS->TRNG_EVCTRL = TRNG_EVCTRL_DATARDYEO_Msk;
TRNG_REGS->TRNG_CTRLA = TRNG_CTRLA_RUNSTDBY_Msk;
TRNG_REGS->TRNG_CTRLA |= TRNG_CTRLA_ENABLE_Msk;
TRNG_REGS->TRNG_INTENSET = TRNG_INTENSET_DATARDY_Msk;
TRNG_REGS->TRNG_CTRLA = ((TRNG_REGS->TRNG_CTRLA) & (uint8_t)(~TRNG_CTRLA_ENABLE_Msk));
TRNG_REGS->TRNG_INTENCLR = TRNG_INTENCLR_DATARDY_Msk;
trng.data = TRNG_REGS->TRNG_DATA;
trng.callback = callback;
trng.context = context;
if(trng.callback != NULL)
{
uint32_t data = trng.data;
uintptr_t context = trng.context;
trng.callback(data, context);
}
h) Reset Controller (RSTC)
//Created by Mr. Abhishek Bansal
//Company: New Era Consultancy Services
typedef uint32_t RSTC_RESET_CAUSE;
typedef uint32_t RSTC_BKUPEXIT_CAUSE;