I setup SPI in the usual way in main.cpp, and want to use spi.write(val) in another project file, but I cannot find what to do to keep the compiler happy. Help please?
Here is some sample files:
Main.cpp
- include "mbed.h"
- include "myproj.h"
SPI spi(p5, p6, p7); mosi, miso, sclk
int main() {
spi.format(16,0);
spi.frequency(1000000);
}
----------
myproj.h
void somefunc(uint16_t val);
----------
otherfile.cpp
- include "mbed.h"
- include "myproj.h"
void somefunc(uint16_t val)
{
spi.write(val);
}
I setup SPI in the usual way in main.cpp, and want to use spi.write(val) in another project file, but I cannot find what to do to keep the compiler happy. Help please?
Here is some sample files: Main.cpp
SPI spi(p5, p6, p7); mosi, miso, sclk
int main() {
spi.format(16,0);
spi.frequency(1000000); }
----------myproj.hvoid somefunc(uint16_t val);
----------otherfile.cppvoid somefunc(uint16_t val) {
spi.write(val);
}