EE445M RTOS
Taken at the University of Texas Spring 2015
nexus.h File Reference
#include "defines.h"
#include <stdint.h>
Include dependency graph for nexus.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define immutable
 
#define public
 
#define private
 
#define always   __attribute__((always_inline))
 
#define atomic_start()
 
#define atomic_end()   EndCritical(atom)
 
#define atomic(x)
 
#define postpone_death()   while(1)
 
#define Hz
 

Typedefs

typedef int32_t memory_address_t
 
typedef int32_t frequency_t
 

Functions

 __attribute__ ((always_inline)) static inline int32_t StartCritical()
 
void * memset (void *, int, int)
 
void * memcpy (void *, const void *, long)
 
int strcmp (const char *, const char *)
 
int ustrncmp (const char *, const char *, uint32_t)
 
void ustrcpy (char *, const char *)
 
uint32_t ustrlen (const char *s)
 

Macro Definition Documentation

#define always   __attribute__((always_inline))

A convenience alias to 'attribute((always_inline))' to make function definitions read more naturally.

Definition at line 17 of file nexus.h.

#define atomic (   x)
Value:
{ \
int32_t atom; \
atom = StartCritical(); \
x \
EndCritical(atom); \
}

Wrap a block of code and ensure it is executed without interruption.

Warning
Assumes that an int32t named atom exists in local scope.

Definition at line 32 of file nexus.h.

Referenced by Thread1().

#define atomic_end ( )    EndCritical(atom)

End a critical section.

Definition at line 25 of file nexus.h.

Referenced by os_add_thread().

#define atomic_start ( )
Value:
int32_t atom; \
atom = StartCritical()

Begin a critical section.

Definition at line 20 of file nexus.h.

Referenced by os_add_thread().

#define Hz

#Defined to nothing; results in code sugar allowing developers to easily determine which parameter is frequency.

Definition at line 45 of file nexus.h.

Referenced by button_debounce_start(), and main().

#define immutable

A keyword to signify that a value should never be reassigned.

Definition at line 9 of file nexus.h.

#define postpone_death ( )    while(1)

A macro to make it clear what we're doing with this while loop.

Definition at line 40 of file nexus.h.

Referenced by _hw_get_channel(), adc_init(), hw_channel_init(), hw_driver_init(), hw_driver_singleton(), main(), os_tcb_of(), schedule(), and system_exec().

#define private

Definition at line 13 of file nexus.h.

#define public

Definition at line 12 of file nexus.h.

Typedef Documentation

typedef int32_t frequency_t

A representation of a periodic frequency.

Definition at line 51 of file nexus.h.

typedef int32_t memory_address_t

A reference to a memory location on the ARM Cortex M4.

Definition at line 48 of file nexus.h.

Function Documentation

__attribute__ ( (always_inline)  )

Begin a critical section while saving the PRIMASK for future restoration.

Returns
current PRIMASK

End a critical section by restoring a previously saved PRIMASK.

Parameters
PRIMASKto restore

bug: this line should be removed in favor of the above to avoid blindly enable interrupts, but instead enabling interrupts only if they were previously enabled before the last function call.

Definition at line 57 of file nexus.h.

58  {
59  asm("MRS R0, PRIMASK ;// save old status\n");
60  asm("CPSID I ;// mask all (except faults)\n");
61 }
void* memcpy ( void *  ,
const void *  ,
long   
)

A duplicate of the c standard memcpy function.

Definition at line 25 of file nexus.c.

Referenced by shell_set_ps1().

25  {
26 
27  long i = 0;
28  uint8_t *dest8 = (uint8_t*)str1;
29  uint8_t *source8 = (uint8_t*)str2;
30  for (i=0; i<n; ++i) {
31  dest8[i] = source8[i];
32  }
33 }

Here is the caller graph for this function:

void* memset ( void *  ,
int  ,
int   
)

A duplicate of the c standard memset function.

Definition at line 4 of file nexus.c.

Referenced by shell_clear_shell_buffer(), and system_register_command().

4  {
5 
6  int i;
7  unsigned char *p = b;
8  i = 0;
9  while(len > 0) {
10  *p = c;
11  ++p;
12  --len;
13  }
14  return b;
15 }

Here is the caller graph for this function:

int strcmp ( const char *  ,
const char *   
)

A duplicate of the c standard strcmp function.

Definition at line 35 of file nexus.c.

References ustrncmp().

Referenced by _system_command_from_name().

35  {
36 
37  return(ustrncmp(s1, s2, (uint32_t)-1));
38 }
int ustrncmp(const char *s1, const char *s2, uint32_t n)
Definition: nexus.c:40

Here is the call graph for this function:

Here is the caller graph for this function:

void ustrcpy ( char *  ,
const char *   
)

A duplicate of the c standard strcpy function.

Definition at line 69 of file nexus.c.

Referenced by system_register_command().

69  {
70  uint32_t i = 0;
71  while (1) {
72  dest[i] = source[i];
73  if (dest[i++] == '\0') { break; }
74  }
75 }

Here is the caller graph for this function:

uint32_t ustrlen ( const char *  s)

A duplicate of the c standard strlen function.

Definition at line 17 of file nexus.c.

Referenced by shell_set_ps1(), and uart_send_string_().

17  {
18  uint32_t len = 0;
19  while(s[len]) { ++len; }
20  return(len);
21 }

Here is the caller graph for this function:

int ustrncmp ( const char *  ,
const char *  ,
uint32_t   
)

A duplicate of the c standard strncmp function.

Definition at line 40 of file nexus.c.

Referenced by strcmp().

40  {
41 
42  /* Loop while there are more characters. */
43  while(n) {
44  /* If we reached a NULL in both strings, they must be equal so
45  * we end the comparison and return 0 */
46  if(!*s1 && !*s2) {
47  return(0);
48  }
49 
50  /* Compare the two characters and, if different, return the
51  * relevant return code. */
52  if(*s2 < *s1) {
53  return(1);
54  }
55  if(*s1 < *s2) {
56  return(-1);
57  }
58 
59  /* Move on to the next character. */
60  s1++;
61  s2++;
62  n--;
63  }
64  /* If we fall out, the strings must be equal for at least the
65  * first n characters so return 0 to indicate this. */
66  return 0;
67 }

Here is the caller graph for this function: