编译错误:在';'标记之前的预期构造函数,析构函数或类型转换

时间:2014-05-19 16:36:38

标签: c++ function compilation

我是新来的,张贴是因为我已经阅读了几篇有帮助我的帖子。我知道你可能认为这篇文章是另一个副本,而事实并非如此。这不是重复,因为我的代码与其他代码不同。这是我的代码:

#include "bcm2835.h"
#include <cmath>
#include <iostream>
using namespace std;


// COMMANDS
#define WAKEUP 0x02
#define SLEEP  0x04
#define RESET  0x06
#define START  0x09
#define STOP   0x0a
#define RDATAC 0x10
#define SDATAC 0x11
#define RDATA  0x12
#define OFSCAL 0x18
#define GANCAL 0x19
#define RREG1  0x20
#define WREG1  0x40
#define RREG2  0x08
#define WREG2  0x08

// REGISTERS
#define CONFIG0 0x85
#define CONFIG1 0x10       // checksum is kept off
#define CONFIG2 0x15       //10SPS data rate and Gate control mode
#define OFC0    0x00
#define OFC1    0x00
#define OFC2    0x00
#define FSC0    0x00
#define FSC1    0x00
#define FSC2    0x40
#define NUM     1024

int nobytes;
int S = 50;
int i,flag = 1;
int j, k, factor, converged, count = 0;
char status = LOW;
char txbuffer[11], rxbuffer[4], dummy;
float xhat, xhat_m, P_m, L , K, last_xhat_converged, xhat_converged = 0.0;
float P = 1.0;
float R = 0.01;
float Q, mean, variance = 0;
float current, lastreading, current_test[50];
double key, startkey;
float X1[4096];
float X2[4096];
float Xf1[4096];
float Xf2[4096];
float v[4096];
float xf[4096];
float c[65536];
float ys[65536];

spi_start();
initialise();


void spi_start()
 {
bcm2835_init();
//cout << "The SPI mode is starting";
// INITIAL SETUP OF THE SPI DEVICE
bcm2835_spi_begin();                                          // Setup the SPI0 port on the RaspberryPi
bcm2835_spi_chipSelect(BCM2835_SPI_CS0);                      // Assert the chip select
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST);      // Set the Bit order
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW);      // Set the the chip select to be active low
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_64);    // Set the clock divider, SPI speed is 3.90625MHz
bcm2835_spi_setDataMode(BCM2835_SPI_MODE1);                   // Set the Data mode
//cout << "The SPI mode has been started";
 }

void initialise()
 {
// INITIAL RESET OF THE CHIP
nobytes = 1;
txbuffer[0] = RESET;
bcm2835_spi_writenb(txbuffer, nobytes);
bcm2835_delay(100); //no accurate timing required

// WRITING OF THE CONTROL AND THE CALIBRATION REGISTERS
nobytes = 11;
txbuffer[0] = WREG1;
txbuffer[1] = WREG2;
txbuffer[2] = CONFIG0;
txbuffer[3] = CONFIG1;
txbuffer[4] = CONFIG2;
txbuffer[5] = OFC0;
txbuffer[6] = OFC1;
txbuffer[7] = OFC2;
txbuffer[8] = FSC0;
txbuffer[9] = FSC1;
txbuffer[10]= FSC2;
bcm2835_spi_writenb(txbuffer, nobytes);
bcm2835_delay(100); //no accurate timing required

 }

建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

您的问题是您混淆了编译器:

spi_start();
initialize();

是函数调用而不是函数声明 请包含退货类型:

void spi_start();
void initialise();
相关问题