tice.h

#include <tice.h>

This header includes defines for OS memory and prototypes for OS routines.

API Documentation

Core CE define file.

Authors

Matt “MateoConLechuga” Waltz

Jacob “jacobly” Young

Defines

randInt(min, max)

Returns a pseudo-random integer in the range of min to max (inclusive).

os_ClrHome()

Resets the OS homescreen; accounts for split screen.

os_ClrHomeFull()

Resets the OS homescreen fully; ignores split screen mode.

rtc_Enable(int)

Enables the Real-Time-Clock (RTC).

Parameters
  • int – Interrupt mask to enable specific RTC interrupts.

rtc_Set(sec, min, hr, day)

Sets the Real-Time-Clock (RTC) with new values.

Note

The set values do not take effect until the next RTC second. Verify the values have been loaded by waiting for rtc_IsBusy() to be false. The RTC will also need to be enabled.

Parameters
  • sec – Second value to load.

  • min – Minute value to load.

  • hr – Hour value to load.

  • day – Day value to load.

rtc_SetAlarm(sec, min, hr)

Sets the Real-Time-Clock (RTC) alarm with new values.

Parameters
  • sec – Second alarm value.

  • min – Minute alarm value.

  • hr – Hour alarm value.

rtc_Disable()

Disables the Real-Time-Clock (RTC).

rtc_IsBusy()

Checks if the RTC is busy setting newly loaded values.

rtc_AckInterrupt(mask)

Acknowledges an RTC interrupt.

This should be used to clear the condition that is causing the interrupt.

Parameters
  • mask – RTC interrupt mask.

rtc_ChkInterrupt(mask)

Checks if a RTC interrupt condition has occurred.

Parameters
  • mask – RTC interrupt mask.

rtc_Time()

Gets a combination of the RTC time; useful for seeding random numbers via srand().

rtc_Seconds

RTC seconds.

rtc_Minutes

RTC minutes.

rtc_Hours

RTC hours.

rtc_Days

RTC days.

rtc_AlarmSeconds

RTC alarm seconds.

rtc_AlarmMinutes

RTC alarm minutes.

rtc_AlarmHours

RTC alarm hours.

timer_Enable(n, rate, int, dir)

Enables timer n with the specified settings.

The CE has 3 different timers.

Warning

Timer 2 is needed by library functions like clock() and sleep(). Timer 3 is needed by USB.

Parameters
  • n – Timer to enable (range 1 - 3 inclusive).

  • rate – Rate in Hz the timer ticks at. Can be TIMER_32K or TIMER_CPU.

  • int – Throw an interrupt when the timer reaches 0. Can be TIMER_0INT or TIMER_NOINT.

  • dir – Direction in which to count. Can be TIMER_UP or TIMER_DOWN.

timer_Disable(n)

Disables a timer.

Parameters
  • n – Timer to disable (range 1 - 3 inclusive).

timer_Get(n)

Gets the current count value of a timer.

Attention

Do not use this function if the timer is configured with TIMER_CPU. Use the timer_GetSafe() function instead.

Parameters
  • n – Timer to get count value of (range 1 - 3 inclusive).

timer_GetSafe(n, dir)

Safely gets the current count value of a timer.

This should be used if the timer is ticking at >= 1MHz.

Parameters
  • n – Timer to get count value of (range 1 - 3 inclusive).

  • dir – Direction the timer is counting.

timer_Set(n, value)

Sets the count value of a timer.

Parameters
  • n – Timer to set count value of (range 1 - 3 inclusive).

  • value – Value to set timer count to.

timer_GetReload(n)

Gets the current reload value of a timer.

The reload value is loaded into the timer count when the timer reaches zero.

Parameters
  • n – Timer to get count reload value of (range 1 - 3 inclusive).

timer_SetReload(n, value)

Sets the reload value of a timer.

The reload value is loaded into the timer count when the timer reaches zero.

Parameters
  • n – Timer to set count reload value of (range 1 - 3 inclusive).

  • value – Value to set timer reload count to.

timer_GetMatch(n, m)

Gets the match m value of a timer.

There are two match value comparators per timer.

Parameters
  • n – Timer to get match comparator value of (range 1 - 3 inclusive).

  • m – Match compartor index (range 1 - 2 inclusive, recommended to use TIMER_MATCH(1) or TIMER_MATCH(2)).

timer_SetMatch(n, m, value)

Sets the match m value of a timer.

There are two match value comparators per timer.

Parameters
  • n – Timer to set match comparator value of (range 1 - 3 inclusive).

  • m – Match compartor index (range 1 - 2 inclusive recommended to use TIMER_MATCH(1) or TIMER_MATCH(2)).

  • value – Value to set match compartor to.

timer_AckInterrupt(n, mask)

Acknowledges a timer interrupt.

This should be used to clear the condition that is causing the interrupt.

Parameters
  • n – Timer to acknowledge interrupt of (range 1 - 3 inclusive).

  • mask – Interrupt mask, combination of TIMER_RELOADED, TIMER_MATCH(1), or TIMER_MATCH(2).

