JenOS
User Guide
JN-UG-3075
Revision 1.8
25 August 2016
JenOS
User Guide
2 © NXP Laboratories UK 2016 JN-UG-3075 v1.8
JenOS
User Guide
JN-UG-3075 v1.8 © NXP Laboratories UK 2016 3
Contents
Preface 9
Organisation 9
Conventions 10
Acronyms and Abbreviations 10
Related Documents 11
Support Resources 11
Trademarks 11
Chip Compatibility 11
Part I: Concept and Operational Information
1. Introduction 15
1.1 Modules and Architecture 15
1.1.1 JenOS Modules 15
1.1.2 Software Architecture 16
1.2 Resources 17
2. Real-time Operating System (RTOS) 19
2.1 RTOS Fundamentals 19
2.2 Introduction to the JenOS RTOS 20
2.3 RTOS Configuration 20
2.4 RTOS Concepts and Features 21
2.4.1 User Tasks 21
2.4.2 Interrupt Service Routines (ISRs) 22
2.4.3 Priorities and Scheduling 22
2.4.4 Task/ISR States 23
2.4.5 State Transitions 24
2.4.6 Activity Scheduling (using Software Timers) 25
2.4.7 Mutual Exclusion (Mutex) 27
2.4.8 Inter-task Communication (using Messages) 28
2.5 OS Error Callback Function 30
2.5.1 Strict Error Checks 30
2.5.2 Handling OS Errors 30
Contents
4 © NXP Laboratories UK 2016 JN-UG-3075 v1.8
3. Persistent Data Manager (PDM) for Flash Memory 33
3.1 Overview 33
3.2 Initialising the PDM 34
3.3 Data Storage in NVM 35
3.4 Recovering Data from NVM 36
3.5 Saving Data to NVM 37
3.6 Deleting Data in NVM 37
3.7 Mutexes in PDM 38
3.8 Ensuring Consistency of PDM Records 38
4. Persistent Data Manager (PDM) for EEPROM 39
4.1 Overview 39
4.2 Initialising the PDM and Building a File System 40
4.3 Managing Data in EEPROM 41
4.3.1 Saving Data to EEPROM 42
4.3.2 Recovering Data from EEPROM 43
4.3.3 Deleting Data in EEPROM 43
4.4 Storing Counters in EEPROM 44
4.4.1 Creating a Counter 44
4.4.2 Incrementing a Counter 44
4.4.3 Reading a Counter 44
4.4.4 Deleting a Counter 45
4.5 PDM Features 45
4.5.1 Mutex in PDM 45
4.5.2 Event and Error Handler for EEPROM 45
4.5.3 EEPROM Capacity 46
4.5.4 EEPROM Wear Count 46
4.5.5 Ensuring Consistency of PDM Records 47
5. Power Manager (PWRM) 49
5.1 Low-Power Modes 49
5.1.1 Doze Mode 49
5.1.2 Sleep Mode with Memory Held 49
5.1.3 Sleep Mode without Memory Held 50
5.1.4 Deep Sleep Mode 50
5.2 Callback Functions for Power Manager 51
5.2.1 Essential Callback Function 51
5.2.2 Pre-sleep and Post-sleep Callback Functions 51
5.2.3 Wake Timer Callback Function 52
5.3 Initialising and Starting the Power Manager 52
5.4 Enabling Power-Saving 53
JenOS
User Guide
JN-UG-3075 v1.8 © NXP Laboratories UK 2016 5
5.5 Non-interruptible Activities 53
5.6 Terminating Low-Power Mode 54
5.7 Scheduling Wake Events 55
5.8 Doze Mode 55
5.8.1 Circumstances that Lead to Doze Mode 56
5.8.2 Doze Mode Monitoring During Development 57
6. Protocol Data Unit Manager (PDUM) 59
6.1 Message Assembly and Disassembly 59
6.2 Preparing the PDU Manager 60
6.3 Inserting Data into Outgoing Message 61
6.4 Extracting Data from Incoming Message 62
7. Debug (DBG) Module 63
7.1 Overview 63
7.2 Enabling the Debug Module 64
7.3 Initialising and Configuring the Debug Module 64
7.3.1 Using JN516x UART Input/Output 64
7.3.2 Using Alternative Serial Output 65
7.4 Debug Configuration Flags 66
7.5 Example Diagnostic Code 67
Part II: Reference Information
8. RTOS API 71
8.1 RTOS Macros 71
OS_TASK 72
OS_ISR 73
OS_SWTIMER_CALLBACK 74
OS_HWCOUNTER_ENABLE_CALLBACK 75
OS_HWCOUNTER_DISABLE_CALLBACK 76
OS_HWCOUNTER_SET_CALLBACK 77
OS_HWCOUNTER_GET_CALLBACK 78
8.2 RTOS Functions 79
8.2.1 Initialisation Functions 79
OS_vStart 80
OS_vRestart 81
8.2.2 User Task Functions 82
OS_eActivateTask 83
OS_eGetCurrentTask 84