IanHarvey / spark-monitor

Home power monitor using Spark Core
10 stars 2 forks source link

Code doesn't compile #1

Open bshaffer82 opened 9 years ago

bshaffer82 commented 9 years ago

I am using the particle online build tools with your firmware. I cannot get it to compile. I get the following errors:

power_montor.cpp:7:69: error: 'FComplex' has not been declared bool processData(volatile uint16_t raw, int count, int zerosample, FComplex res); ^

power_montor.cpp: In function 'void dmaInit(volatile uint16_t, uint32_t)': power_montor.cpp:103:35: error: 'ADC1_DR_ADDRESS' was not declared in this scope res->re += (cal_Scale \ c_sum) / count; ^

power_montor.cpp:104:10: error: 'struct DMA_InitTypeDef' has no member named 'DMA_MemoryBaseAddr' res->im += (cal_Scale * s_sum) / count; ^

power_montor.cpp:105:20: error: 'DMA_DIR_PeripheralSRC' was not declared in this scope return true; ^

power_montor.cpp:113:10: error: 'struct DMA_InitTypeDef' has no member named 'DMA_M2M'

      ^

power_montor.cpp:113:20: error: 'DMA_M2M_Disable' was not declared in this scope

                ^

power_montor.cpp:114:14: error: 'DMA1_Channel1' was not declared in this scope dmac.DMA_PeripheralBaseAddr = ADC1_DR_ADDRESS; ^

power_montor.cpp: In function 'void adcSetup()': power_montor.cpp:124:22: error: 'RCC_PCLK2_Div6' was not declared in this scope dmac.DMA_M2M = DMA_M2M_Disable; ^

power_montor.cpp:124:36: error: 'RCC_ADCCLKConfig' was not declared in this scope dmac.DMA_M2M = DMA_M2M_Disable; ^

power_montor.cpp:125:27: error: 'RCC_AHBPeriph_DMA1' was not declared in this scope DMA_Init(DMA1_Channel1, &dmac); ^

power_montor.cpp:125:53: error: 'RCC_AHBPeriphClockCmd' was not declared in this scope DMA_Init(DMA1_Channel1, &dmac); ^

power_montor.cpp:126:28: error: 'RCC_APB2Periph_GPIOA' was not declared in this scope

                        ^

power_montor.cpp:129:10: error: 'struct ADC_InitTypeDef' has no member named 'ADC_Mode'

      ^

power_montor.cpp:132:33: error: 'ADC_ExternalTrigConv_None' was not declared in this scope ADC_InitTypeDef adc1; ^

power_montor.cpp:134:10: error: 'struct ADC_InitTypeDef' has no member named 'ADC_NbrOfChannel' // Clock config ^

power_montor.cpp:138:54: error: 'ADC_SampleTime_239Cycles5' was not declared in this scope

                                                  ^

power_montor.cpp:144:30: error: 'ADC_ResetCalibration' was not declared in this scope adc1.ADC_DataAlign = ADC_DataAlign_Right; ^

power_montor.cpp:145:46: error: 'ADC_GetResetCalibrationStatus' was not declared in this scope adc1.ADC_NbrOfChannel = 1; ^

power_montor.cpp:148:30: error: 'ADC_StartCalibration' was not declared in this scope // This gives ~50Khz sampling rate, 1 mains cycle should fit in 1024 samples ^

power_montor.cpp:149:41: error: 'ADC_GetCalibrationStatus' was not declared in this scope ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_239Cycles5); ^

power_montor.cpp: In function 'void isr_sync_pin()': power_montor.cpp:180:48: error: 'ADC_SoftwareStartConvCmd' was not declared in this scope static unsigned long lastTime; ^

power_montor.cpp:188:68: error: 'DMA1_Channel1' was not declared in this scope lastTime = micros(); ^

power_montor.cpp:193:49: error: 'ADC_SoftwareStartConvCmd' was not declared in this scope break; ^

power_montor.cpp:194:60: error: 'DMA1_Channel1' was not declared in this scope

                                                        ^

power_montor.cpp:195:25: error: 'DMA1_FLAG_TC1' was not declared in this scope case RUNNING: ^

make[1]: * [../build/target/user/platform-6power_montor.o] Error 1 make: * [user] Error 2 Error: Could not compile. Please review your code.

IanHarvey commented 9 years ago

It looks like the online tools have changed recently. I'll take a look, but in the meantime can you check you're using the code from here on GitHub, not from the Instructables download? The errors you're getting don't match the latest code.

Thanks Ian

bshaffer82 commented 9 years ago

Ok, I'll give that try. I find the partical.io libraries really difficult to use. I recently found the core code and libraries on github but even that wasn't very well documented. At least having the source means that with a few grep's I can figure out what happens when I do an Adc_Read() for instance.

/Craig

On Mon, Sep 21, 2015 at 12:59 PM, Ian Harvey notifications@github.com wrote:

It looks like the online tools have changed recently. I'll take a look, but in the meantime can you check you're using the code from here on GitHub, not from the Instructables download? The errors you're getting don't match the latest code.

Thanks Ian

— Reply to this email directly or view it on GitHub https://github.com/IanHarvey/spark-monitor/issues/1#issuecomment-142042739 .

IanHarvey commented 9 years ago

I've been building the code using command-line source from GitHub:

git clone -b master https://github.com/spark/firmware.git git clone -b master https://github.com/spark/core-common-lib.git git clone -b master https://github.com/spark/core-communication-lib.git

and then build instructions are given in firmware/README.md.

The firmware file (saved as firmware/src/application.cpp) builds just fine for me, although on the cloud IDE I get "ADC1_DR_ADDRESS' was not declared in this scope".

I haven't managed to identify where the headers (etc) that the cloud IDE is using come from yet, it's very frustrating.

bshaffer82 commented 9 years ago

Interesting...I had similar problems, their IDE doesn't have very much documentation.

Craig

On Wed, Sep 23, 2015 at 5:09 PM, Ian Harvey notifications@github.com wrote:

I've been building the code using command-line source from GitHub:

git clone -b master https://github.com/spark/firmware.git git clone -b master https://github.com/spark/core-common-lib.git git clone -b master https://github.com/spark/core-communication-lib.git

and then build instructions are given in firmware/README.md.

The firmware file (saved as firmware/src/application.cpp) builds just fine for me, although on the cloud IDE I get "ADC1_DR_ADDRESS' was not declared in this scope".

I haven't managed to identify where the headers (etc) that the cloud IDE is using come from yet, it's very frustrating.

— Reply to this email directly or view it on GitHub https://github.com/IanHarvey/spark-monitor/issues/1#issuecomment-142729540 .

IanHarvey commented 9 years ago

I've added a fix for this in commit baf9ba3, to add back the missing definition. This now works for me on the Particle cloud IDE without problems.

Let me know if there are any further problems - please note though this code is only for the Core module - the Photon & Electron have a different ARM controller so the low-level peripheral stuff can't be expected to build.

Thanks Ian