timer_ChkInterrupt(n, mask)

Checks if a timer interrupt condition has occurred.

Parameters
  • n – Timer to check interrupt for (range 1 - 3 inclusive).

  • mask – Interrupt mask, combination of TIMER_RELOADED, TIMER_MATCH(1), or TIMER_MATCH(2).

matrix_element(matrix, row, col)

Gets an element from a matrix.

Parameters
  • matrix – Structure of matrix

  • row – Row in matrix

  • col – Column in matrix

Returns

real_t containing element data

lcd_Ram

Base address of memory-mapped RAM for the LCD.

lcd_Control

LCD Control register.

lcd_Palette

LCD palette registers, 512 bytes.

lcd_BacklightLevel

Current backlight level of the LCD.

0 is bright. 255 is dark.

os_SmallFont

TIOS small font.

See also

os_FontSelect

os_LargeFont

TIOS large font.

See also

os_FontSelect

os_TextShadow

Text buffer, 260 bytes.

os_AsmPrgmSize

Current size of executing program.

os_PenCol

Small font column location.

os_PenRow

Small font row location.

os_OP1

OP1 Variable.

os_OP2

OP2 Variable.

os_OP3

OP3 Variable.

os_OP4

OP4 Variable.

os_OP5

OP5 Variable.

os_OP6

OP6 Variable.

os_OP7

OP7 Variable.

LCD_WIDTH

Width of LCD in pixels.

LCD_HEIGHT

Height of LCD in pixels.

LCD_SIZE

Total number of pixels in LCD.

TIMER_32K

Use the 32K clock for timer.

TIMER_CPU

Use the CPU clock rate for timer.

TIMER_0INT

Enable an interrupt when 0 is reached for the timer.

TIMER_NOINT

Disable interrupts for the timer.

TIMER_UP

Timer counts up.

TIMER_DOWN

Timer counts down.

TIMER_MATCH(i)

Timer hit the match value.

There are 2 match values per timer

TIMER_RELOADED

Timer was reloaded (Needs TIMER_0INT enabled)

RTC_LOAD_INT

RTC load operation complete.

RTC_ALARM_INT

RTC alarm interrupt.

RTC_DAY_INT

RTC interrupt on day change.

RTC_HR_INT

RTC interrupt on hour change.

RTC_MIN_INT

RTC interrupt on minute change.

RTC_SEC_INT

RTC interrupt on second change.

RTC_INT_MASK

RTC mask for all interrupts.

timer_GetLow(n)

Typedefs

typedef struct font font_t

Structure of font description.

See also

os_FontSelect

typedef int (*os_runprgm_callback_t)(void *data, int retval)

Callback function pointer type for os_RunPrgm.

See also

os_RunPrgm

typedef unsigned int useconds_t

An unsigned integer type capable of holding integers in the range [0,1000000].

See also

usleep

typedef struct system_info system_info_t
typedef uint8_t sk_key_t

Scan code type.

Enums

enum os_colors_t

Colors used by the OS.

Values:

enumerator OS_COLOR_BLUE = 10
enumerator OS_COLOR_RED
enumerator OS_COLOR_BLACK
enumerator OS_COLOR_MAGENTA
enumerator OS_COLOR_GREEN
enumerator OS_COLOR_ORANGE
enumerator OS_COLOR_BROWN
enumerator OS_COLOR_NAVY
enumerator OS_COLOR_LTBLUE
enumerator OS_COLOR_YELLOW
enumerator OS_COLOR_WHITE
enumerator OS_COLOR_LTGRAY
enumerator OS_COLOR_MEDGRAY
enumerator OS_COLOR_GRAY
enumerator OS_COLOR_DARKGRAY

Functions

void delay(uint16_t msec)

Suspends execution of the calling thread for (at least) msec milliseconds.

See also

sleep

See also

usleep

Parameters

msec – number of milliseconds

void msleep(uint16_t msec)

Suspends execution of the calling thread for (at least) msec milliseconds.

unsigned int sleep(unsigned int seconds)

Sleeps until the number of real-time seconds specified in seconds have elapsed or until a signal arrives which is not ignored.

See also

delay

See also

usleep

Note

Currently, signals do not exist, so this will never be interrupted.

Parameters

seconds – number of seconds

Returns

zero if the requested time has elapsed, or the number of seconds left to sleep, if the call was interrupted by a signal handler

void ticksleep(unsigned long ticks)

Suspends execution of the calling thread for (at least) ticks clock ticks.

See also

CLOCKS_PER_SEC

See also

delay

See also

usleep

Parameters

ticks – number of clock ticks

int usleep(useconds_t usec)

Suspends execution of the calling thread for (at least) usec microseconds.

The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.

See also

delay

See also

sleep

See also

useconds_t

Note

Currently, no errors are possible.

Parameters

usec – number of microseconds

Returns

0 on success, or -1 on error, with errno set to indicate the error

uint32_t random(void)

Returns a pseudo-random 32-bit integer.

Returns

the random integer

void srandom(uint32_t seed)

Seeds the pseudo-random number generator used by random() and rand() with the value seed.

Parameters

seed – the seed value

void boot_SetDate(uint8_t day, uint8_t month, uint16_t year)

Sets the calculator’s date.

Performs checks to ensure date is within range

Parameters
  • day – Day to set

  • month – Month to set

  • year – Year to set

void boot_GetDate(uint8_t *day, uint8_t *month, uint16_t *year)

Gets the calculator’s date.

Parameters
  • day – Pointer to variable to store day

  • month – Pointer to variable to store month

  • year – Pointer to variable to store year

void boot_SetTime(uint8_t seconds, uint8_t minutes, uint8_t hours)

Sets the calculator’s time.

Performs checks to ensure time is within range

Parameters
  • seconds – Seconds to set

  • minutes – Minutes to set

  • hours – Hours to set

void boot_GetTime(uint8_t *seconds, uint8_t *minutes, uint8_t *hours)

Gets the calculator’s time.

Parameters
  • seconds – Pointer to variable to store seconds

  • minutes – Pointer to variable to store minutes

  • hours – Pointer to variable to store hours

bool boot_IsAfterNoon(void)

Checks if past noon.

Returns

True if past noon

uint8_t boot_GetBootMajorVer(void)
Returns

Bootcode version major

uint8_t boot_GetBootMinorVer(void)
Returns

Bootcode version minor

uint8_t boot_GetHardwareVer(void)
Returns

Hardware version

void boot_ClearVRAM(void)

Turns all of VRAM into 0xFF (white)

bool boot_CheckOnPressed(void)

Checks if the [on] key was pressed.

Returns

True is returned if [on] key was pressed

void boot_DebugPrintf(const char *string)

Basically a reimplemented form of printf that prints to some debugging device.

Parameters

string – String to send to debug device

void boot_TurnOn(void)

Turns on the calculator.

void boot_TurnOff(void)

Turns off the calculator (probably not a good idea to use)

void boot_NewLine(void)

Inserts a new line at the current cursor posistion on the homescreen Does not scroll.

uint8_t boot_GetBatteryStatus(void)
Returns

Current battery status

bool boot_BatteryCharging(void)
Returns

True if the battery is currently charging.

bool boot_USBBusPowered(void)
Returns

True if the USB bus is powered by a host.

bool boot_USBSelfPowered(void)
Returns

True if the USB bus is self-powered.

void boot_USBResetChip(void)

Resets the USB controller.

void boot_USBDisableTimers(void)

Disables the USB Timers.

void boot_USBEnableTimers(void)

Enables the USB Timers.

void boot_USBResetTimers(void)

Resets the USB Timers.

void boot_WaitShort(void)

Waits for ~10 ms.

In most cases it is better to use the delay() function.

void os_NewLine(void)

Inserts a new line at the current cursor posistion on the homescreen.

Does scroll.

void os_DisableCursor(void)

Disables the OS cursor.

void os_EnableCursor(void)

Enables the OS cursor.

void os_SetDrawFGColor(uint24_t color)

Sets the foreground color used to draw text on the graphscreen.

Parameters

color – 565 BGR color to set text foreground to

uint24_t os_GetDrawFGColor(void)

Gets the foreground color used to draw text on the graphscreen.

Returns

565 BGR color of text foreground

void os_SetDrawBGColor(uint24_t color)

Sets the background color used to draw text on the graphscreen.

Parameters

color – 565 BGR color to set text background to

uint24_t os_GetDrawBGColor(void)

Gets the background color used to draw text on the graphscreen.

Warning

Only useable in OS 5.2 and above; use at your own risk

Returns

565 BGR color of text nackground

void os_SetCursorPos(uint8_t curRow, uint8_t curCol)

Set the cursor posistion used on the homescreen.

Parameters
  • curRow – The row aligned offset

  • curCol – The column aligned offset

void os_GetCursorPos(unsigned int *curRow, unsigned int *curCol)

Gets the cursor posistion used on the homescreen.

Parameters
  • curRow – Pointer to store the row aligned offset

  • curCol – Pointer to store the column aligned offset

void os_FontSelect(font_t *font)

Selects the (monospace) font to use when drawing on the graphscreen.

Parameters

font

font id/pointer to use os_SmallFont

os_LargeFont

font_t *os_FontGetID(void)

Gets the font to use when drawing on the graphscreen.

Returns

0: small font

1: large monospace font

uint24_t os_FontGetWidth(const char *string)
Parameters

string – String to get pixel width of

Returns

The width of a string in the variable-width format

uint24_t os_FontGetHeight(void)
Returns

The height of the font characters

uint24_t os_FontDrawText(const char *string, uint16_t col, uint8_t row)

Draws text using the small font to the screen.

Parameters
  • string – String to draw

  • col – Column to start drawing at

  • row – Row to start drawing at

Returns

The end column

uint24_t os_FontDrawTransText(const char *string, uint16_t col, uint8_t row)

Draws transparent text using the small font to the screen.

Parameters
  • string – String to draw

  • col – Column to start drawing at

  • row – Row to start drawing at

Returns

The end column

uint24_t os_PutStrFull(const char *string)

Puts some text at the current homescreen cursor location.

Parameters

string – Text to put on homescreen

Returns

1 if string fits on screen, 0 otherwise

uint24_t os_PutStrLine(const char *string)

Puts some text at the current homescreen cursor location.

Parameters

string – Text to put on homescreen

Returns

1 if string fits on line, 0 otherwise

void os_SetFlagByte(int offset, uint8_t set)

Set a particular OS flag.

Parameters
  • offset – Offset to particular flag in list

  • set – Bitmask of flag to set

uint8_t os_GetFlagByte(int offset)

Get a particular OS flag.

Parameters

offset – Offset to particular flag in list

Returns

Bitmask of flag

size_t os_MemChk(void **free)

Returns the size in bytes of free RAM that the user isn’t using.

A pointer is also returned to the start of this region; you can use it for your own purposes but do not exceed the size returned. This function is useful if you are running out of space in the bss or heap and need a little extra memory.

Parameters

free – Set to start of free available RAM

Returns

Size of available RAM

void os_ThrowError(uint8_t error) __attribute__((noreturn))

Throws an OS error.

Parameters

error – Error code to throw

const system_info_t *os_GetSystemInfo(void)

Gets the system info.

Returns

A pointer to system_info_t

int os_PushErrorHandler(void) __attribute__((returns_twice))

This function can return twice (like setjmp).

First return always happens with a return value of 0. Second return only happens if an error occurs before os_PopErrorHandler is called, with the errNo as the return value.

int errno = os_PushErrorHandler();
if (errno) {
    // handle error, but no longer under the protection of the error handler so do not call os_PopErrorHandler()
} else {
    // run some code that may error
    os_PopErrorHandler();
}

void os_PopErrorHandler(void)

Restores stack state after a call to os_PushErrorHandler.

Must be called with stack in the same state as it was when os_PushErrorHandler returned with 0, and should not be called along the error path.

int os_RunPrgm(const char *prgm, void *data, size_t size, os_runprgm_callback_t callback)

Runs a program that exists on the calculator.

Note that this will destroy the currently running program, requiring you to save any data as needed. This program has an optional callback that will be executed when the called program finishes, which can be used to rebuild the program state. Additionally, program context information can be safely stored by using the extra user data arguments, which will then be delivered to the callback.

Note

The callback return code is passed to the launcher of the original program that called this function.

Parameters
  • prgm – Name of program to execute.

  • data – User data that will be available in the callback function. May be NULL.

  • size – Size of user data (keep this small, it is stored on the stack!)

  • callback – Callback function to run when program finishes executing. The argument data will contain the provided data contents, and retval will contain the error code if a TI-BASIC program, or the exit code if a C program. Other types of programs may have an undefined retval. This argument may be left NULL if execution should not return to the calling program.

Returns

This function should not return, but if it does, -1 indicates the program could not be found, -2 if not enough memory, and < 0 if some other error occurred.

void *os_GetSymTablePtr(void)
Returns

A pointer to symtable of the OS

void *os_NextSymEntry(void *entry, uint24_t *type, uint24_t *nameLength, char *name, void **data)
Returns

next entry or NULL if no more entries, pass os_GetSymTablePtr() as first entry

int os_DelSymEntry(void *entry)

Delete a var from RAM.

Parameters

entry – An entry as returned from os_NextSymEntry().

Returns

TIOS System Error Code or 0 on success.

int os_CreateString(const char *name, const string_t *data)

Creates an TIOS Str.

Parameters
  • name – Name of the Str to create.

  • data – Initial contents of the created Str.

Returns

A TIOS error code, or 0 on success.

string_t *os_GetStringData(const char *name, int *archived)

Gets a pointer to an TIOS Str’s data, which may be in archive.

Note

Returns NULL if the Str doesn’t exist, otherwise a pointer to the size bytes.

Parameters
  • name – Name of the Str to lookup.

  • archived – Set to 1 if the Str is archived, otherwise 0, may be NULL if you don’t need it.

Returns

A pointer to the Str data

int os_CreateEquation(const char *name, const equ_t *data)

Creates a TIOS Equ.

Parameters
  • name – Name of the Equ to create.

  • data – Initial contents of the created Equ.

Returns

A TIOS error code, or 0 on success.

equ_t *os_GetEquationData(const char *name, int *archived)

Gets a pointer to an TIOS Equ’s data, which may be in archive.

Note

Returns NULL if the Equ doesn’t exist, otherwise a pointer to the size bytes.

Parameters
  • name – Name of the Equ to lookup.

  • archived – Set to 1 if the Equ is archived, otherwise 0, may be NULL if you don’t need it.

Returns

A pointer to the Equ data.

var_t *os_CreateAppVar(const char *name, uint16_t size)

Creates a TIOS AppVar.

Note

Returns NULL if creation failed for some reason, otherwise a pointer to the size bytes.

Note

If successful, the AppVar contents will be uninitialized, aka filled with random bytes.

Parameters
  • name – Name of the AppVar to create.

  • size – Size of AppVar to create.

