JN RM 2001 Integrated Peripherals API 2v0
JN RM 2001 Integrated Peripherals API 2v0
JN RM 2001 Integrated Peripherals API 2v0
JN-RM-2001
Revision 2.0
13-Feb-2007
Jennic
Disclaimer
The contents of this document are subject to change without notice. Customers are advised to consult with JENNIC commercial representatives before
ordering.
The information and circuit diagrams in this document are presented as examples of semiconductor device applications, and are not intended for
incorporation in devices for actual use. Also, JENNIC is unable to assume responsibility for infringement of any patent rights or other rights of third
parties arising from the use of this information or circuit diagrams.
No license is granted by its implication or otherwise under any patent or patent rights of JENNIC Ltd
“Typical” parameters that are provided in this document may vary in different applications and performance may vary over time. All operating
parameters must be validated for each customer application by the customer’s own technical experts.
CAUTION:
Customers considering the use of our products in special applications where failure or abnormal
operation may directly affect human lives or cause physical injury or property damage, or where
extremely high levels of reliability are demanded (such as aerospace systems, atomic energy
controls, vehicle operating controls, medical devices for life support, etc.) are requested to
consult with JENNIC representatives before such use. JENNIC customers using or selling
products incorporating JENNIC IP for use in such applications do so at their own risk and agree
to fully indemnify JENNIC for any damages resulting from such improper use or sale.
Organisation
This document consists of two chapters.
• Chapter 1 gives a brief overview of the scope of the manual
• Chapter 2 describes in detail the calls available to control each feature of the device
Conventions
Code fragments or function prototypes are represented by Courier typeface. When referring
to constants or functions defined in the code they are emboldened, like so.
2.1 General
2.1.1 u32AHI_Init
Declaration PUBLIC uint32 u32AHI_Init(void);
Inputs None
Outputs 0 if initialisation failed, otherwise a 32-bit version number (most significant 16 bits
are main revision, least significant 16 bits are minor revision)
Description Used to initialise the AHI. This should be called after every reset or wake-up and
before any other AHI calls are made. Note that the application API should have
been initialised before this function is called, and the call to initialise the
application API includes a parameter to register a function to call whenever an
interrupt from the peripherals occurs, see following section for details.
The item bitmap, u32ItemBitmap, has a bit set for each individual interrupt source within the
peripheral, as described in the tables below.
Before calling the callback function, the library clears the source of the interrupt, so there is no
danger of the same interrupt causing the processor to enter a state of permanently trying to
handle the same interrupt due to a malformed callback function. This also means that it is
possible to have a NULL callback function.
The UARTs are the exception to this rule; when generating a ‘receive data available’ or ‘timeout
indication’ interrupt, the UARTs will only clear the interrupt when the data is read from the UART
receive buffer. It is therefore vital that if UART interrupts are to be enabled, the callback
function handles the ‘receive data available’ and ‘timeout indication’ interrupts by reading the
data from the UART before returning.
Note that if the Application Queue API is being used, the issue with UART interrupts is handled
by the API, so the application does not have to cope with it. See [3] for more information about
the Application Queue API.
The item bitmaps are defined as follows:
TickTimer
Mask (Bit) Description
0 Single source for Tick Timer interrupt, therefore returns 1 every time
System Controller
Mask (Bit) Description
E_AHI_SYSCTRL_COMP_MASK (29) Comparator events
E_AHI_SYSCTRL_WK1_MASK (27) Wake Timer events
E_AHI_SYSCTRL_WK0_MASK (26)
E_AHI_DIO20_INT (20) Digital IO events
E_AHI_DIO19_INT (19)
E_AHI_DIO18_INT (18)
.
.
E_AHI_DIO0_INT (0)
SPI Master
Mask (Bit) Description
E_AHI_SPIM_TX_MASK (1) Asserted to indicate transfer has completed
Intelligent Peripheral
Mask (Bit) Description
E_AHI_IP_INT_STATUS_MASK (6) Asserted to indicate transaction has completed, i.e slave select goes high
and TXGO or RXGO has gone low
E_AHI_IP_TXGO_MASK (1) Asserted when TX data is copied to the internal buffer and cleared when it
has been sent out.
E_AHI_IP_RXGO_MASK (0) Asserted when device is ready to receive state and cleared when data RX
is complete.
Analogue Peripherals
Mask (Bit) Description
E_AHI_AP_INT_STATUS_MASK (0) Asserted to indicate capture complete or new sample ready
2.3.1 u8AHI_PowerStatus
Declaration PUBLIC uint8 u8AHI_PowerStatus(void);
Inputs None
Outputs uint8 containing power domain control settings
bit 0: 1 if chip has completed a sleep-wake up cycle
bit 1: If 1 after wake up, memory contents were retained during sleep
bit 2: 1 if analogue power domain is switched on
bit 3: 1 if protocol power domain is switched on
Description Returns the power domain settings for the JN5121/JN513x, as described above.
Outputs None
Description Determines whether the memory will remain powered during the next sleep
period.
2.3.3 vAHI_CpuDoze
Declaration PUBLIC void vAHI_CpuDoze(void);
Inputs None
Outputs None
Description Causes the CPU to stop operating until an interrupt occurs. The CPU clock will be
disabled during sleep to minimise power consumption, although other modules will
still be operational. The function returns when the CPU re-starts.
2.3.4 vAHI_PowerDown
Declaration PUBLIC void vAHI_PowerDown(bool_t bDeepNotNormalSleep);
Inputs bool_t TRUE for the sleep to be deep sleep (device only
bDeepNotNormalSleep awakes through a reset)
FALSE for normal sleep (device wakes after
interrupt or reset)
Outputs None
Description Sends the device to sleep. In normal sleep mode, all parts of the device are
inactive or powered down apart from the 32 kHz oscillator and those parts of the
system controller used for wake up. In deep sleep, even these are powered
down. This function does not return. When the device restarts, it will begin
processing at the reset vector.
2.3.6 vAHI_ProtocolPower
Declaration PUBLIC void vAHI_ProtocolPower(bool_t bOnNotOff);
Inputs bool_t bOnNotOff TRUE to turn the protocol power domain on.
FASLE to turn the protocol power domain off.
Outputs None
Description Control the regulator that supplies the protocol domain (the radio, modem
baseband and encryption coprocessor).
Outputs None
Description Registers an application callback that will be called when the system control
interrupt (caused by wake timer, comparator and DIO events) is triggered.
2.3.12 vAHI_SwReset
Declaration PUBLIC void vAHI_SwReset (void);
Inputs None
Outputs None
Description Generates an internal reset when called, which completely re-starts the system.
2.4.1 vAHI_WakeTimerEnable
Declaration PUBLIC void vAHI_WakeTimerEnable(uint8 u8Timer,
bool_t bIntEnable);
2.4.2 vAHI_WakeTimerStart
Declaration PUBLIC void vAHI_WakeTimerStart(uint8 u8Timer, uint32 u32Count);
2.4.3 vAHI_WakeTimerStop
Declaration PUBLIC void vAHI_WakeTimerStop(uint8 u8Timer);
Inputs None
Outputs uint8 Bitmap:
Returned value logical ANDed with E_AHI_WAKE_TIMER_MASK_0 will be
non-zero if wake timer 0 is running
Returned value logical ANDed with E_AHI_WAKE_TIMER_MASK_1 will be
non-zero if wake timer 1 is running
Description Returns a bitmap where the relevant bits are set to show which timers are active.
It is possible to have more than one timer active at once. Note that a timer remains
active after the timed interval has completed.
2.4.5 u32AHI_WakeTimerCalibrate
Declaration PUBLIC uint32 u32AHI_WakeTimerCalibrate(void);
Inputs None
Outputs uint32 Returned value shows the calibration offset from the ideal, measured
against the 16MHz clock. The ideal result would be 10000 decimal. A
lower value means that the 32kHz clock is running fast and a higher
value means it is running slow.
Description Performs a calibration of the 32kHz clock against the more accurate 16MHz clock.
The returned value can be used to adjust the time interval values used to program
the wake timers.
Note that the 32kHz clock has a tolerance of +/-30%.
2.4.6 u8AHI_WakeTimerFiredStatus
Declaration PUBLIC uint8 u8AHI_WakeTimerFiredStatus(void);
Inputs None
Outputs uint8 Bitmap:
Returned value logical ANDed with E_AHI_WAKE_TIMER_MASK_0 will be
non-zero if wake timer 0 has fired
Returned value logical ANDed with E_AHI_WAKE_TIMER_MASK_1 will be
non-zero if wake timer 1 has fired
Description Returns a bitmap where the relevant bits are set to show which timers have fired.
Any fired timer status is cleared as a result of this call.
2.5.1 vAHI_ApConfigure
Declaration PUBLIC void vAHI_ApConfigure(bool_t bAPRegulator,
bool_t bIntEnable,
uint8 u8SampleSelect,
uint8 u8ClockDivRatio,
bool_t bRefSelect);
E_AHI_AP_REGULATOR_ENABLE
E_AHI_AP_REGULATOR_DISABLE
bool_t bIntEnable Enable/disable interrupt when conversion/capture
completes
E_AHI_AP_INT_ENABLE
E_AHI_AP_INT_DISABLE
uint8 u8SampleSelect Select sample period in divided clock
E_AHI_AP_SAMPLE_2
E_AHI_AP_SAMPLE_4
E_AHI_AP_SAMPLE_6
E_AHI_AP_SAMPLE_8
uint8 u8ClockDivRatio Clock divide ratio
E_AHI_AP_CLOCKDIV_2MHZ
E_AHI_AP_CLOCKDIV_1MHZ
E_AHI_AP_CLOCKDIV_500KHZ
E_AHI_AP_CLOCKDIV_250KHZ
Inputs None
Outputs bool_t TRUE if powered up, FALSE if still waiting
Description This function should be called after enabling the AP regulator to ensure it has
powered up. When the analogue peripheral regulator is enabled, it will take a little
while to start up. This period varies from 31.25usec – 218.75usec.
2.5.3 vAHI_APRegisterCallback
Declaration PUBLIC void vAHI_APRegisterCallback(PR_HWINT_APPCALLBACK
prApCallback)
2.6.1 vAHI_AdcEnable
Declaration PUBLIC void vAHI_AdcEnable(bool_t bContinuous,
bool_t bInputRange,
uint8 u8Source);
2.6.2 vAHI_AdcStartSample
Declaration PUBLIC void vAHI_AdcStartSample(void);
Inputs None
Outputs None
Description Sets the ADC to start a sample in single shot mode. When complete an interrupt
will be triggered if enabled, otherwise use the bAHI_AdcPoll() routine to poll for
completion.
Inputs None
Outputs bool_t TRUE if busy in single shot mode
Description Determines if ADC is busy performing a conversion
2.6.4 u16AHI_AdcRead
Declaration PUBLIC uint16 u16AHI_AdcRead(void);
Inputs None
Outputs uint16 Most recent ADC conversion result
Description Reads the most recent ADC conversion result. The value is 12 bits wide.
2.6.5 vAHI_AdcDisable
Declaration PUBLIC void vAHI_AdcDisable (void);
Inputs None
Outputs None
Description Disable the ADC.
2.7.1 vAHI_DacEnable
Declaration PUBLIC void vAHI_DacEnable(uint8 u8Dac,
bool_t bInputRange,
bool_t bRetainOutput,
uint16 u16InitialVal);
2.7.2 bAHI_DacPoll
Declaration PUBLIC bool_t bAHI_DacPoll (void);
Inputs None
Outputs bool_t returns TRUE if busy, FALSE when complete
Description Determines if the DAC is busy performing a conversion. A short delay (approx
2μs) after polling and determining the DAC has completed is included to prevent
lockups when further calls are made to the DAC.
2.7.4 vAHI_DacDisable
Declaration PUBLIC void vAHI_DacDisable (uint8 u8Dac);
Outputs None
Description Disable the specified DAC.
2.8.1 vAHI_CompEnable
Declaration PUBLIC void vAHI_CompEnable(uint8 u8Hysteresis,
uint8 u8SignalSelect);
2.8.3 vAHI_CompDisable
Declaration PUBLIC void vAHI_CompDisable(void);
Inputs None
Outputs None
Description Disables the specified comparator.
2.8.5 vAHI_CompWakeEnable
Declaration PUBLIC void vAHI_CompWakeEnable(bool_t bIntEnable,
bool_t bRisingNotFalling);
2.8.6 u8AHI_CompStatus
Declaration PUBLIC uint8 u8AHI_CompStatus(void);
Inputs None
Outputs uint8 Returned value will be non-zero if comparator is ‘high’
Description Returns the status of the comparator. The status is non-zero if one input is higher
than the other and zero if it is lower.
2.8.7 u8AHI_CompWakeStatus
Declaration PUBLIC uint8 u8AHI_CompWakeStatus(void);
Inputs None
Outputs bool_t Returned value will be non-zero if comparator wake-up interrupt has
occurred.
Description Returns the wake-up interrupt status of the comparator. The value is cleared after
reading.
2.9.1 vAHI_DioSetDirection
Declaration PUBLIC void vAHI_DioSetDirection(uint32 u32Inputs,
uint32 u32Outputs);
Inputs uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
u32Inputs set means that the bit will become an input. Bits 21-31 are
ignored.
uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
u32Outputs set means that the bit will become an output. Bits 21-31 are
ignored.
Outputs None
Description Sets the direction for DIO pins as either input or output. Not all DIO pins have to
be defined (in other words, u32Inputs logical AND with u32Outputs does not
have to have all of bits 0 to 20 set). Any DIO pins that aren’t defined by a call to
this function will be left in their previous state. If a bit is set in both u32Inputs and
u32Outputs, it will default to becoming an input. If a DIO is assigned to another
peripheral and that peripheral is enabled, this call will not affect that bit.
Inputs uint32 u32On Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
set means that the bit will be set on. Bits 21-31 are ignored.
uint32 u32Off Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
set means that the bit will be set off. Bits 21-31 are ignored.
Outputs None
Description Sets whether a DIO output is on or off. Not all DIO pins have to be defined (in
other words, u32On logical AND with u32Off does not have to have all of bits 0 to
20 set). Any DIO pins that aren’t defined by a call to this function will be left in
their previous state. If a bit is set in both u32On and u32Off, it will default to being
off. This call has no effect on DIO pins that aren’t defined as outputs (see
vAHI_DioSetDirection()). If a DIO is assigned to another peripheral and that
peripheral is enabled, this call will not affect that bit.
2.9.3 u32AHI_DioReadInput
Declaration PUBLIC uint32 u32AHI_DioReadInput(void);
Inputs None
Outputs uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. The bit will be set if
the input is high or 0 if the input is low. Bits 21-31 are always 0.
Description Returns the value of each of the DIO input pins. The value is not valid for DIO
pins that are assigned as outputs or which are assigned to another enabled
peripheral.
2.9.4 u8AHI_DioSetByte
Declaration PUBLIC void u8AHI_DioSetByte(bool_t bDIOSelect, uint8
u8DataByte);
Inputs bool bDIOSelect Selects which DIO lines are used to output the byte:
0 selects DIO 0-7
1 selects DIO 8-15
uint8 8DataByte The byte to output on the DIO pins.
Outputs None
Description Outputs a byte on either DIO 0-7 or DIO 8-15.
Inputs bool bDIOSelect Selects which DIO lines are used to read the input byte:
0 selects DIO 0-7
1 selects DIO 8-15
uint8 8DataByte The byte read from DIO 0-7 or DIO 8-15
Outputs None
Description Reads a byte on either DIO 0-7 or DIO 8-15.
2.9.6 vAHI_DioSetPullup
Inputs uint32 u32On Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
set means that the pull up will be turned on. Bits 21-31 are
ignored.
uint32 u32Off Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
set means that the pull up will be turned off. Bits 21-31 are
ignored.
Outputs None
Description Sets the pullups on the DIO pins as on or off. These can be set independently of
whether the pins are inputs or outputs.
2.9.7 vAHI_DioInterruptEdge
Declaration PUBLIC void vAHI_DioInterruptEdge (uint32 u32Rising,
uint32 u32Falling);
Inputs uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit set
u32Rising means that the interrupt will be triggered by a rising edge on
the input. Bits 21-31 are ignored.
uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit set
u32Falling means that the interrupt will be triggered by a falling edge on
the input. Bits 21-31 are ignored.
Outputs None
Description Sets whether a DIO input, when set to generate an interrupt, will generate it on a
rising or a falling edge. Not all DIO pins have to be defined (in other words,
u32Rising logical AND with u32Falling does not have to have all of bits 0 to 20
set). Any DIO pins that aren’t defined by a call to this function will be left in their
previous state. If a bit is set in both u32Rising and u32Falling, it will default to
rising edge. This call has no effect on DIO pins that aren’t defined as inputs (see
vAHI_DioSetDirection()). If a DIO is assigned to another peripheral and that
2.9.8 vAHI_DioInterruptEnable
Declaration PUBLIC void vAHI_DioInterruptEnable (uint32 u32Enable,
uint32 u32Disable);
Inputs uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
u32Enable set means that the interrupt s enabled for that pin. Bits 21-
31 are ignored.
uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. A bit
u32Disable set means that the interrupt is disabled for that pin. Bits 21-
31 are ignored.
Inputs None
Outputs None
Description Sets whether a DIO input will generate an interrupt. Not all DIO pins have to be
defined (in other words, u32Enable logical AND with u32Disable does not have
to have all of bits 0 to 20 set). Any DIO pins that aren’t defined by a call to this
function will be left in their previous state. If a bit is set in both u32Enable and
u32Disable, it will default to disabling the interrupt. This call has no effect on DIO
pins that aren’t defined as inputs (see vAHI_DioSetDirection()). If a DIO is
assigned to another peripheral and that peripheral is enabled, this call will not
affect that bit.
DIO interrupts can also be used to wake the device from sleep mode.
2.9.9 u32AHI_DioInterruptStatus
Declaration PUBLIC uint32 u32AHI_DioInterruptStatus(void);
Inputs None
Outputs uint32 Bitmask: each of bits 0-20 corresponds to a DIO pin. The bit will be set if
an interrupt associated with the pin has triggered. Bits 21-31 are always
0.
Outputs None
Description Returns the interrupt status of each of the DIO input pins. The value is not valid
for DIO pins that are assigned as outputs or which are assigned to another
enabled peripheral. After reading, the value is cleared.
2.10.1 vAHI_UartEnable
Declaration PUBLIC void vAHI_UartEnable(uint8 u8Uart);
2.10.3 vAHI_UartSetClockDivisor
Declaration PUBLIC void vAHI_UartSetClockDivisor(uint8 u8Uart,
uint8 u8BaudRate);
Outputs None
Description Sets various control bits for a UART. Note that RTS cannot be controlled
automatically, but only set or cleared under software control.
2.10.8 u8AHI_UartReadLineStatus
Declaration PUBLIC uint8 u8AHI_UartReadLineStatus(uint8 u8Uart);
2.10.9 u8AHI_UartReadModemStatus
Declaration PUBLIC uint8 u8AHI_UartReadModemStatus(uint8 u8Uart);
2.10.10 u8AHI_UartReadInterruptStatus
Declaration PUBLIC uint8 u8AHI_UartReadInterruptStatus(uint8 u8Uart);
2.10.11 vAHI_UartWriteData
Declaration PUBLIC void vAHI_UartWriteData(uint8 u8Uart, uint8 u8Data);
2.10.13 vAHI_Uart0RegisterCallback
Declaration PUBLIC void vAHI_Uart0RegisterCallback(PR_HWINT_APPCALLBACK
prUart0Callback)
2.10.14 vAHI_Uart1RegisterCallback
Declaration PUBLIC void vAHI_Uart1RegisterCallback(PR_HWINT_APPCALLBACK
PrUart1Callback)
2.11.1 vAHI_TimerEnable
Declaration PUBLIC void vAHI_TimerEnable(uint8 u8Timer,
uint8 u8Prescale,
bool_t bIntRiseEnable,
bool_t bIntPeriodEnable,
bool_t bOutputEnable);
2.11.3 vAHI_TimerStartSingleShot
Declaration PUBLIC void vAHI_TimerStartSingleShot(uint8 u8Timer,
uint16 u16Hi,
uint16 u16Lo);
2.11.5 vAHI_TimerStartDeltaSigma
Declaration PUBLIC void vAHI_TimerStartDeltaSigma(uint8 u8Timer,
uint16 0x0000,
uint16 u16Hi,
bool_t bRtzEnable);
2.11.7 vAHI_TimerReadCapture
Declaration PUBLIC void vAHI_TimerReadCapture(uint8 u8Timer,
uint16 *pu16Hi,
uint16 *pu16Lo);
2.11.8 vAHI_TimerStop
Declaration PUBLIC void vAHI_TimerStop(uint8 u8Timer);
2.11.10 u8AHI_TimerFired
Declaration PUBLIC uint8 u8AHI_TimerFired(uint8 u8Timer);
2.11.11 vAHI_Timer0RegisterCallback
Declaration PUBLIC void vAHI_Timer0RegisterCallback(PR_HWINT_APPCALLBACK
PrTimer0Callback)
2.11.12 vAHI_Timer1RegisterCallback
Declaration PUBLIC void vAHI_Timer1RegisterCallback(PR_HWINT_APPCALLBACK
PrTimer1Callback)
2.12.1 vAHI_TickTimerInit
Declaration PUBLIC void vAHI_TickTimerInit(PR_HWINT_APPCALLBACK
prTickTimerCallback);
2.12.2 vAHI_TickTimerWrite
Declaration PUBLIC void vAHI_TickTimerWrite(uint32 u32Count);
Inputs uint32 u32Count Tick Timer counter value (0 - 0xFFFFFFFF)
Outputs None
Description Set the current value of the Tick Timer counter, can be used to reset the timer to
zero or any other point.
2.12.3 vAHI_TickTimerIntPendClr
Declaration PUBLIC void vAHI_TickTimerIntPendClr(void);
Inputs None
Outputs None
Description Clear any pending Tick Timer interrupt
2.12.4 bAHI_TickTimerIntStatus
Declaration PUBLIC bool_t bAHI_TickTimerIntStatus(void);
Inputs None
Outputs bool_t TRUE if an interrupt is pending, FALSE otherwise
Description Returns the current interrupt status of the Tick Timer
2.12.6 vAHI_TickTimerIntEnable
Declaration PUBLIC void vAHI_TickTimerIntEnable(bool_t bIntEnable);
Inputs bool_t bIntEnable TRUE to enable the Tick Timer interrupt, FALSE to disable
it
Outputs None
Description Enable/disable Tick Timer interrupt
2.12.7 u32AHI_TickTimerRead
Declaration PUBLIC uint32 u32AHI_TickTimerRead(void);
Inputs None
Outputs uint32 Value of the Tick Timer counter
Description Returns the current value of the Tick Timer counter
2.12.8 vAHI_TickTimerInterval
Declaration PUBLIC void vAHI_TickTimerInterval(uint32 u32Interval);
2.13.1 vAHI_SpiConfigure
Declaration PUBLIC void vAHI_SpiConfigure(uint8 u8SlaveEnable,
bool_t bLsbFirst,
bool_t bTxNegEdge,
bool_t bRxNegEdge,
uint8 u8ClockDivider,
bool_t bInterruptEnable,
bool_t bAutoSlaveSelect);
Inputs uint8 u8SlaveEnable Number of extra SPI slaves to control, valid values are
0 to 4 and higher values are truncated to 4. By default,
there is 1 SPI slave (the flash memory) with a
dedicated IO pin for its select line. Up to four more
select lines can be set, which use DIO pins 0 to 3.
bool_t bLsbFirst TRUE to transfer data in the order that the least
significant bit is transferred first.
bool_t bTxNegEdge TRUE for transmit data to change on the positive edge
of the clock, and therefore to be sampled by the slave
device on the negative edge of the clock.
bool_t bRxNegEdge TRUE for received data to be sampled on the negative
edge of the clock, and therefore to be changed by the
slave device on the positive edge.
uint8 u8ClockDivider The 16-MHz base clock is divided by 2u8ClockDivider
bool_t TRUE to enable interrupt when an SPI transfer has
bInterruptEnable completed.
bool_t TRUE for the programmed slave select line or lines
bAutoSlaveSelect (see vAHI_SpiSelect()) to be automatically asserted
at the start of a transfer and de-asserted when the
transfer completes. FALSE for the slave select lines to
reflect the value set by vAHI_SpiSelect() directly.
Outputs None
Description Enables and sets the SPI master. Depending on how many additional slaves are
enabled, can use DIO pins 0 to 3. For instance, if 2 additional slaves are enabled,
DIO 0 and 1 will be assigned for this.
2.13.3 vAHI_SpiRestoreConfiguration
Declaration PUBLIC void vAHI_SpiRestoreConfiguration(tSpiConfiguration
*ptConfiguration)
2.13.4 vAHI_SpiSelect
Declaration PUBLIC void vAHI_SpiSelect(uint8 u8SlaveMask);
Inputs uint8 u8SlaveMask Bitmask, one bit per slave select line
Outputs None
Description Sets the active slave select line or lines to use. The slave select lines are asserted
immediately if automatic slave select is disabled, or during transfers otherwise.
The number of valid bits in u8SlaveMask depends on the setting of
u8SlaveEnable in a prior call to vAHI_SpiConfigure(), as follows:
u8SlaveEnable Valid bits in u8SlaveMask
0 Bit 0
1 Bits 0, 1
2 Bits 0, 1, 2
3 Bits 0, 1, 2, 3
4 Bits 0, 1, 2, 3, 4
2.13.6 vAHI_SpiStartTransfer32
Declaration PUBLIC void vAHI_SpiStartTransfer32(uint32 u32Out);
2.13.7 u32AHI_SpiReadTransfer32
Declaration PUBLIC uint32 u32AHI_SpiReadTransfer32(void);
Inputs None
Outputs uint32 Received data
Description Called after a 32-bit SPI transfer has completed, this routine returns the received
data.
2.13.8 vAHI_SpiStartTransfer16
Declaration PUBLIC void vAHI_SpiStartTransfer16(uint16 u16Out);
Inputs None
Outputs uint16 Received data (16 bits)
Description Called after a 16-bit SPI transfer has completed, this routine returns the received
data.
2.13.10 vAHI_SpiStartTransfer8
Declaration PUBLIC void vAHI_SpiStartTransfer8(uint8 u8Out);
2.13.11 u8AHI_SpiReadTransfer8
Declaration PUBLIC uint8 u8AHI_SpiReadTransfer8(void);
Inputs None
Outputs uint8 Received data (8 bits)
Description To be called after an 8-bit SPI transfer has completed, this returns the received
data.
2.13.12 bAHI_SpiPollBusy
Declaration PUBLIC bool_t bAHI_SpiPollBusy(void);
Inputs None
Outputs bool_t TRUE if the SPI master is performing a transfer
Description Can be used to poll the SPI master to tell if it is currently busy.
Inputs None
Outputs None
Description Call only returns when the SPI master has completed a transfer.
2.13.14 vAHI_SpiRegisterCallback
Declaration PUBLIC void vAHI_SpiRegisterCallback(PR_HWINT_APPCALLBACK
prSpiCallback)
Inputs PR_HWINT_APPCALLBACK Pointer to function that is to be called when
prSpiCallback SPI master interrupt occurs.
Outputs None
Description Registers an application callback that will be called when the SPI Master interrupt
is triggered.
2.14.1 vAHI_SiConfigure
Declaration PUBLIC void vAHI_SiConfigure(bool_t bSiEnable,
bool_t bInterruptEnable,
uint16 u16PreScaler);
Outputs None
Description Issue Commands to the interface bus.
2.14.3 vAHI_SiWriteData8
Declaration PUBLIC void vAHI_SiWriteData8(uint8 u8Out);
2.14.5 u8AHI_SiReadData8
Declaration PUBLIC uint8 u8AHI_SiReadData8(void)
Inputs None
Outputs uint8 Contents of the Rx register
Description Read data sent to us over the Si bus.
2.14.6 bAHI_SiPollBusy
Declaration PUBLIC bool_t bAHI_SiPollBusy(void)
Inputs None
Outputs bool_t TRUE if busy
Description Check to see if the serial interface is busy - could be in use by another master.
2.14.7 bAHI_SiPollTransferInProgress
Declaration PUBLIC bool_t bAHI_SiPollTransferInProgress(void)
Inputs None
Outputs bool_t TRUE if a transfer is in progress
Description Check to see if a transfer is in progress.
2.14.9 bAHI_SiPollArbitrationLost
Declaration PUBLIC bool_t bAHI_SiPollArbitrationLost (void)
Inputs None
Outputs bool_t TRUE if arbitration loss has occurred
Description Check to see if arbitration loss has occurred.
2.14.10 vAHI_SiRegisterCallback
Declaration PUBLIC void vAHI_SiRegisterCallback(PR_HWINT_APPCALLBACK
prSiCallback)
2.15.1 vAHI_IpEnable
Declaration PUBLIC void vAHI_IpEnable(bool_t bTxEdge,
bool_t bRxEdge,
bool_t bEndian)
Inputs bool_t bTxEdge Select the clock edge that TX data is sampled on
E_AHI_IP_TXPOS_EDGE (data sampled on +ve edge)
E_AHI_IP_TXNEG_EDGE (data sampled on -ve edge)
bool_t bRxEdge Select the clock edge that RX data is sampled on
E_AHI_IP_RXPOS_EDGE (data sampled on +ve edge)
E_AHI_IP_RXNEG_EDGE (data sampled on -ve edge)
bool_t bEndian Select byte order of data over the IP interface
E_AHI_IP_BIG_ENDIAN data RX/TX format
E_AHI_IP_LITTLE_ENDIAN data RX/TX format
Outputs None
Description Initialise and enable IP mode
2.15.2 bAHI_IpSendData
Declaration PUBLIC bool_t bAHI_IpSendData(uint8 u8Length,
uint8 *pau8Data)
Inputs uint8 *pu8Length pointer to write length of data received (in words)
uint8 *pau8Data pointer to buffer to copy data into
Outputs bool_t TRUE for data read, FALSE for unable to read
Description Read data received from SPI Master, data in pau8Data buffer is stored LSB first.
2.15.4 bAHI_IpTxDone
Declaration PUBLIC bool_t bAHI_IpTxDone(void)
Inputs None
2.15.5 bAHI_IpRxDataAvailable
Declaration PUBLIC bool_t bAHI_IpRxDataAvailable(void)
Inputs None
2.15.6 vAHI_IpRegisterCallback
Declaration PUBLIC void vAHI_IpRegisterCallback(PR_HWINT_APPCALLBACK
prIpCallback)
2.16.2 bAHI_FlashErase
Declaration PUBLIC bool_t bAHI_FlashErase(void);
Inputs None
Outputs bool_t TRUE if sector erase was successful
FALSE if sector erase failed
Description Erases the 32-Kbyte sector of the Flash memory used to store application data, by
setting all bits to 1. Does not affect sectors containing application code.
Inputs uint8 u8Sector The number of the sector to be erased: integer in range 0
to 3.
Outputs bool_t TRUE if sector erase was successful
FALSE if sector erase failed
Description Erases the specified 32-Kbyte sector of Flash memory by setting all bits to 1. The
Flash device consists of four 32-Kbyte sectors, numbered 0 to 3.
Inputs uint16 u16Addr Address of first Flash memory byte to be read (offset from
start of 32-Kbyte block)
uint16 u16Len Number of bytes to be read: integer in range 1 to 0x8000.
uint8 *pu8Data Pointer to start of buffer to receive read data.
Outputs bool_t TRUE if read was successful
FALSE if read failed or input parameters were invalid
Description Reads data from application data area of Flash memory. The Flash sector
allocated to application data is a continuous block of 32 Kbytes. The address
given is an offset within this area, i.e. it starts at 0. The function returns without
reading anything if input values are invalid (e.g. try to read beyond end of sector).
2.17.1 bAHI_eFuseBlow
Declaration PUBLIC bool_t bAHI_eFuseBlow(uint8 u8FuseNum,
uint8 u8Bank);
2.17.2 bAHI_eFuseReadBank
Declaration PUBLIC bool_t bAHI_eFuseReadBank(uint8 u8Bank,
uint32 *pu32Buffer);
Revision History
Version Date Description
1.0 12-Sep-2005 Released
1.1 19-Sep-2005 Changes to Analogue Peripherals, Added Tick Timer description
1.2 14-Nov-2005 Correction to sense of parameters txNegEdge and RxNegEdge in SPIconfigure
Correct naming of u32AHI_Init().
Updated document style.
Corrected definition of u8Prescale in vAHI_TimerEnable()
1.3 13-Jan-2006 Minor updates
1.4 13-Jan-2006 Updated for v3 of JN5121
1.5 07-Mar-2006 Correction to vAHI_ApConfigure, and removed DioWake functions
1.6 30-Mar-2006 Added comment about use of tick timer in doze mode plus other minor updates
1.7 06-Jul-2006 Updated template, added interrupt item bitmap descriptions
IP mode added
References to NVRAM changed to LPRAM
vAHI_SwReset() and vAHI_DriveResetOut() added
Resolution and ADC changed
ADC clock Divider changed
References to Comp2 removed
Declaration for vAHI_DioSetPullup corrected
Clarification of some vAHI_SpiConfigure parameters
1.8 24-Jul-2006 Change to table in Section 2.9 “DIO”
1.9 05-Oct-2006 Name of library changed to Integrated Peripherals API.
Mentions of LPRAM and NVRAM removed.
ADC resolution changed.
Description of vAHI_TickTimerInit() modified (does not enable interrupts).
Description of operation of Receive FIFO interrupts for the UARTs added.
Description of vAHI_UartReset() modified.
u8AHI_DioSetByte() and u8AHI_DioReadByte() added.
1.10 09-Nov-2006 Description of vAHI_SiWriteData8() modified.
COMP0 and COMP1 in enumerated values changed to COMP.
2.0 13-Feb-2007 Added JN513x functionality.
Corrected description of function vAHI_TimerStartDeltaSigma().
United States Sales Office United States Sales Office Korean Sales Office
1322 Scott Street, Suite 203 1060 First Avenue, Suite 400 701, 7th Floor, Kunam Building
Point Loma King of Prussia 831-37, Yeoksam-Dong
CA 92106 PA 19406 Kangnam-ku
USA USA Seoul 135-080
Korea
Tel +1 619 223 2215 Tel +1 619 223 2215
Fax +1 619 223 2081 Fax +1 619 223 2081 Tel +82 2 552 5325
E-mail [email protected] E-mail [email protected] Fax +82 2 3453 8802
E-mail [email protected]