// test-lib.h
#ifndef TEST_LIB_H_
#define TEST_LIB_H_
#include "board.h"
#include "cr_section_macros.h"
class testClass
{
public:
testClass();
void begin();
};
#endif /* TEST_LIB_H_ */ |
// test-lib.cpp
#include "test-lib.h"
testClass::testClass()
{
}
void testClass::begin()
{
Chip_I2C_Init(I2C0);
} |
// test-prog.cpp
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif
#include <cr_section_macros.h>
#include "test-lib.h"
testClass footy;
int main(void) {
#if defined (__USE_LPCOPEN)
#if !defined(NO_BOARD_LIB)
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
// Set the LED to the state of "On"
Board_LED_Set(0, true);
#endif
#endif
footy.begin();
// Force the counter to be placed into memory
volatile static int i = 0 ;
// Enter an infinite loop, just incrementing a counter
while(1) {
i++ ;
}
return 0 ;
} |
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_I2C0); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 4, (IOCON_FUNC1 | I2C_FASTPLUS_BIT) | IOCON_DIGMODE_EN); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 5, (IOCON_FUNC1 | I2C_FASTPLUS_BIT) | IOCON_DIGMODE_EN); Chip_SYSCTL_PeriphReset(RESET_I2C0); |
extern "c" |
extern "c" {
#include "board.h"
#inlcude other_c_linkage_headers.h
}
|
#ifndef __I2C_11U6X_H_
#define __I2C_11U6X_H_
#include "i2c_common_11u6x.h"
#ifdef __cplusplus
extern "C" {
#endif
// snip
/**
* @briefInitializes the LPC_I2C peripheral with specified parameter.
* @paramid: I2C peripheral ID (I2C0, I2C1 ... etc)
* @returnNothing
*/
void Chip_I2C_Init(I2C_ID_T id);
// snip
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __I2C_11U6X_H_ */ |