I2C. Fixed testhal for F4x.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4410 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
2a1dd61381
commit
4b96f983dd
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
//#define CORTEX_VTOR_INIT 0x000E0000
|
//#define CORTEX_VTOR_INIT 0x000E0000
|
||||||
#define CORTEX_VTOR_INIT 0x00000000
|
#define CORTEX_VTOR_INIT 0x00000000
|
||||||
#define CORTEX_USE_FPU TRUE
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Kernel parameters. */
|
/* Kernel parameters. */
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
* @brief Enables the I2C subsystem.
|
* @brief Enables the I2C subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_I2C FALSE
|
#define HAL_USE_I2C TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,7 +51,7 @@ static int16_t acceleration_x, acceleration_y, acceleration_z;
|
||||||
static void print(char *p) {
|
static void print(char *p) {
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
chIOPut(&SD2, *p++);
|
sdPut(&SD2, *p++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ static void print(char *p) {
|
||||||
static void println(char *p) {
|
static void println(char *p) {
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
chIOPut(&SD2, *p++);
|
sdPut(&SD2, *p++);
|
||||||
}
|
}
|
||||||
chIOWriteTimeout(&SD2, (uint8_t *)"\r\n", 2, TIME_INFINITE);
|
sdWriteTimeout(&SD2, (uint8_t *)"\r\n", 2, TIME_INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,20 +73,20 @@ static void printn(int16_t n) {
|
||||||
char buf[16], *p;
|
char buf[16], *p;
|
||||||
|
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
chIOPut(&SD2, '+');
|
sdPut(&SD2, '+');
|
||||||
else{
|
else{
|
||||||
chIOPut(&SD2, '-');
|
sdPut(&SD2, '-');
|
||||||
n = abs(n);
|
n = abs(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
chIOPut(&SD2, '0');
|
sdPut(&SD2, '0');
|
||||||
else {
|
else {
|
||||||
p = buf;
|
p = buf;
|
||||||
while (n)
|
while (n)
|
||||||
*p++ = (n % 10) + '0', n /= 10;
|
*p++ = (n % 10) + '0', n /= 10;
|
||||||
while (p > buf)
|
while (p > buf)
|
||||||
chIOPut(&SD2, *--p);
|
sdPut(&SD2, *--p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,13 @@ int16_t complement2signed(uint8_t msb, uint8_t lsb){
|
||||||
return (int16_t)word;
|
return (int16_t)word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* I2C interface #2 */
|
||||||
|
static const I2CConfig i2cfg2 = {
|
||||||
|
OPMODE_I2C,
|
||||||
|
400000,
|
||||||
|
FAST_DUTY_CYCLE_2,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Application entry point.
|
* Application entry point.
|
||||||
*/
|
*/
|
||||||
|
@ -119,6 +126,11 @@ int main(void) {
|
||||||
halInit();
|
halInit();
|
||||||
chSysInit();
|
chSysInit();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Starts I2C
|
||||||
|
*/
|
||||||
|
i2cStart(&I2CD2, &i2cfg2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepares the Serial driver 2
|
* Prepares the Serial driver 2
|
||||||
*/
|
*/
|
||||||
|
@ -126,14 +138,6 @@ int main(void) {
|
||||||
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
|
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
|
||||||
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
|
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
|
||||||
|
|
||||||
/* I2C interface #2 */
|
|
||||||
static const I2CConfig i2cfg2 = {
|
|
||||||
OPMODE_I2C,
|
|
||||||
400000,
|
|
||||||
FAST_DUTY_CYCLE_16_9,
|
|
||||||
};
|
|
||||||
i2cStart(&I2CD2, &i2cfg2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the accelerometer
|
* Prepares the accelerometer
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue