# The SPI devices (firmware flash, touchscreen, power management), the RTC and wireless Source: GBATEK "DS Serial Peripheral Interface Bus (SPI)", "DS Touch Screen Controller (TSC)", "DS Power Management Device", "DS Real-Time Clock (RTC)", "DS Firmware Serial Flash Memory", "DS Firmware Header", "DS Firmware User Settings", "DS Wireless Communications". DOC unless marked. All of these hang off the ARM7. ## The SPI bus (ARM7 SPICNT 40001C0h, SPIDATA 40001C2h) One bus, three chip selects (device select bits 8-9: 0 power management, 1 firmware, 2 touchscreen), baud rate 4 MHz / 2 MHz / 1 MHz / 512 kHz, an 8-bit (or "bugged" 16-bit) transfer started by writing SPIDATA, a busy flag, an optional IRQ (IF bit 23), and a chip-select hold bit for multi-byte commands. A transfer's busy time follows from the baud rate (8 bits at the chosen clock): the board models it so software polling the busy bit sees the right duration. The cartridge's save chip is on a **separate** SPI bus (cartridge.md). ## Firmware flash - ST M45PE20 (256 KB, DS), M35PE20 (DS Lite), M25PE40 (512 KB, iQue); commands WREN, WRDI, RDID, RDSR, READ, FAST, PW (page write) and the program, erase and power-down commands of GBATEK's list. - Contents: a header (with the KEY1-encrypted, LZ77-compressed ARM9 and ARM7 boot code of the firmware, its "MACP" id code), Wi-Fi settings and calibration, three access points, and **two user-settings copies** (nickname, birthday, language, touchscreen calibration, favourite colour, alarm) with a counter and CRC choosing the newer. - Each console's firmware differs (MAC, calibration, user settings): no two dumps in the census match except where No-Intro lists factory images (census.md). - The board needs the player's firmware image for a firmware boot, or a synthesised one (user settings, calibration and MAC filled in, no boot code) for a direct boot (Open decision in handoff-brief.md). ## Touchscreen controller Texas Instruments TSC2046 (DS), AKM AK4148AVT (DS Lite): a control byte selects a channel (temperature 0/1, X, Y, Z1, Z2, battery (grounded on the DS), AUX = microphone) and 8- or 12-bit conversion; the result is clocked out over the next two bytes. Pen-down raises /PENIRQ, visible in EXTKEYIN bit 6 (whether it raises an IRQ: GBATEK doubts it, U1). The firmware's calibration points map ADC values to pixels; games read raw values and apply the calibration themselves. ## Power management Mitsumi 3152A (DS), 3205B (DS Lite): an index register then a data byte; register 0: amplifier, (DS) amplifier mute, backlights top and bottom, power LED, system power off; power LED blink; register 1: battery low; register 2: microphone amplifier enable; register 3: microphone gain (20/40/80/160); register 4 (DS Lite): backlight levels, external power present. The DS Lite's differences are a model row. ## Real-time clock Seiko S-35180 (compatible with S-35190A), 3-wire serial through ARM7 4000138h (bit-banged data, clock, select, with direction bits). Registers: status 1 and 2, date and time (BCD), alarms/interrupts (FOUT frequencies, per-minute steady interrupt), clock adjustment, free register. The RTC's interrupt reaches the ARM7 as IF bit 7. gba-python's cartridge RTC is a different Seiko part (S-3511A) with a different interface: nothing to share at code level (chip rule). ## Wireless (late) A wireless controller with a baseband chip (Mitsumi MM3155) and an RF chip (RF9008) on the DS, one BB/RF chip (MM3218) on the DS Lite (GBATEK "DS Wifi Baseband Chip (BB)"): 8 KB RAM at 04804000h, registers at 04808000h, its own IRQ, multiplayer (DS Download Play, Nintendo's beacons) and IEEE 802.11b. GBATEK documents it in depth (some 3,700 lines). **Proposal: out of scope until late**: a board that ignores wireless must still answer the registers the firmware and games poll at boot (W_ID, power-down registers) with the values GBATEK gives, so software proceeds as on a console with no network in reach. ## Unknowns (U) - U1 Whether /PENIRQ raises an interrupt on the DS. - U2 TSC conversion timing (how long after the control byte a result is valid). - U3 The firmware flash's busy times for page program and erase (data sheet values: the ST M45PE20 data sheet is not pinned yet). - U4 What games see from the wireless registers on a console with the radio powered but no partner, beyond the boot-time reads.