Hardware and Libndls: Difference between pages

From Hackspire
(Difference between pages)
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
Line 1: Line 1:
==Hardware revisions==
''libndls'' is a set of macros and functions available as a [https://en.wikipedia.org/wiki/Static_library static library] when building with Ndless. The library is automatically linked by <tt>nspire-gcc</tt> and <tt>nspire-g++</tt> without "-nostdlib".


===TI-Nspire (Clickpad) / Phoenix ===
These definitions are available in the latest version of the Ndless SDK and should work on every Ndless version.
<div style="overflow-x: auto">
{| class="wikitable" style="font-size: 0.8em"
! Variant / HW Revision !! Factory !! Datestamps !! MB code (PCB ID) !! board # !! LCD board code !! board # !! KB board code !! board # !! Other board !! board # !! Source (URL) !! Comment. (Note: many datestamps come from forums and other compilations) !!
|-
| PVT CAS+ ||  ||  ||  ||  || PH1_PVT_LCDB || 2430 ||  ||  ||  ||  || http://i.imgur.com/4hVUkaa.jpg ||  ||
|-
| <none> / pre-A || S || 0407-0707 || P2/P3 ASIC MB_MP || 6440 || P1R2/P3_LB_MP || 2440 ||  ||  ||  ||  || http://i.imgur.com/WGPf0LF.jpg || Some have an 'A' suffix to the left serial part: https://i.imgur.com/77oy8JT.jpg , https://i.imgur.com/K0aqUuW.jpg ; Also reported here: https://tiplanet.org/forum/viewtopic.php?f=17&t=4995 || Ph3-EVT1_FPC_1413
|-
| A || S || 0707-0907? ||  ||  ||  ||  ||  ||  ||  ||  ||  || http://www.publicsurplus.com/sms/auction/view?auc=1171896 for the associated viewscreen. (0607A would be seen for CAS devices) ||
|-
| A (other?) || K || 0509 ||  ||  ||  ||  ||  ||  ||  ||  ||  || http://i.ebayimg.com/images/g/j6kAAOSwgn5XEZ-a/s-l1600.jpg ||
|-
| B || S || 1207? ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://groups.google.com/forum/#!msg/tinspire/wwFr1zlFf0s/G2ePaXVXwOkJ ||
|-
| C || P || 0108-0308? ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| D || P || 0508 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| E || P || 0508-0708 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| F || P || 0708-0908? ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| G || P || 0409-0809 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| H || P || 0609 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| I || P || 0809?-1209 ||  ||  || N1/N3_LB_ ||  ||  ||  ||  ||  || http://i.imgur.com/RidWq1Z.jpg ||  ||
|-
|}
</div>


===TI-Nspire (Touchpad) / Phoenix (Nspire2.0)===
==Ndless==
<div style="overflow-x: auto">
*<tt>void assert_ndless_rev(unsigned required_rev)</tt>: Since v3.1 r617. Displays a popup asking to update Ndless if the Ndless revision on the calculator is less than ''required_rev'', and exits the program. Does nothing if the revision is greater or equal than ''required_rev''. You should call this function at the beginning of your program if it is using syscalls recently added to Ndless, or libndls functions which depend on recent syscalls. See [[Ndless_features_and_limitations#Checking Ndless's version|Checking Ndless version]] for more info. Note that this function works without v3.1 r617 or higher.
{| class="wikitable" style="font-size: 0.8em"
*<tt>const char *NDLESS_DIR</tt>: (since v3.1 r797) full path to the "ndless" directory in the documents folder ("/documents/ndless")
! Variant / HW Revision !! Factory !! Datestamps !! MB code (PCB ID) !! board # !! LCD board code !! board # !! KB board code !! board # !! Other board !! board # !! Source (URL) !! Comment. (Note: many datestamps come from forums and other compilations)
|-
| PROTO CAS ||  ||  || PCB TG2995C MB || 4400 ||  ||  ||  ||  ||  ||  || https://tiplanet.org/forum/viewtopic.php?t=14207 ||
|-
|  DVT CAS ||  ||  || N1 MB NKB || 4420 || N1/N3 LB PCR2 FPC || 2410 ||  ||  ||  ||  || https://tiplanet.org/forum/viewtopic.php?t=10964 ||
|-
| A || P || 0110-0310 || PCB TG2995D MB || 4430 || TG2995 C LB || 2410 ||  ||  ||  ||  || http://datamath.org/Graphing/JPEG_NSpire_CAS_TP.htm || What is https://i.imgur.com/04R7lYv.jpg ?
|-
| B || P || 0310-0710 || PCB TG2995D MB || 4430 || TG2995 C LB || 2410 ||  ||  ||  ||  || http://datamath.org/Graphing/JPEG_NSpire_TP_Y.htm || Found on a school edition (yellow)
|-
| C || P || 0710-1010 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| D || P || 0611-0711 ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://i.imgur.com/znF0jP3.jpg shows a datestamp
|-
| E || P || 0412 ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://i.imgur.com/73G6iBH.jpg shows a datestamp
|-
|}
</div>


===TI-Nspire CX / Firebird===
==LCD API==
*<tt>scr_type_t lcd_type()</tt>: Returns the native LCD type (see the list below). Using this is always the fastest way to display a frame.
*<tt>bool lcd_init(scr_type_t type)</tt>: Set the LCD mode. You need to call this before you can use lcd_blit with the same <tt>scr_type</tt>. You also need to call <tt>lcd_init(SCR_TYPE_INVALID)</tt> before using any of the functions in the UI section and before exiting the program.
*<tt>void lcd_blit(void* buffer, scr_type_t type)</tt>: Blit the buffer to the screen.


<div style="overflow-x: auto">
Available screen types (as of r2004):
{| class="wikitable" style="font-size: 0.8em"
*SCR_320x240_4: 4bit grayscale. Native on classic calcs.
! Variant / HW Revision !! Factory !! Datestamps !! MB code (PCB ID) !! board # !! LCD board code !! board # !! KB board code !! board # !! Other board !! board # !! Source (URL) !! Comment. (Note: many datestamps come from forums and other compilations)
*SCR_320x240_8: 8bit paletted mode.
|-
*SCR_320x240_16: RGB444
| Proto ("Nspire Color") ||  || 0810 || Firebird Color MB || 6412 ||  ||  || none ||  || Firebird Color BTB EVT || 2410 || https://tiplanet.org/forum/gallery/image_page.php?image_id=1691 ||
*SCR_320x240_565: RGB565. Native on CX before HW-W
|-
*SCR_240x320_565: RGB565. Native on CX HW-W
| <none> / pre-A ||  ||  || Firebird Color MB || 6421 ||  ||  ||  ||  ||  ||  || https://i.imgur.com/Y4yds6M.png ||
|-
| A || P || 0211?-0411 || Firebird Color MB || 6422 ||  ||  || Firebird (Noncas) Color KB EVT || 4421 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?image_id=1229 ||
|-
| B || P || 0411-0511 || Firebird Color MB || 6422 ||  ||  || Firebird (Noncas) Color KB EVT || 4421 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?image_id=2634 ||
|-
| C || P || 0511-0811? || Firebird Color MB || 6422 ||  ||  || Firebird (Noncas) Color KB EVT || 4421 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?image_id=1227 ||
|-
| D || P || 0911-0512 || Firebird Color MB || 6422 ||  ||  || Firebird (Noncas) Color KB EVT || 4421 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?image_id=2397 || https://i.imgur.com/OtnD7S3.jpg shows a datestamp. https://i.imgur.com/XEqIPUf.jpg is a CX-C CAS.
|-
| E || P || 0512-0612? ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://i.imgur.com/O3hLcQT.jpg shows a datestamp
|-
| F || P || 0712-0812? || Firebird Color MB || 6430 ||  ||  || Firebird (Noncas) Color KB EVT || 4421 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?image_id=2398 ||
|-
| G || P || 1012? ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://i.imgur.com/SNfyWQP.jpg shows a datestamp
|-
| H || P || 1112-0213 ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://i.imgur.com/yOmZY29.jpg shows a datestamp
|-
| I || P || 0213 ||  ||  ||  ||  ||  ||  ||  ||  ||  || Mention of the datestamp: https://www.omnimaga.org/general-calculator-help/hardware-needed-to-downgrade-3-2-4/msg360687/#msg360687
|-
| J ("CR") || P || 0313-0513? || NSC CR MB || 4440 ||  ||  || Firebird (non)cas Color KB DVT || 4424 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?album_id=184&image_id=2878 || incompatible with OS versions < 3.2.3 / Nlaunch + J04 connector removed
|-
| K || P || 0613-0713? ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| L || P || 1113?-1213 ||  ||  ||  ||  ||  ||  ||  ||  ||  || Datestamp from here: https://tiplanet.org/forum/viewtopic.php?p=170487#p170487
|-
| M || P || 1213-0114? ||  ||  ||  ||  ||  ||  ||  ||  ||  || Datestamp from here: https://tiplanet.org/forum/viewtopic.php?p=166933#p166933
|-
| N || P || 0314 || NSC SM MB || 4412 ||  ||  || Firebird (non)cas Color KB DVT || 4424 || Firebird Color BTB EVT1.2 || 2412 || https://tiplanet.org/forum/gallery/image_page.php?image_id=3697 ||
|-
| O ("CR II") || P || 0414-0614 || NSC SM MB || 4412 ||  ||  || NSC CELL (Non)CAS KB || 4410 || Firebird Color BTB || 2440 || https://tiplanet.org/forum/gallery/image_page.php?image_id=5469 || Samsung rechargeable battery. (Ref calc for France: N3/TBL/1E2/K)
|-
| P || P || 0614 || NSC SM MB || 4412 ||  ||  || NSC CELL (Non)CAS KB || 4410 || Firebird Color BTB || 2440 ||  ||
|-
| Q ? ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| R || P || 0814? ||  ||  ||  ||  ||  ||  ||  ||  ||  || Datestamp from http://www.cncalc.org/thread-11903-1-1.html
|-
| S || P || 0914-1014 ||  ||  ||  ||  ||  ||  ||  ||  ||  || https://i.imgur.com/zsYyaNC.jpg shows a datestamp
|-
| T ("CR III") || P || 1014-1214? || CX CRIII MB || 4412 ||  ||  || NSC CR OS (Non)CAS || 4413 || Firebird Color BTB || 2440 || https://tiplanet.org/forum/gallery/image_page.php?image_id=5472 || incompatible with OS versions < 3.9.1
|-
| U || P || 0115? ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| V || P || 0315-0815? || CX CRIII MB || 4412 ||  ||  || NSC CR OS (Non)CAS || 4413 || Firebird Color BTB || 2440 ||  ||
|-
| W ("CR IV") || P || 1115-0116 || CX CR IV MB || 4440 ||  ||  || <none> ||  || <none> ||  || https://tiplanet.org/forum/gallery/image_page.php?album_id=184&image_id=6823 || Now uses a unified motherboard, instead of 3 parts. New LCD + J04 connector back + incompatible versions < 4.0.1
|}
</div>


===TI-Nspire CM / Rabbit===
==UI==
*<tt>void show_msgbox(const char *title, const char *msg)</tt>: show a message box, with a single button OK"
*<tt>unsigned int show_msgbox_2b(const char *title, const char *msg, const char *button1, const char *button2)</tt>: since v3.1. show a message box with two buttons with custom labels. Return the number of the button pressed (1 for the first button).
*<tt>unsigned int show_msgbox_3b(const char *title, const char *msg, const char *button1, const char *button2, const char *button3)</tt>: since v3.1. show a message box with three buttons with custom labels. Return the number of the button pressed (1 for the first button).
*<tt>int show_msg_user_input(const char * title, const char * msg, char * defaultvalue, char ** value_ref)</tt>: since v3.1 r607. Request popup. Usage: <tt>char * value; show_msg_user_input("title", "msg", "default", &value)</tt>. <tt>value</tt> must be freed with <tt>free()</tt> once used. Returns the length of the value, or -1 if an empty text was entered or escape was pressed. Some issues fixed in r634 with the new String API.
*<tt>int show_1numeric_input(const char * title, const char * subtitle, const char * msg, int * value_ref, int min_value, int max_value)</tt>: since v3.1 r607. Request popup for one numeric input. Caution, values like -1 or 0 for ''min_value'' will cancel the popup. Returns 1 if OK, 0 if cancelled.
*<tt>int show_2numeric_input(const char * title, const char * subtitle, const char * msg1, int * value1_ref, int min_value1, int max_value1, const char * msg2, int * value2_ref, int min_value2, int max_value2)</tt>: since v3.1 r607. Request popup for two numeric inputs. Caution, values like -1 or 0 for ''min_value'' will cancel the popup. Returns 1 if OK, 0 if cancelled.
*<tt>void refresh_osscr(void)</tt>: since v3.1. Must be called at the end of a program that creates or deletes files, to update the OS document browser.


<div style="overflow-x: auto">
==Keyboard==
{| class="wikitable" style="font-size: 0.8em"
*<tt>BOOL any_key_pressed(void)</tt>: non-blocking key press test. Return <tt>TRUE</tt> if one or more keys are being pressed.
! Variant / HW Revision !! Factory !! Datestamps !! MB code (PCB ID) !! board # !! LCD board code !! board # !! KB board code !! board # !! Other board !! board # !! Source (URL) !! Comment. (Note: many datestamps come from forums and other compilations)
*<tt>BOOL isKeyPressed(key)</tt>: non-blocking key press test. <tt>key</tt> must be one of the <tt>KEY_NSPIRE_*</tt> constants defined in keys.h.
|-
*<tt>BOOL on_key_pressed(void)</tt>: since v3.1. Non-blocking ON key press test. Caution, key scanning is time consuming and may hurt the performance of programs which needs high reactivity. You should skip key scanning regularly in the main loop of a game.
| Chinese Language EVT1 ||  || <none> || RABBIT MB EVT || 4410 ||  ||  || RABBIT KB (NON ) CAS EVT || 2416 ||  ||  || https://tiplanet.org/forum/gallery/image_page.php?image_id=2658 ||
*<tt>void wait_key_pressed(void)</tt>: block until a key is pressed. Changing the timer frequency have effects on the latency of this function.
|-
*<tt>void wait_no_key_pressed(void)</tt>: block until all the keys are released. Changing the timer frequency have effects on the latency of this function.
| CM-C EVT1 ||  || (103) ||  ||  ||  ||  || RABBIT KB (NON) CAS EVT || 2419 ||  ||  || https://tiplanet.org/forum/gallery/image_page.php?album_id=193&image_id=2761 ||
*<tt>touchpad_info_t *touchpad_getinfo(void)</tt>: return information on the Touchpad area such as its dimension. Return <tt>NULL</tt> if not a TI-Nspire Touchpad. See <tt>include/libndls.h</tt> for the definition of <tt>touchpad_info_t</tt>.
|-
*<tt>int touchpad_scan(touchpad_report_t *report)</tt>: check user interactions with the Touchpad area and writes to <tt>report</tt>. See <tt>include/libndls.h</tt> for the definition of <tt>touchpad_report_t</tt>. <tt>report->contact</tt> and <tt>report->pressed</tt> are always <tt>FALSE</tt> on TI-Nspire Clickpad. See <tt>src/arm/tests/ndless_tpad.c</tt> for an example of use.
| CM-C CAS DVT1 ||  || (240) || RABBIT MB EVT || 4415 ||  ||  || RABBIT KB (NON) CAS EVT || 4411 ||  ||  || https://tiplanet.org/forum/gallery/image_page.php?album_id=1&image_id=6294 ||
*<tt>int get_event(struct s_ns_event*)</tt>: since r721. Poll for an OS event. See <tt>struct s_ns_event</tt> in nucleus.h.
|-
*<tt>void send_key_event(struct s_ns_event* eventbuf, unsigned short keycode_asciicode, BOOL is_key_up, BOOL unknown)</tt>: since r721. Simulate a key event.
| CM-C || P || 0911 || RABBIT MB DVT || 6420 ||  ||  || RABBIT KB (NON) CAS EVT || 4420 ||  ||  || https://tiplanet.org/forum/gallery/image_page.php?album_id=119&image_id=1359 ||
*<tt>void send_click_event(struct s_ns_event* eventbuf, unsigned short keycode_asciicode, BOOL is_key_up, BOOL unknown)</tt>: since r750. Simulate a click event. keycode_asciicode=0xFB00: single click, keycode_asciicode=0xAC00: drag.
|-
*<tt>void send_pad_event(struct s_ns_event* eventbuf, unsigned short keycode_asciicode, BOOL is_key_up, BOOL unknown)</tt>: since r750. Simulate a cursor move. Set the cursor coordinates in eventbuf, and keycode_asciicode to 0x7F00.
| CM-C (CAS) No-rev -> A || P || 0412-0512 || RABBIT MB DVT || 6420 ||  ||  || RABBIT KB (NON) CAS EVT || 4411 ||  ||  || https://tiplanet.org/forum/gallery/image_page.php?album_id=180&image_id=2596 || https://i.imgur.com/J3cJBcI.jpg shows a 0512 datestamp
|-
|}
</div>


==PCB==
==Filesystem==
High resolution photos can be found in the above table.
<tt>int enable_relative_paths(char **argv)</tt>: since r820. Call before using <tt>fopen()</tt> and other file-related functions with paths relative to the current program. <tt>argv</tt> should be the <tt>argv</tt> parameter of the <tt>main()</tt> function. Returns -1 on error, 0 if success.
 
===Connector J04===
As can be seen in the PCB photos, there are empty pads for a connector labelled "J04" (not on some CR models). Most likely this is for debugging using an interface such as JTAG.
 
Analyzation of the signals on the pins provided the following information regarding signal types.
 
"GND" means signal ground, it has the same potential as the whole ground plane on the PCBs. The minus pole of one battery is directly connected to it.
"Vcc 3.3V" means the 3.3V power supply of the calculator. It seems to be present even if the calculator is off.
"Floating" is a signal with an undefined voltage level, this state is very likely for inputs.
"High" is a signal with almost 3.3V, but not a supply signal. These signals are probably inputs with pull-up resistors (they can be pulled-down with a large value resistor).
 
{| class="wikitable"
| GND
| 1
| 2
| GND
|-
| Vcc 3.3V
| 3
| 4
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| High
| 5
| 6
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| High
| 7
| 8
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| Floating
| 9
| 10
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| GND
| 11
| 12
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| GND
| 13
| 14
| GND
|-
| Floating
| 15
| 16
| Floating
|-
| Floating
| 17
| 18
| GND
|-
| Floating
| 19
| 20
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| Floating
| 21
| 22
| Square-wave: 112Hz, 99% duty-cycle, not present if the calc is off
|-
| Floating
| 23
| 24
| RS232 Output (115'200,8,n,1)
|-
| Floating
| 25
| 26
| RS232 Input
|-
| GND
| 27
| 28
| GND
|-
| GND
| 29
| 30
| GND
|}
 
'''TODO:''' Double-check the results and find out, what these signals (Floating, High, Square-wave) really are. Maybe, there are common interfaces as JTAG, I2C or whatever.
 
===Connector J01 - Dock connector===
Pins currently known, probably there are more GPIOs accessible. Somewhere there's SPI, too.
 
{| class="wikitable"
|-
| Vcc || pin 2
|-
| Rx || pin 3
|-
| Tx || pin 4
|-
| GND || pin 5 (long)
|-
| GPIO4 / USB Data+ with Navigator Cradle || pin 6
|-
| USB Data- with Navigator Cradle || pin 7
|-
| Vin || pin 8 (medium)
|-
| GPIO0 || pin 17
|-
| GPIO22 || pin 18
|-
| Vin || pin 19 (medium)
|-
| GND || pin 22 (long)
|}
 
===UART===
A serial adapter can be connected to the Tx/Rx/GND pins of the dock connector (pin 1 is the one at the left-hand side, TI-Nspire upside down, connector at the bottom). '''Warning: only use TTL voltage levels, never RS232 levels'''.
 
The configuration of the terminal on the computer side should be:
{| class="wikitable"
|-
| Baud rate || 115200
|-
| Data || 8 bit
|-
| Parity || none
|-
| Stop || 1 bit
|-
| Flow control || none
|}
 
While starting up, the calculator sends some logging information through the interface. A log (including deletion and reprogramming the OS) can be found [http://hackspire.unsads.com/files/log-philippburch-serial-boot.txt here]).
 
Different types of files can be send with the X-Modem protocol, depending on the boot startup options chosen with the [[Operating_System#Startup_key_combinaisons|key combos]]. Windows HyperTerminal or TeraTerm strangely couldn't be used for the X-Modem transfer. [http://www.ohse.de/uwe/software/lrzsz.html lrzsz] is a better alternative, which can be built on Windows with Cygwin.
stty -F /dev/ttyS0 115200 -evenp -cstopb
cat < /dev/ttyS0
# Abort with Ctrl+C when the X-Modem transfer begins
# The `cat` is used to show the startup logs during reboot
./lsz -X boot2.img <> /dev/ttyS0 >&0; cat /dev/ttyS0
 
===Power supply===
You can use the TI-Nspire with an external power supply (5V to 6V) instead of the batteries. Use pad P1, pin 8 or pin 19 for V+ and pad P2, pin 5 or pin 22 for GND. It will boot, but print "Critical voltage detected. Forcing shutdown." on RS232 and shutdown. It seems that the battery voltage of measured using only 2 batteries. A workaround is to use two resistors (100K work) to set the middle point at half voltage.
 
==Screen==
 
{| class="wikitable"
|-
! Device !! Screen !! Controller !! Notes
|-
| TI-Nspire Clickpad/Touchpad || 320x240 - 4 bit greyscale LCD || [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0161e/index.html ARM PrimeCell PL110] ||
|-
| TI-Nspire CX (before rev W)|| 320x240 - 16 bit color LCD || [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0293c/index.html ARM PrimeCell PL111] ||
|-
| TI-Nspire CX (from rev W)|| 240x320 - 16 bit color LCD || Same as previous? || LCD is rotated
|}


==CPU==
==CPU==
*<tt>void clear_cache(void)</tt>: flush the data cache and invalidate the instruction and data caches of the processor. Should be called before loading code dynamically, after a code patch or with self-modifying code.


CPU is an [http://www.arm.com/products/CPUs/ARM926EJ-S.html ARM926EJ-S] with ARM9 instruction set ([http://infocenter.arm.com/help/topic/com.arm.doc.ddi0198e/index.html Reference manual]), 16KB of instruction cache, 8KB of data cache.
==Hardware==
 
*<tt>BOOL is_classic</tt>: since v3.1. <tt>TRUE</tt> on classic TI-Nspire. This is the preferred way to check CX/CM-specific features: ''if (is_classic) classic_code; else cx_code;''
{| class="wikitable"
*<tt>BOOL is_cm</tt>: since v3.1 r863. <tt>TRUE</tt> on TI-Nspire CM/CM-C.
|-
*<tt>BOOL has_colors</tt>: since v3.1. <tt>TRUE</tt> if the device has a screen in color.
! Device !! Chip !! Technology !! Notes
*<tt>BOOL is_touchpad</tt>: <tt>TRUE</tt> on a TI-Nspire Touchpad or on a TI-Nspire CX.
|-
*<tt>unsigned hwtype()</tt>: 0 on classic TI-Nspire, 1 on TI-Nspire CX.
| TI-Nspire Clickpad || Texas Instruments TI-NS2006A || Zevio LSI || [http://microblog.routed.net/2008/08/15/ic-friday-tis-nspire/ Die photos]
*<tt>IO()</tt>: select an I/O port whose mapping depends on the hardware type. Fo example <tt>IO(0xDC00000C, 0xDC0000010)</tt> will return 0xDC00000C on classic TI-Nspire, 0xDC0000010 on CX. Returns a ''volatile unsigned*''.
|-
| TI-Nspire Touchpad || Texas Instruments TI-NS2007C Magnum || Zevio LSI ||
|-
| TI-Nspire COLOR || Texas Instruments ET-NS2010A || Toshiba ASIC ||
|-
| TI-Nspire CX || Texas Instruments ET-NS2010B || Toshiba ASIC ||
|-
| TI-Nspire CM || Texas Instruments ET-LC2010B || Toshiba ASIC || Some research should be done to find differences with CX SOC
|}
 
==SDRAM==
 
{| class="wikitable"
|-
! Device !! Chip !! Size !! Notes
|-
| TI-Nspire Clickpad || QIMONDA HYB18L256160 || 32MiB (16Mb x 16) ||
|-
| TI-Nspire Touchpad || MT48H16M16 || 32MiB (16Mb x 16) ||
|-
| TI-Nspire CX (before rev J) || Samsung K511F12ACA-B075 || 64MiB|| K511F12ACA is a multipart package, shared with NAND Flash-ROM
|-
| TI-Nspire CX (from rev J) || ESMT FM60D1G12A 6BE || 64MiB || FM60D1G12A is a multipart package, shared with NAND Flash-ROM
|-
| TI-Nspire CM || Samsung K511F5ACC-B075 || 32MiB || K511F5ACC is a multipart package, shared with NAND Flash-ROM
|}
 
Some more research has to be done here, regarding what the SOC exactly contains + external in all revisions.
 
==NAND memory==
 
Used for Boot2, Diag, OS and user filesystem.
 
{| class="wikitable"
|-
! Device !! Chip !! Size !! Notes
|-
| TI-Nspire Clickpad || ST NAND256R3A || 32MiB ||
|-
| TI-Nspire Touchpad || Samsung SEC K9F5608 || 32MiB ||
|-
| TI-Nspire CX (before rev J) || Samsung K511F12ACA-B075 || 128MiB || K511F12ACA is a multipart package, shared with SDRAM
|-
| TI-Nspire CX (from rev J) || ESMT FM60D1G12A 6BE || 128MiB || FM60D1G12A is a multipart package, shared with SDRAM
|-
| TI-Nspire CM || Samsung K511F5ACC-B075 || 128MiB || K511F5ACC is a multipart package, shared with SDRAM
|}
 
Notes: The memory does not support "Execute In Place" (XIP). If executable code is contained in this memory, it has to be copied in RAM first.


==NOR ROM==
==Time==
*<tt>void idle(void)</tt>: switch to low-power state until the next interrupt occurs. The use of this function is encouraged when waiting in loops for an event to save the batteries.  Changing the timer frequency have effects on the latency of this function.
*<tt>void msleep(unsigned ms)</tt>: delay for a specified amount of time in ms. The CPU is regularly switched to low-power state while blocking. Note that the <tt>sleep</tt> function has been removed.


Used for boot1 and certificate memory.
==Configuration==
*<tt>void cfg_register_fileext(const char *ext, const char *prgm)</tt>: (since v3.1 r797) associate for Ndless the file extension <tt>ext</tt> (without leading '.') to the program name <tt>prgm</tt>. Does nothing if the extension is already registered.


{| class="wikitable"
==Debugging==
|-
*<tt>void bkpt()</tt>: software breakpoint. Make the emulator halt and open the debugger. Remove before transferring to a calculator, as it will crash if executed.
! Device !! Chip !! Size !! Notes
|-
| TI-Nspire Clickpad || SST 39WF400A || 512KB ||
|-
| TI-Nspire Touchpad || Internal || ??KB ||
|-
| TI-Nspire COLOR || Macronix MX29SL402 || 512KB || Prototype
|-
| TI-Nspire CX || Internal || ??KB ||
|-
| TI-Nspire CX rev W || Macronix MX29SL402 || 512KB || Probably added so that they could include a new boot1 that can handle the new board design / LCD
|-
| TI-Nspire CM || Internal || ??KB ||
|}


==Other==
==Deprecated==
===Real-Time Clock===
===Common types===
The clock is correctly emulated in the [[TI-84 Plus Emulation|TI-84 Plus mode]] of the TI-Nspire. Although the TI-Nspire OS doesn't display any clock as the TI-89 Titanium and the TI-84 Plus do, the TI-Nspire keeps track of time when the TI-84 Plus keypad is replaced by the TI-Nspire keypad, and then put back. We can be quite sure there is an[http://en.wikipedia.org/wiki/Real-time_clock RTC] inside. It is also interesting to mention the XML tags ''dfmt'' (date format) and ''tfmt'' (time format) set to 1 in the factory settings (''phoenix/syst/locales/en/settings/factory.zip/settings.xml'' of the [[OS_upgrade_files#Compressed_file_system|compressed file system]]) in the OS file of both the TI-Nspire and the TI-Nspire CAS. These two parameters don't appear in the system settings dialog of the TI-Nspire OS, as it is the case for the tags ''curr'' and ''unit'' of ''settings.xml''.
Deprecated. Use #include <stdbool.h> instead.
<tt>typedef enum bool {FALSE = 0, TRUE = 1} BOOL;</tt>


===MMU===
===Old screen API===
The [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0198e/Babfdfbh.html ARM926EJ-S] integrated [http://en.wikipedia.org/wiki/Memory_management_unit Memory Management Unit] is enabled, but seems to only be used to map NOR, RAM and peripherals in memory space, and control the cache settings : [[Virtual Memory]].
The following section is only valid if using the OLD_SCREEN_API define.


==More information==
*<tt>SCREEN_BASE_ADDRESS</tt>: address of the screen buffer. Read from the LCD controller, caching it is recommended.
*The [http://www.datamath.org/Graphing/NSpire.htm TI-Nspire] and [http://www.datamath.org/Graphing/NSpire_CAS.htm TI-Nspire CAS] in Datamath Calculator Museum
*<tt>SCREEN_BYTES_SIZE</tt>: size of the screen buffer. Calculated depending on the color mode advertised by the LCD controller, caching it is recommended as long as the mode isn't changed.
*<tt>SCREEN_WIDTH</tt>: screen width in pixels
*<tt>SCREEN_HEIGHT</tt>: screen height in pixels
*<tt>void clrscr(void)</tt>: clear the screen
*<tt>BOOL lcd_isincolor(void)</tt>: since v3.1. Check the current LCD mode.
*<tt>void lcd_incolor(void)</tt>: since v3.1. Switch to color LCD mode.
*<tt>void lcd_ingray(void)</tt>: since v3.1. Switch to grayscale LCD mode.
*<tt>volatile unsigned *IO_LCD_CONTROL</tt>: since v3.1. LCD control register of the LCD controller

Latest revision as of 14:36, 21 June 2019

libndls is a set of macros and functions available as a static library when building with Ndless. The library is automatically linked by nspire-gcc and nspire-g++ without "-nostdlib".

These definitions are available in the latest version of the Ndless SDK and should work on every Ndless version.

Ndless

  • void assert_ndless_rev(unsigned required_rev): Since v3.1 r617. Displays a popup asking to update Ndless if the Ndless revision on the calculator is less than required_rev, and exits the program. Does nothing if the revision is greater or equal than required_rev. You should call this function at the beginning of your program if it is using syscalls recently added to Ndless, or libndls functions which depend on recent syscalls. See Checking Ndless version for more info. Note that this function works without v3.1 r617 or higher.
  • const char *NDLESS_DIR: (since v3.1 r797) full path to the "ndless" directory in the documents folder ("/documents/ndless")

LCD API

  • scr_type_t lcd_type(): Returns the native LCD type (see the list below). Using this is always the fastest way to display a frame.
  • bool lcd_init(scr_type_t type): Set the LCD mode. You need to call this before you can use lcd_blit with the same scr_type. You also need to call lcd_init(SCR_TYPE_INVALID) before using any of the functions in the UI section and before exiting the program.
  • void lcd_blit(void* buffer, scr_type_t type): Blit the buffer to the screen.

Available screen types (as of r2004):

  • SCR_320x240_4: 4bit grayscale. Native on classic calcs.
  • SCR_320x240_8: 8bit paletted mode.
  • SCR_320x240_16: RGB444
  • SCR_320x240_565: RGB565. Native on CX before HW-W
  • SCR_240x320_565: RGB565. Native on CX HW-W

UI

  • void show_msgbox(const char *title, const char *msg): show a message box, with a single button OK"
  • unsigned int show_msgbox_2b(const char *title, const char *msg, const char *button1, const char *button2): since v3.1. show a message box with two buttons with custom labels. Return the number of the button pressed (1 for the first button).
  • unsigned int show_msgbox_3b(const char *title, const char *msg, const char *button1, const char *button2, const char *button3): since v3.1. show a message box with three buttons with custom labels. Return the number of the button pressed (1 for the first button).
  • int show_msg_user_input(const char * title, const char * msg, char * defaultvalue, char ** value_ref): since v3.1 r607. Request popup. Usage: char * value; show_msg_user_input("title", "msg", "default", &value). value must be freed with free() once used. Returns the length of the value, or -1 if an empty text was entered or escape was pressed. Some issues fixed in r634 with the new String API.
  • int show_1numeric_input(const char * title, const char * subtitle, const char * msg, int * value_ref, int min_value, int max_value): since v3.1 r607. Request popup for one numeric input. Caution, values like -1 or 0 for min_value will cancel the popup. Returns 1 if OK, 0 if cancelled.
  • int show_2numeric_input(const char * title, const char * subtitle, const char * msg1, int * value1_ref, int min_value1, int max_value1, const char * msg2, int * value2_ref, int min_value2, int max_value2): since v3.1 r607. Request popup for two numeric inputs. Caution, values like -1 or 0 for min_value will cancel the popup. Returns 1 if OK, 0 if cancelled.
  • void refresh_osscr(void): since v3.1. Must be called at the end of a program that creates or deletes files, to update the OS document browser.

Keyboard

  • BOOL any_key_pressed(void): non-blocking key press test. Return TRUE if one or more keys are being pressed.
  • BOOL isKeyPressed(key): non-blocking key press test. key must be one of the KEY_NSPIRE_* constants defined in keys.h.
  • BOOL on_key_pressed(void): since v3.1. Non-blocking ON key press test. Caution, key scanning is time consuming and may hurt the performance of programs which needs high reactivity. You should skip key scanning regularly in the main loop of a game.
  • void wait_key_pressed(void): block until a key is pressed. Changing the timer frequency have effects on the latency of this function.
  • void wait_no_key_pressed(void): block until all the keys are released. Changing the timer frequency have effects on the latency of this function.
  • touchpad_info_t *touchpad_getinfo(void): return information on the Touchpad area such as its dimension. Return NULL if not a TI-Nspire Touchpad. See include/libndls.h for the definition of touchpad_info_t.
  • int touchpad_scan(touchpad_report_t *report): check user interactions with the Touchpad area and writes to report. See include/libndls.h for the definition of touchpad_report_t. report->contact and report->pressed are always FALSE on TI-Nspire Clickpad. See src/arm/tests/ndless_tpad.c for an example of use.
  • int get_event(struct s_ns_event*): since r721. Poll for an OS event. See struct s_ns_event in nucleus.h.
  • void send_key_event(struct s_ns_event* eventbuf, unsigned short keycode_asciicode, BOOL is_key_up, BOOL unknown): since r721. Simulate a key event.
  • void send_click_event(struct s_ns_event* eventbuf, unsigned short keycode_asciicode, BOOL is_key_up, BOOL unknown): since r750. Simulate a click event. keycode_asciicode=0xFB00: single click, keycode_asciicode=0xAC00: drag.
  • void send_pad_event(struct s_ns_event* eventbuf, unsigned short keycode_asciicode, BOOL is_key_up, BOOL unknown): since r750. Simulate a cursor move. Set the cursor coordinates in eventbuf, and keycode_asciicode to 0x7F00.

Filesystem

int enable_relative_paths(char **argv): since r820. Call before using fopen() and other file-related functions with paths relative to the current program. argv should be the argv parameter of the main() function. Returns -1 on error, 0 if success.

CPU

  • void clear_cache(void): flush the data cache and invalidate the instruction and data caches of the processor. Should be called before loading code dynamically, after a code patch or with self-modifying code.

Hardware

  • BOOL is_classic: since v3.1. TRUE on classic TI-Nspire. This is the preferred way to check CX/CM-specific features: if (is_classic) classic_code; else cx_code;
  • BOOL is_cm: since v3.1 r863. TRUE on TI-Nspire CM/CM-C.
  • BOOL has_colors: since v3.1. TRUE if the device has a screen in color.
  • BOOL is_touchpad: TRUE on a TI-Nspire Touchpad or on a TI-Nspire CX.
  • unsigned hwtype(): 0 on classic TI-Nspire, 1 on TI-Nspire CX.
  • IO(): select an I/O port whose mapping depends on the hardware type. Fo example IO(0xDC00000C, 0xDC0000010) will return 0xDC00000C on classic TI-Nspire, 0xDC0000010 on CX. Returns a volatile unsigned*.

Time

  • void idle(void): switch to low-power state until the next interrupt occurs. The use of this function is encouraged when waiting in loops for an event to save the batteries. Changing the timer frequency have effects on the latency of this function.
  • void msleep(unsigned ms): delay for a specified amount of time in ms. The CPU is regularly switched to low-power state while blocking. Note that the sleep function has been removed.

Configuration

  • void cfg_register_fileext(const char *ext, const char *prgm): (since v3.1 r797) associate for Ndless the file extension ext (without leading '.') to the program name prgm. Does nothing if the extension is already registered.

Debugging

  • void bkpt(): software breakpoint. Make the emulator halt and open the debugger. Remove before transferring to a calculator, as it will crash if executed.

Deprecated

Common types

Deprecated. Use #include <stdbool.h> instead. typedef enum bool {FALSE = 0, TRUE = 1} BOOL;

Old screen API

The following section is only valid if using the OLD_SCREEN_API define.

  • SCREEN_BASE_ADDRESS: address of the screen buffer. Read from the LCD controller, caching it is recommended.
  • SCREEN_BYTES_SIZE: size of the screen buffer. Calculated depending on the color mode advertised by the LCD controller, caching it is recommended as long as the mode isn't changed.
  • SCREEN_WIDTH: screen width in pixels
  • SCREEN_HEIGHT: screen height in pixels
  • void clrscr(void): clear the screen
  • BOOL lcd_isincolor(void): since v3.1. Check the current LCD mode.
  • void lcd_incolor(void): since v3.1. Switch to color LCD mode.
  • void lcd_ingray(void): since v3.1. Switch to grayscale LCD mode.
  • volatile unsigned *IO_LCD_CONTROL: since v3.1. LCD control register of the LCD controller