Returns

A pointer to the AppVar data.

var_t *os_GetAppVarData(const char *name, int *archived)

Gets a pointer to a TIOS AppVar’s data, which may be in archive.

Note

Returns NULL if the AppVar doesn’t exist, otherwise a pointer to the size bytes.

Parameters
  • name – Name of the AppVar to lookup.

  • archived – Set to 1 if the AppVar is archived, otherwise 0, may be NULL if you don’t need it.

Returns

A pointer to the AppVar data.

void os_DelAppVar(const char *name)

Deletes an AppVar from RAM.

Parameters

name – Name of the AppVar to delete.

int os_ChkFindSym(uint8_t type, const char *name, void **entry, void **data)

Locates a symbol in the symtable.

Parameters
  • type – Type of symbol to find

  • name – Pointer to name of symbol to find

  • entry – Can be NULL if you don’t care

  • data – Can be NULL if you don’t care

Returns

If file exists, returns 1 and sets entry and data, otherwise returns 0.

int os_GetVarSize(const char *name, size_t *size)

Gets the size of sized vars such as equations, string, programs, appvars, or the dimension of a list.

Parameters
  • name – Name of the var to lookup.

  • size – Pointer to store size of variable.

Returns

TIOS System Error Code or 0 on success.

int os_GetMatrixDims(const char *name, int *rows, int *cols)

Gets the dimensions of a matrix.

Parameters
  • name – Name of the matrix to lookup.

  • rows – Pointer to store number of rows.

  • cols – Pointer to store number of columns.

Returns

TIOS System Error Code or 0 on success.

int os_GetRealListElement(const char *name, int index, real_t *value)

Gets a real value from a real list or a complex list where the selected element has no imaginary component.

Parameters
  • name – Name of the list.

  • index – Element index (1-based).

  • value – Set tto the value of the selected element.

Returns

TIOS System Error Code or 0 on success.

int os_GetMatrixElement(const char *name, int row, int col, real_t *value)

Gets a real value from a matrix.

Parameters
  • name – Name of the matrix.

  • row – Element row (1-based).

  • col – Element col (1-based).

  • value – Set to the value of the selected element.

Returns

TIOS System Error Code or 0 on success.

int os_GetRealVar(const char *name, real_t *value)

Gets the real value of a real variable or a complex variable with no imaginary component.

Parameters
  • name – Name of TIOS variable.

  • value – Set to the value of the variable.

Returns

TIOS System Error Code or 0 on success.

int os_SetListDim(const char *name, int dim)

If list name doesn’t exist, create it with dim elements, otherwise resize the list, with new elements being set to 0.

Parameters
  • name – Name of the list to resize.

  • dim – New list dimension.

Returns

TIOS System Error Code or 0 on success.

int os_SetMatrixDims(const char *name, int rows, int cols)

If matrix name doesn’t exist, create it with dimensions rows and cols, otherwise resize the matrix, with new elements being set to 0.

Parameters
  • name – Name of the matrix to resize.

  • rows – New row dimension.

  • cols – New col dimension.

Returns

TIOS System Error Code or 0 on success.

int os_SetRealListElement(const char *name, int index, const real_t *value)

Sets a list element to a real value.

If the list doesn’t exist, then index must be 1 and it creates a 1 element list.

Parameters
  • name – Name of the list.

  • index – Element index (1-based).

  • value – The value to set to the selected element.

Returns

TIOS System Error Code or 0 on success.

int os_SetMatrixElement(const char *name, int row, int col, const real_t *value)

Sets a matrix element to a real value.

Parameters
  • name – Name of the matrix.

  • row – Element row (1-based).

  • col – Element col (1-based).

  • value – The value to set to the selected element.

Returns

TIOS System Error Code or 0 on success.

int os_SetRealVar(const char *name, const real_t *value)

Sets a variable to a real value, creating it if it doesn’t exist.

Parameters
  • name – Name of variable to lookup.

  • value – The value to set the variable to.

Returns

TIOS System Error Code or 0 on success.

void *os_GetAnsData(uint8_t *type)

Gets the Ans variable.

Note

Returns NULL if Ans doesn’t exist or type is NULL

Parameters

type – This is set to the current variable type in ANS

Returns

Pointer to the data

real_t os_RealCopy(const real_t *src)

Copies a real_t type.

Parameters

src – Pointer to original real_t

Returns

Copied real_t

real_t os_RealAcosRad(const real_t *arg)

Takes the arccosine of a real_t, giving the answer in radians.

Note

Ensure -1 <= *arg <= 1, or program will crash.

real_t os_RealAsinRad(const real_t *arg)

Takes the arcsine of a real_t, giving the answer in radians.

Note

Ensure -1 <= *arg <= 1, or program will crash.

real_t os_RealAtanRad(const real_t *arg)

Takes the arctangent of a real_t, giving the answers in radians.

real_t os_RealCosRad(const real_t *arg)

Takes the cosine of a real_t given in radians.

real_t os_RealRadToDeg(const real_t *arg)

Converts a real_t from radians to degrees.

