UM10462
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2016. All rights reserved.
User manual
Rev. 5.5 — 21 December 2016
428 of 523
NXP Semiconductors
UM10462
Chapter 22: LPC11U3x/2x/1x Integer division routines
The integer division routines perform arithmetic integer division operations and can be
called in the application code through simple API calls.
The following function prototypes are used:
typedef struct { int quot; int rem; } idiv_return;
typedef struct { unsigned quot; unsigned rem; } uidiv_return;
typedef struct {
/* Signed integer division */
int(*sidiv) (int numerator, int denominator);
/* Unsigned integer division */
unsigned (*uidiv) (unsigned numerator, unsigned denominator);
/* Signed integer division with remainder */
idiv_return (*sidivmod) (int numerator, int denominator);
/* Unsigned integer division with remainder */
uidiv_return (*uidivmod)(unsigned numerator, unsigned denominator);
} LPC_ROM_DIV_STRUCT;
22.4 Examples
22.4.1 Initialization
The example C-code listing below shows how to initialize the API’s ROM table pointer.
typedef struct _ROM {
const unsigned p_dev1;
const unsigned p_dev2;
const unsigned p_dev3;
const PWRD *pPWRD;
const LPC_ROM_DIV_STUCT * pROMDiv;
const unsigned p_dev4;
const unsigned p_dev5;
const unsigned p_dev6;
} ROM;
ROM ** rom = (ROM **) 0x1FFF1FF8;
pDivROM = (*rom)->pROMDiv;
22.4.2 Signed division
The example C-code listing below shows how to perform a signed integer division via the
ROM API.
/* Divide (-99) by (+6) */
int32_t result;