Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • avn/swd/skyward-boardcore
  • emilio.corigliano/skyward-boardcore
  • ettore.pane/skyward-boardcore
  • giulia.facchi/skyward-boardcore
  • valerio.flamminii/skyward-boardcore
  • nicolo.caruso/skyward-boardcore
6 results
Select Git revision
Show changes
Showing
with 32 additions and 107 deletions
......@@ -91,22 +91,20 @@ void __attribute__((used)) EXTI2_IRQHandlerImpl()
// Pass timestamp to sensor
if (gyro != nullptr)
{
gyro->IRQupdateTimestamp(currentTimestamp);
}
}
void configure()
{
// Set SPI pins to correct alternate mode
GpioSck::mode(Mode::ALTERNATE);
GpioMiso::mode(Mode::ALTERNATE);
GpioMosi::mode(Mode::ALTERNATE);
GpioSck::alternateFunction(5);
GpioMiso::alternateFunction(5);
GpioMosi::alternateFunction(5);
GpioSck::mode(Mode::ALTERNATE);
GpioMiso::mode(Mode::ALTERNATE);
GpioMosi::mode(Mode::ALTERNATE);
// Setup interrupt pin (sensors pulls INT2 up, so we set it to PULL_DOWN
// to avoid spurious interrupts)
GpioINT2::mode(Mode::INPUT_PULL_DOWN);
......@@ -176,7 +174,5 @@ int main()
printf("\n\n\nend.\n");
for (;;)
{
Thread::sleep(1000);
}
}
......@@ -68,9 +68,7 @@ int main()
printf("Doing self test!\n");
if (!sensor.selfTest())
{
printf("Error: selfTest() returned false!\n");
}
printf("selfTest returned true\n");
printf("Now printing some sensor data:\n");
......
......@@ -65,13 +65,9 @@ int main()
if (!sensor.init())
{
if (sensor.getLastError() == SensorErrors::INVALID_WHOAMI)
{
printf("TEST FAILED: invalid WHO_AM_I value, init failed \n");
}
else
{
printf("TEST FAILED: init failed \n");
}
return -1;
}
......@@ -91,9 +87,7 @@ int main()
sensor.sample();
if (sensor.getLastError() == SensorErrors::NO_NEW_DATA)
{
printf("\nWarning: no new data to be read \n");
}
data = sensor.getLastSample();
......
......@@ -66,9 +66,7 @@ int main()
TRACE("Doing self test!\n");
bool ok = sensor.selfTest();
if (!ok)
{
TRACE("Error: selfTest() returned false!\n");
}
TRACE("Now printing some sensor data:\n");
Thread::sleep(100);
......
......@@ -77,13 +77,9 @@ void sampleOneShotMode(I2C &i2c)
lps28dfw.sample();
if (lps28dfw.getLastError() == SensorErrors::NO_ERRORS)
{
lps28dfw.getLastSample().print(std::cout);
}
else
{
printf("Error: %d\n", lps28dfw.getLastError());
}
Thread::sleep(100);
}
......@@ -112,14 +108,10 @@ void sampleContinuousMode(I2C &i2c)
lps28dfw.sample();
if (lps28dfw.getLastError() == SensorErrors::NO_ERRORS)
{
lps28dfw.getLastSample().print(std::cout);
}
else
{
printf("Error: %d\n", lps28dfw.getLastError());
}
}
printf("End Continuous\n");
}
......@@ -140,24 +132,17 @@ void sampleInterruptMode(I2C &i2c)
for (uint8_t i = 0; i < nSamples; i++)
{
while (!sampleAvailable)
{
waiting->wait();
}
sampleAvailable = false;
lps28dfw.sample();
if (lps28dfw.getLastError() == SensorErrors::NO_ERRORS)
{
lps28dfw.getLastSample().print(std::cout);
}
else
{
printf("Error: %d\n", lps28dfw.getLastError());
}
}
printf("End Interrupt\n");
}
......
......@@ -35,14 +35,10 @@ int main()
LPS331AP lps331(bus);
if (!lps331.init())
{
printf("Init failed\n");
}
if (!lps331.selfTest())
{
printf("Self test failed\n");
}
while (true)
{
......
......@@ -56,7 +56,6 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin,
int main()
{
SPIBus bus(SPI3);
GpioPin csPin(GPIOE_BASE, 3); // PE3 CS
......@@ -115,9 +114,7 @@ int main()
// testFifoFillingTime(bus, csPin, busConfiguration, sensConfig, int2Pin);
while (true)
{
Thread::sleep(5000);
}
return 0;
}
......@@ -205,10 +202,8 @@ void testSampleImplTime(SPIBus& bus, miosix::GpioPin csPin,
{
TRACE("Self test failed\n\n");
while (true)
{
Thread::sleep(2000);
}
}
std::cout << "sensor initialized\n";
while (true)
......@@ -255,10 +250,8 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin,
{
std::cout << "Self test failed\n\n";
while (true)
{
Thread::sleep(2000);
}
}
while (true)
{
......@@ -271,17 +264,15 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin,
}
sens->sample();
const std::array<LSM6DSRXData, LSM6DSRXDefs::FIFO_SIZE>& buf =
sens->getLastFifo();
uint16_t fifoSize;
const auto buf = sens->getLastFifo(fifoSize);
// Print fifo
std::cout << "last fifo element:\n";
buf[sens->getLastFifoSize() - 1].print(std::cout);
std::cout << "last fifo size: " << sens->getLastFifoSize() << "\n";
buf[fifoSize - 1].print(std::cout);
std::cout << "last fifo size: " << fifoSize << "\n";
// Check fifo data
for (uint16_t i = 1; i < sens->getLastFifoSize(); ++i)
for (uint16_t i = 1; i < fifoSize; ++i)
{
// Check for accelerometer timestamps
if (buf[i].accelerationTimestamp <=
......@@ -299,10 +290,8 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin,
// Check that gyr and acc timestamps are equal
if (buf[i].accelerationTimestamp != buf[i].angularSpeedTimestamp)
{
std::cout << "Error, timestamps not equal\n\n";
}
}
std::cout << "Extraction completed\n\n" << std::endl;
Thread::sleep(1000);
......
......@@ -57,9 +57,7 @@ int main()
printf("Starting process verification!\n");
if (!sensor.checkConnected())
{
printf("Sensor not connected!\n");
}
while (true)
{
......
......@@ -52,13 +52,9 @@ int main()
sensor.init();
if (!sensor.checkConnected())
{
printf("The thermocouple is not connected\n");
}
else
{
printf("The thermocouple is connected\n");
}
// Wait for one sample to be made
Thread::sleep(100);
......
......@@ -53,9 +53,7 @@ int main()
printf("Starting process verification!\n");
if (!sensor.selfTest())
{
printf("Sensor self test failed!\n");
}
while (true)
{
......
......@@ -34,14 +34,10 @@ int main()
MS5803I2C ms5803(bus, 10);
if (!ms5803.init())
{
printf("MS5803 Init failed\n");
}
if (!ms5803.selfTest())
{
printf("Self test failed\n");
}
while (true)
{
......
......@@ -44,9 +44,7 @@ int main()
Thread::sleep(100);
if (!sensor.init())
{
printf("MS5803 Init failed\n");
}
Thread::sleep(100);
printf("pressureTimestamp,press,temperatureTimestamp,temp\n");
......
......@@ -32,34 +32,37 @@ using namespace miosix;
#define RATE 4
// USART2: AF7
typedef miosix::Gpio<GPIOA_BASE, 2> u2tx1;
typedef miosix::Gpio<GPIOA_BASE, 3> u2rx1;
int main()
{
printf("Welcome to the ublox test\n");
u2rx1::getPin().alternateFunction(7);
u2rx1::getPin().mode(Mode::ALTERNATE);
u2tx1::getPin().alternateFunction(7);
u2tx1::getPin().mode(Mode::ALTERNATE);
USART usart(USART2, 38400);
// Keep GPS baud rate at default for easier testing
UBXGPSSerial gps(38400, RATE, USART2, 9600);
UBXGPSSerial gps(usart, 38400, RATE, 9600);
UBXGPSData dataGPS;
printf("Gps allocated\n");
// Init the gps
if (gps.init())
{
printf("Successful gps initialization\n");
}
else
{
printf("Failed gps initialization\n");
}
// Perform the selftest
if (gps.selfTest())
{
printf("Successful gps selftest\n");
}
else
{
printf("Failed gps selftest\n");
}
// Start the gps thread
gps.start();
......@@ -67,13 +70,11 @@ int main()
while (true)
{
printf("a\n");
// Give time to the thread
Thread::sleep(1000 / RATE);
// Sample
gps.sample();
printf("b\n");
dataGPS = gps.getLastSample();
// Print out the latest sample
......
......@@ -115,13 +115,9 @@ State HSMUTTest::state_S(const Event& e)
break;
case EV_I:
if (this->foo == false)
{
this->foo = true;
}
else
{
retState = UNHANDLED;
}
break;
case EV_E:
retState = transition(&HSMUTTest::state_S11);
......@@ -236,13 +232,9 @@ State HSMUTTest::state_S2(const Event& e)
break;
case EV_I:
if (this->foo == false)
{
this->foo = true;
}
else
{
retState = UNHANDLED;
}
break;
default:
retState = tranSuper(&HSMUTTest::state_S);
......@@ -307,7 +299,6 @@ State HSMUTTest::state_S211(const Event& e)
int main()
{
EventBroker::getInstance().start();
HSMUTTest& hsm = HSMUTTest::getInstance();
......
......@@ -110,14 +110,10 @@ void testCommunication(char *data, USARTInterface &src, USARTInterface &dst)
t.join();
if (strcmp(data, rcv) == 0)
{
printf("*** %d -> %d WORKING!\n", src.getId(), dst.getId());
}
else
{
printf("### ERROR: %d -> %d!\n", src.getId(), dst.getId());
}
}
int main()
{
......
......@@ -40,7 +40,6 @@ using namespace std;
// Data produced by the MySensor sensor.
struct MySensorData : public PressureData, public TemperatureData
{
MySensorData() : PressureData{0, 0.0}, TemperatureData{0, 0.0} {}
MySensorData(float p, float t)
......@@ -95,7 +94,6 @@ private:
struct MySensorDataFIFO : public AccelerometerData, public GyroscopeData
{
MySensorDataFIFO()
: AccelerometerData{TimestampTimer::getTimestamp(), 0.0, 0.0, 0.0},
GyroscopeData{TimestampTimer::getTimestamp(), 0.0, 0.0, 0.0}
......@@ -160,19 +158,18 @@ public:
FIFOData sampleImpl()
{
index = 0;
return sensor->getFifoElement(index);
uint16_t actualFifoSize;
return sensor->getLastFifo(actualFifoSize)[index];
}
FIFOData getLastSample() override
{
if (index < FifoSize - 1)
{
index++;
}
TRACE("Index : %d \n", index);
return sensor->getFifoElement(index);
uint16_t actualFifoSize;
return sensor->getLastFifo(actualFifoSize)[index];
}
private:
......
......@@ -46,9 +46,7 @@ int main()
LOG_ERR(logger, "This is a message {}", 52);
LOG_INFO(log2, "Ops, there was an {}!", "error");
for (int i = 0; i < 4; i++)
{
LOG_INFO(log4, "This is an async log! {:d}", asyncCtr++);
}
LOG_DEBUG(log3, "This is a verbose debug message {:.3f}", 1.234f);
LOG_CRIT(log3, "Float {:.1f} {:05.2f} {:f}", 1.234f, 1234.1234,
-9876.98765432f);
......