real_t os_RealExp(const real_t *arg)

Evaluates the exponential function (e^x, where e=2.717..) of a real_t.

real_t os_RealFloor(const real_t *arg)

Takes the floor of a real_t.

real_t os_RealFrac(const real_t *arg)

Extracts the fractional part of a real_t.

real_t os_RealRoundInt(const real_t *arg)

Rounds a real_t to the nearest integer.

real_t os_RealLog(const real_t *arg)

Takes the natural logarithm of a real_t.

Note

To take log base 10, divide this value by ln(10)

real_t os_RealNeg(const real_t *arg)

Negates a real_t.

real_t os_RealDegToRad(const real_t *arg)

Converts a real_t from degrees to radians.

real_t os_RealInv(const real_t *arg)

Takes the reciprocal of a real_t.

real_t os_RealSinRad(const real_t *arg)

Takes the sine of a real_t given in radians.

real_t os_RealSqrt(const real_t *arg)

Takes the square root of a real_t.

real_t os_RealTanRad(const real_t *arg)

Takes the tangent of a real_t given in radians.

real_t os_RealInt(const real_t *arg)

Extracts the integer part of a real_t.

cplx_t os_CplxSquare(const cplx_t *arg)

Calculates the square of a cplx_t.

real_t os_RealAdd(const real_t *arg1, const real_t *arg2)

Adds two real_t values.

real_t os_RealDiv(const real_t *arg1, const real_t *arg2)

Divides two real_t values.

real_t os_RealGcd(const real_t *arg1, const real_t *arg2)

Calculates the Greatest Common Divisor of two real_t values.

real_t os_RealLcm(const real_t *arg1, const real_t *arg2)

Calculates the Least Common Multiple of two real_t values.

real_t os_RealMax(const real_t *arg1, const real_t *arg2)

Returns the larger of two real_t values.

real_t os_RealMin(const real_t *arg1, const real_t *arg2)

Returns the smaller of two real_t values.

real_t os_RealMul(const real_t *arg1, const real_t *arg2)

Multiplies two real_t values.

real_t os_RealNcr(const real_t *total, const real_t *num)

Calculates the value of nCr (binomial coefficient) for two real_t values.

real_t os_RealNpr(const real_t *total, const real_t *num)

Calculates the value of nPr (permutation number) for two real_t values.

real_t os_RealPow(const real_t *base, const real_t *exp)

Raises one real_t value to the power of another.

real_t os_RealRandInt(const real_t *min, const real_t *max)

Returns a random real_t between min and max.

real_t os_RealMod(const real_t *arg1, const real_t *arg2)

Calculates the remainder (modulo) of two real_t values.

real_t os_RealSub(const real_t *arg1, const real_t *arg2)

Subtracts two real_t values.

real_t os_RealRound(const real_t *arg, char digits)

Rounds a real_t.

Note

digits must be in the range 0 - 9

Parameters
  • arg – Real variable.

  • digits – Number of digits to round to.

int os_RealCompare(const real_t *arg1, const real_t *arg2)

Compares two real_t.

Note

os_RealCompare(arg1, arg2) op 0 computes arg1 op arg2 for any comparison operator op.

Parameters
  • arg1 – Real variable 1.

  • arg2 – Real variable 2.

Returns

-1, 0, or 1 if arg1 is less than, equal to, or greater than arg2.

int24_t os_RealToInt24(const real_t *arg)

Converts a real_t to an integer.

Note

Saturates on overflow

Parameters

arg – Real variable.

real_t os_Int24ToReal(int24_t arg)

Converts an integer to a real_t.

Note

Saturates on overflow

Parameters

arg – Integer value.

float os_RealToFloat(const real_t *arg)

Converts a real_t to a float.

Note

Saturates on overflow

Parameters

arg – Real variable.

real_t os_FloatToReal(float arg)

Converts an float to a real_t.

Note

Saturates on overflow

Parameters

arg – Float value.

int os_RealToStr(char *result, const real_t *arg, int8_t maxLength, uint8_t mode, int8_t digits)

This converts a ti-float to a ti-ascii string.

Parameters
  • result – Zero terminated string copied to this address

  • arg – Real to convert

  • maxLength

    <=0: use default max length (14)

    >0: max length of result, minimum of 6

  • mode

    0: Use current mode for everything (digits ignored)

    1: Normal mode

    2: Sci mode

    3: Eng mode

    >4: Use current Normal/Sci/Eng mode (digits still used)

  • digits

    -1: Float mode

    0-9: Fix # mode

Returns

Length of result

real_t os_StrToReal(const char *string, char **end)

This converts a ti-ascii string to a ti-float.

String format regexp: / *[-\032+]?[0-9]*(.[0-9]*)?([eE\033][-\032+]?[0-9]*)?/

Parameters
  • string – TI-ascii string to convert

  • end – If non-null, pointer to end of parsed number is stored here

Returns

resulting TI-float; on exponent overflow this is +-9.9999999999999e99

int os_TestFlagBits(uint16_t offset_pattern)

High 8 is unsigned offset, low 8 is bits to test.

