-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05a9f68
commit 5f257ad
Showing
416 changed files
with
480,471 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: MIMXRT1050-EVKB | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- 'core/**' | ||
- 'cmake/**' | ||
- 'NXP/MIMXRT1050-EVKB/**' | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- 'core/**' | ||
- 'cmake/**' | ||
- 'NXP/MIMXRT1050-EVKB/**' | ||
|
||
defaults: | ||
run: | ||
working-directory: NXP/MIMXRT1050-EVKB | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
# Get the ARM GCC compiler | ||
- name: Install tools for linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: sudo apt install gcc-arm-none-eabi cmake | ||
|
||
- name: Install Ninja | ||
uses: seanmiddleditch/gha-setup-ninja@v1 | ||
|
||
- name: Build project | ||
run: | | ||
cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE="../../cmake/arm-gcc-cortex-m7.cmake" | ||
cmake --build build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"name": "ARM GCC Cortex", | ||
"toolchainFile": "${workspaceFolder}/../../cmake/arm-gcc-cortex-m7.cmake" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "NXP: Local J-Link", | ||
"type": "cortex-debug", | ||
"request": "launch", | ||
"servertype":"jlink", | ||
"runToMain": true, | ||
"executable": "${workspaceFolder}/build/app/mimxrt1050_azure_iot.elf", | ||
"device": "MIMXRT1052xxx6A", | ||
"svdFile": "${workspaceFolder}/.vscode/MIMXRT1052.svd", | ||
}, | ||
{ | ||
"name": "NXP: Remote", | ||
"type": "cortex-debug", | ||
"executable": "${workspaceFolder}/build/app/mimxrt1050_azure_iot.elf", | ||
"request": "launch", | ||
"servertype": "external", | ||
"gdbTarget": "${input:device.host}", | ||
"runToMain": true, | ||
"device": "MIMXRT1052xxx6A", | ||
"svdFile": "${workspaceFolder}/.vscode/MIMXRT1052.svd", | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"id": "device.host", | ||
"type": "promptString", | ||
"default": "localhost:2331", | ||
"description": "The local hostname with port for GDB to connect to" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) | ||
set(CMAKE_C_STANDARD 99) | ||
|
||
set(GSG_BASE_DIR ${CMAKE_SOURCE_DIR}/../..) | ||
set(CORE_SRC_DIR ${GSG_BASE_DIR}/core/src) | ||
set(CORE_LIB_DIR ${GSG_BASE_DIR}/core/lib) | ||
|
||
# Set the toolchain if not defined | ||
if(NOT CMAKE_TOOLCHAIN_FILE) | ||
set(CMAKE_TOOLCHAIN_FILE "${GSG_BASE_DIR}/cmake/arm-gcc-cortex-m7.cmake") | ||
endif() | ||
|
||
include(${GSG_BASE_DIR}/cmake/utilities.cmake) | ||
|
||
# Define the Project | ||
project(mimxrt1050_azure_iot C ASM) | ||
|
||
add_subdirectory(${CORE_SRC_DIR} core_src) | ||
add_subdirectory(lib) | ||
add_subdirectory(app) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
set(LINKER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/startup/MIMXRT1052xxxxx_flexspi_nor.ld") | ||
|
||
set(SOURCES | ||
startup/startup_MIMXRT1052.S | ||
startup/tx_initialize_low_level.S | ||
|
||
azure_config.h | ||
nx_client.c | ||
mqtt.c | ||
board_init.c | ||
console.c | ||
main.c | ||
) | ||
|
||
add_executable(${PROJECT_NAME} ${SOURCES}) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
PUBLIC | ||
azrtos::threadx | ||
azrtos::netxduo | ||
|
||
app_common | ||
jsmn | ||
MIMXRT1050-evk | ||
netx_driver | ||
) | ||
|
||
target_link_options(${PROJECT_NAME} | ||
PRIVATE | ||
-T${LINKER_SCRIPT} -Wl,-Map=${PROJECT_NAME}.map) | ||
|
||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES | ||
LINK_DEPENDS ${LINKER_SCRIPT} | ||
SUFFIX ".elf" | ||
) | ||
|
||
create_bin_output(${PROJECT_NAME}) | ||
firmware_size(${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. */ | ||
|
||
#ifndef _AZURE_CONFIG_H | ||
#define _AZURE_CONFIG_H | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Azure IoT Hub Connection Transport | ||
// Define this to use MQTT, else Azure RTOS SDK for Azure IoT | ||
// ---------------------------------------------------------------------------- | ||
#define ENABLE_MQTT | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Azure IoT Dynamic Provisioning Service | ||
// Define this to use the DPS service, otherwise direct IoT Hub | ||
// ---------------------------------------------------------------------------- | ||
//#define ENABLE_DPS | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Azure IoT Hub config | ||
// ---------------------------------------------------------------------------- | ||
#define IOT_HUB_HOSTNAME "" | ||
#define IOT_DEVICE_ID "" | ||
#define IOT_PRIMARY_KEY "" | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Azure IoT DPS config | ||
// ---------------------------------------------------------------------------- | ||
#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" | ||
#define IOT_DPS_ID_SCOPE "" | ||
#define IOT_DPS_REGISTRATION_ID "" | ||
|
||
#endif // _AZURE_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. */ | ||
|
||
#include "board_init.h" | ||
|
||
#include "board.h" | ||
#include "pin_mux.h" | ||
|
||
void board_init() | ||
{ | ||
BOARD_ConfigMPU(); | ||
BOARD_InitPins(); | ||
BOARD_BootClockRUN(); | ||
BOARD_InitDebugConsole(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. */ | ||
|
||
#ifndef _BOARD_INIT_H | ||
#define _BOARD_INIT_H | ||
|
||
#include "nx_api.h" | ||
|
||
void board_init(); | ||
|
||
#endif // _BOARD_INIT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. */ | ||
|
||
#include "fsl_debug_console.h" | ||
|
||
int _read(int file, char *ptr, int len); | ||
int _write(int file, char *ptr, int len); | ||
|
||
int _read(int file, char *ptr, int len) | ||
{ | ||
int DataIdx; | ||
for (DataIdx = 0; DataIdx < len; DataIdx++) | ||
{ | ||
*ptr++ = GETCHAR(); | ||
} | ||
return len; | ||
} | ||
|
||
int _write(int file, char *ptr, int len) | ||
{ | ||
int DataIdx; | ||
for (DataIdx = 0; DataIdx < len; DataIdx++) | ||
{ | ||
PUTCHAR(*ptr++); | ||
} | ||
return len; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. */ | ||
|
||
#include <stdio.h> | ||
#include <time.h> | ||
|
||
#include "nx_driver_imxrt10xx.h" | ||
#include "tx_api.h" | ||
|
||
#include "board_init.h" | ||
#include "networking.h" | ||
#include "sntp_client.h" | ||
|
||
#include "mqtt.h" | ||
#include "nx_client.h" | ||
|
||
#include "azure_config.h" | ||
|
||
#define AZURE_THREAD_STACK_SIZE 4096 | ||
#define AZURE_THREAD_PRIORITY 4 | ||
|
||
TX_THREAD azure_thread; | ||
ULONG azure_thread_stack[AZURE_THREAD_STACK_SIZE / sizeof(ULONG)]; | ||
|
||
void azure_thread_entry(ULONG parameter); | ||
void tx_application_define(void* first_unused_memory); | ||
|
||
void azure_thread_entry(ULONG parameter) | ||
{ | ||
UINT status; | ||
|
||
printf("\r\nStarting Azure thread\r\n\r\n"); | ||
|
||
// Initialize the network | ||
if (!network_init(nx_driver_imx)) | ||
{ | ||
printf("Failed to initialize the network\r\n"); | ||
return; | ||
} | ||
|
||
// Start the SNTP client | ||
status = sntp_start(); | ||
if (status != NX_SUCCESS) | ||
{ | ||
printf("Failed to start the SNTP client (0x%02x)\r\n", status); | ||
return; | ||
} | ||
|
||
// Wait for an SNTP sync | ||
status = sntp_sync_wait(); | ||
if (status != NX_SUCCESS) | ||
{ | ||
printf("Failed to start sync SNTP time (0x%02x)\r\n", status); | ||
return; | ||
} | ||
|
||
#ifdef ENABLE_MQTT | ||
if ((status = azure_iot_mqtt_entry(&nx_ip, &nx_pool, &nx_dns_client, sntp_time_get))) | ||
#else | ||
if ((status = azure_iot_nx_client_entry(&nx_ip, &nx_pool, &nx_dns_client, sntp_time))) | ||
#endif | ||
{ | ||
printf("Failed to run Azure IoT (0x%04x)\r\n", status); | ||
return; | ||
} | ||
} | ||
|
||
void tx_application_define(void* first_unused_memory) | ||
{ | ||
// Initialise the board | ||
board_init(); | ||
|
||
// Create Azure SDK thread. | ||
UINT status = tx_thread_create(&azure_thread, | ||
"Azure Thread", | ||
azure_thread_entry, | ||
0, | ||
azure_thread_stack, | ||
AZURE_THREAD_STACK_SIZE, | ||
AZURE_THREAD_PRIORITY, | ||
AZURE_THREAD_PRIORITY, | ||
TX_NO_TIME_SLICE, | ||
TX_AUTO_START); | ||
|
||
if (status != TX_SUCCESS) | ||
{ | ||
printf("Azure IoT application failed, please restart\r\n"); | ||
} | ||
} | ||
|
||
int main(void) | ||
{ | ||
tx_kernel_enter(); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.