aiopx.blogg.se

Unity cmock tutorial
Unity cmock tutorial








unity cmock tutorial
  1. UNITY CMOCK TUTORIAL HOW TO
  2. UNITY CMOCK TUTORIAL DRIVER
  3. UNITY CMOCK TUTORIAL CODE
unity cmock tutorial

The temperature value is given in two registers.

UNITY CMOCK TUTORIAL HOW TO

Because the goal is that you understand how to use CMock.

unity cmock tutorial

We’re going to focus on applying TDD to the last functionality. Convert the value of the registers to temperature values.Send an OS event to do a temperature measurement.

UNITY CMOCK TUTORIAL DRIVER

The driver for the temperature sensor should do the following: It’s going to make more sense as we progress through this post. The files and their relations are in the following picture. DA14681 microcontroller will run eventually the temperature driver.įor this post we need to create 5 files. The library we will use is i2c_adapter.h from dialog microcontrollers. We are going to develop a part of the Si7060 temperature sensor driver, which uses I2C communication protocol.

  • project.yml is ceedling configuration file.
  • UNITY CMOCK TUTORIAL CODE

  • code is where your sources, includes and testing files are.
  • ExampleCode is the base code to start with. Test-Driven Development (TDD) with ceedling CMock Tutorial If you want to know more about Ceedling and TDD. Instead you will use the mock version (dashed lines).ĬMock comes with Ceedling. When you run your tests you won’t use the original library. In that way, you won’t need the hardware to test your code. What’s CMock?ĬMock is a tool from that can help you mocking or emulating libraries’ behaviors. And the output you expect the library gives to you. In the end, you only have to know what are the inputs the library wants. So basically you’ll interact only with the library. That’s the job of the library i2c_adapter.h. You don’t write code that directly interacts with those SDA, SCL and I2C protocol. In this case, the SDA is P1_2 (pin 1, port2) and SCL is P1_4. Let’s say you want to use I2C bus available in your microcontroller. Look at the picture to have a better idea: Nowadays is common to use libraries to interact with GPIOs (General-purpose input/output) and communication interfaces like I2C, SPI or ADCs. Understanding Hardware Dependency What do you need to break hardware dependencies? You can find great books in our curated booklist. The concepts you’ll read here are from the book Test-driven development for embedded C. So you would deal with a bigger problem.ģ) You don’t need the hardware as much as you think. “I need to run my code on hardware to make sure my code works”…ġ) The hardware may not be ready or available whenever you need it.Ģ) The hardware may have also bugs. Today, you’ll learn to test your code without hardware. This is the third post in our Test-Driven Development journey.










    Unity cmock tutorial