示例#1
0
/*Starts the SPI2 Driver and the MMC object */
void startMMC(void) {
    /*
     * Initializes the MMC driver to work with SPI2.
     */
    SPI2Init() ;
    mmcObjectInit(&MMCD1);
    mmcStart(&MMCD1, &mmccfg);
}
示例#2
0
文件: newfile.c 项目: reebot/wins
int main(void) {
    // Disable Watch Dog Timer
    RCONbits.SWDTEN = 0;
    // for LED
    ODCAbits.ODA6 = 0;
    TRISAbits.TRISA6 = 0;
    TRISAbits.TRISA4 = 0;
    TRISAbits.TRISA0 = 0;


    //Enable channel
    OpenI2C1(I2C_ON, I2C_BRG);
    //Setup_MPU6050();
    //LDByteWriteI2C(MPU6050_ADDRESS, MPU6050_RA_PWR_MGMT_1, 0x00);
    SPI1Init();
    SPI2Init();
    LCDinit();
    LCDProcessEvents();

    //_05ms = false;
    //TimerInit();
    unsigned char fifocount[2];

    while (1) {
        if (updateScreen) {
            LCDProcessEvents();
            updateScreen = false;
        }
        if (getFifo) {
            LDByteReadI2C(MPU6050_ADDRESS, MPU6050_RA_FIFO_COUNTH, &fifocount[0], 2);
            if (((((unsigned int) fifocount[0]) << 8) | fifocount[1]) == 1024) {
                //need to reset
                unsigned char temp = 0;
                LDByteReadI2C(MPU6050_ADDRESS, MPU6050_RA_USER_CTRL, &temp, 1);
                LDByteWriteI2C(MPU6050_ADDRESS, MPU6050_RA_USER_CTRL, 0b00000100 | temp);
                /*
                int i = 0;
                for(i = data_p; i < data_p+CHUNK_SIZE; i++){
                    rpiData.imu[i] = 0;
                }*/
                __builtin_btg((unsigned int *) &LATA, 0);
            } else if (((((unsigned int) fifocount[0]) << 8) | fifocount[1]) >= 42) {
                LDByteReadI2C(MPU6050_ADDRESS, MPU6050_RA_FIFO_R_W, &rpiData.imu[data_p], DMP_PACKET_SIZE);
                __builtin_btg((unsigned int *) &LATA, 4);
            }
            getFifo = false;
        }
        __builtin_btg((unsigned int *) &LATA, 6);
    }
    return 0;
}