bool os_TestFlagBitsFast(uint16_t offset_pattern)
void os_SetFlagBits(int16_t offset_pattern)
void os_ResetFlagBits(int16_t offset_pattern)
void os_GetStringInput(char *string, char *buf, size_t bufsize)

Custom implementation input routine for use in conjunction with the TIOS.

It is HIGHLY recommended you implement your own routine, this routine has some quirks. It is good enough for getting basic input however.

Parameters
  • string – Input prompt string to be displayed to the user

  • buf – Storage location to store input string

  • bufsize – Available storage size for input string. -1 for null termination.

Returns

None

uint16_t os_GetKey(void)

Gets a key from the OS.

Returns

Key code

Returns

Extended key code in high byte

void os_DisableHomeTextBuffer(void)

Disable text buffering on the homescreen.

C programs use this area by default for the BSS / Heap.

void os_EnableHomeTextBuffer(void)

Enables text buffering on the homescreen.

C programs use this area by default for the BSS / Heap.

sk_key_t os_GetCSC(void)

Performs an OS call to get the keypad scan code.

You can also use this function to get input from the user as a string like this:

const char *chars = "\0\0\0\0\0\0\0\0\0\0\"WRMH\0\0?[VQLG\0\0:ZUPKFC\0 YTOJEB\0\0XSNIDA\0\0\0\0\0\0\0\0";
uint8_t key, i = 0;
char buffer[50];

while((key = os_GetCSC()) != sk_Enter) {
    if(chars[key]) {
        buffer[i++] = chars[key];
    }
}
Feel free to modify the string to suit your needs.

Returns

Key scan code

void os_MSDGetMaxLUN(uint8_t *value)

Perform an MSD GetMaxLUN request, either through the USB port or with an ARM coprocessor.

Parameters

value – On input the wValue to use in the request (should be zero for usb?), on output the max logical unit number.

void os_MSDReset(uint8_t value)

Perform an MSD mass storage reset request, either through the USB port or with an ARM coprocessor.

Parameters

value – Affects the wValue of the request, 1 for 0x55AA, 2 for 0xAA55, otherwise 0x0000 (for usb).

int8_t os_MSDInquiry(uint8_t lun, uint8_t *inquiry)

Performs an MSD inquiry, either through the USB port or with an ARM coprocessor.

Parameters
  • lun – Logical unit number.

  • inquiry – Buffer where the response is stored.

Returns

Error code, 0 for success, 5 for failed command, -5 for failed transfer.

void os_MSDTestUnitReady(uint8_t lun, uint8_t *status)

Performs an MSD test unit ready command, either through the USB port or with an ARM coprocessor.

Parameters
  • lun – Logical unit number.

  • status – Returns the status of the command.

int8_t os_MSDReadCapacity(uint8_t lun, uint32_t data[2])

Performs an MSD read capacity command, either through the USB port or with an ARM coprocessor.

Parameters
  • lun – Logical unit number.

  • data – Returns the returned logical block address and block byte length.

Returns

Error code, 0 for success, 5 for failed command, -5 for failed transfer.

int8_t os_MSDRead(uint8_t lun, uint8_t blockCount, uint32_t lba, uint24_t blockSize, void *buffer)

Performs an MSD read command, either through the USB port or with an ARM coprocessor.

Parameters
  • lun – Logical unit number.

  • blockCount – Number of blocks to read.

  • lba – Logical block address to start reading from.

  • blockSize – Block size, obtained from os_MSDReadCapacity().

  • buffer – Buffer to read data into, should be blockCount * blockSize bytes.

Returns

Error code, 0 for success, 5 for failed command, -5 for failed transfer.

int8_t os_MSDWrite(uint8_t lun, uint8_t blockCount, uint32_t lba, uint24_t blockSize, void *buffer)

Performs an MSD write command, either through the USB port or with an ARM coprocessor.

Parameters
  • lun – Logical unit number.

  • blockCount – Number of blocks to write.

  • lba – Logical block address to start writing to.

  • blockSize – Block size, obtained from os_MSDReadCapacity().

  • buffer – Buffer of data to write, should be blockCount * blockSize bytes.

Returns

Error code, 0 for success, 5 for failed command, -5 for failed transfer.

int8_t os_USBGetRequestStatus(void)

Gets some status after a control request.

Returns

Some status in the range [0, 3].

void os_ForceCmdNoChar(void)

Executes the assembly routine _ForceCmdNoChar.

void os_MoveUp(void)

Routine to scroll homescreen up.

void os_MoveDown(void)

Routine to scroll homescreen down.

void os_HomeUp(void)

Routine to move row and column posistion to (0,0)

void os_RunIndicOn(void)

Routine to turn on the Run Indicator.

void os_RunIndicOff(void)

Routine to turn off the Run Indicator.

void os_DisableAPD(void)

Routine to turn off APD.

void os_EnableAPD(void)

Routine to turn on APD.

void os_ArcChk(void)

Routine checks the amount of free archive.

void os_ClrLCDFull(void)

Routine to clear the homescreen lcd.

void os_ClrLCD(void)

Routine to clear the homescreen lcd.

Accounts for split screen

void os_DrawStatusBar(void)

Routine to redraw the status bar.

void os_DelRes(void)

Invalidate and clear stat variables.

void os_ClrTxtShd(void)

Invalidate and clear text shadow area.

void boot_Set6MHzMode(void)

Runs the calulator at 6 MHz.

void boot_Set48MHzMode(void)

Runs the calulator at 48 MHz.

void boot_Set6MHzModeI(void)

Runs the calulator at 6 MHz (saves interrupt status)

void boot_Set48MHzModeI(void)

Runs the calulator at 48 MHz (saves interrupt status)

uint32_t atomic_load_32(volatile uint32_t *p)

“Atomically” loads from a volatile 32-bit value.

Remark

The hardware does not provide a mechanism to truly atomically load from a 32-bit value. This “atomic” load is implemented by non-atomically reading the value twice and retrying if the values read differ.

Attention

If the maximum period between two value changes is 1us or less (assuming a CPU clock speed of 48MHz), then this function may never complete. For instance, the counter of a timer ticking at 1MHz or more should not be read using this function. In such a case of a purely increasing or decreasing value, atomic_load_increasing_32() or atomic_load_decreasing_32() may be appropriate instead.

Parameters

p – pointer to 32-bit value

uint32_t atomic_load_increasing_32(volatile uint32_t *p)

“Atomically” loads from a volatile, increasing 32-bit value.

Remark

The hardware does not provide a mechanism to truly atomically load from a 32-bit value. This “atomic” load is implemented by temporarily disabling interrupts while non-atomically reading the value twice and then returning the lesser of the two values read.

Attention

If the minimum period between two value changes is 5us or less and the value’s maximum rate of change over a 5us period exceeds 256 (assuming a CPU clock speed of 48MHz), then the value returned may be incorrect. Of relevant note may be the fact that a 48MHz counter does not exceed this limit.

Parameters

p – pointer to 32-bit value

uint32_t atomic_load_decreasing_32(volatile uint32_t *p)

“Atomically” loads from a volatile, decreasing 32-bit value.

Remark

The hardware does not provide a mechanism to truly atomically load from a 32-bit value. This “atomic” load is implemented by temporarily disabling interrupts while non-atomically reading the value twice and then returning the greater of the two values read.

Attention

If the minimum period between two value changes is 5us or less and the value’s maximum rate of change over a 5us period exceeds 256 (assuming a CPU clock speed of 48MHz), then the value returned may be incorrect. Of relevant note may be the fact that a 48MHz counter does not exceed this limit.

Parameters

p – pointer to 32-bit value

struct real_t
#include <>

Structure of real variable type.

Public Members

int8_t sign
int8_t exp
uint8_t mant[7]
struct cplx_t
#include <>

Structure of complex variable type.

Public Members

real_t real
real_t imag
struct list_t
#include <>

Structure of list variable type.

Public Members

uint16_t dim
real_t items[1]
struct cplx_list_t
#include <>

Structure of complex list variable type.

Public Members

uint16_t dim
cplx_t items[1]
struct matrix_t
#include <>

Structure of matrix variable type.

Public Members

uint8_t cols
uint8_t rows
real_t items[1]
struct string_t
#include <>

Structure of string variable type.

Public Members

uint16_t len
char data[1]
struct equ_t
#include <>

Structure of equation variable type.

Public Members

uint16_t len
char data[1]
struct var_t
#include <>

Structure of miscellaneous variable type.

Public Members

uint16_t size
uint8_t data[1]
struct font
#include <>

Structure of font description.

See also

os_FontSelect

Public Members

struct font *font

Points to this font itself, yuck!

void (*drawChar)(char c)

Draws a character using this font.

Param c

The character

uint24_t (*getWidth)(char c)

Gets the width of a character in this font.

Param c

The character

uint24_t (*getHeight)(void)

Gets the height of this font.

struct system_info

Public Members

size_t size

number of valid bytes after this field

uint8_t hardwareVersion

7 on CE

uint8_t hardwareType

0 on TI84+CE, 1 on TI83PCE

uint8_t hardwareType2

9 on TI84+CE, 12 on TI83PCE

uint8_t osMajorVersion

e.g.

5 on OS 5.4.0.0034

uint8_t osMinorVersion

e.g.

4 on OS 5.4.0.0034

uint8_t osRevisionVersion

e.g.

0 on OS 5.4.0.0034

unsigned osBuildVersion

e.g.

34 on OS 5.4.0.0034

uint8_t bootMajorVersion

e.g.

5 on boot 5.3.6.0017

uint8_t bootMinorVersion

e.g.

3 on boot 5.3.6.0017

uint8_t bootRevisionVersion

e.g.

6 on boot 5.3.6.0017

unsigned bootBuildVersion

e.g.

17 on boot 5.3.6.0017

uint8_t unknown[10]

400100f0000010300000 on CE

uint8_t calcid[8]

From certificate

char ti[2]

First part of device name, “TI”

uint16_t language

Localization language