Skip to content

Commit

Permalink
[docooler] first init
Browse files Browse the repository at this point in the history
  • Loading branch information
docooler committed Aug 29, 2017
0 parents commit 573ecb6
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 0 deletions.
Binary file added bin/obj/common.o
Binary file not shown.
Binary file added bin/obj/main.o
Binary file not shown.
Binary file added bin/tmf
Binary file not shown.
47 changes: 47 additions & 0 deletions inc/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*!
* A power value in Watt.
* Resolution: 1 Watt.
*/


struct Watt
{

private:
int watt;

public:
/*!
* Initialize a watt value from a U16.
* 1 W = Watt(1)
*/
explicit Watt(int watt);
/*!
* Get the number of watts as a U16.
*/
int getWatt();

Watt();
};

struct dBm
{
private:
/*!
* The actual dB-value in units of 0.1 dB.
* I.e, if db has the numerical value 42,
* that means 4.2 dB.
*/
int dbm;

public:

dBm();
explicit dBm(float powerdBm);

/*!
* Construct a dBm value given a Watt value
* Conversion is given by 10*log10(Watt)+30
*/
static dBm fromWatt(Watt w);
};
14 changes: 14 additions & 0 deletions make/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# UNIX Makefile

PROJ_DIR = /home/docooler/workspace/c_plus_plus/name_define

#var makefile
include config.Makefile

#module makefile
include $(PROJ_DIR)/sw/swModule.Makefile

#target makefile
include targets.Makefile


7 changes: 7 additions & 0 deletions make/config.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

CXX = g++
LD = g++
CXXFLAGS = -g

BIN_DIR = $(PROJ_DIR)/bin
OBJ_DIR = $(BIN_DIR)/obj
11 changes: 11 additions & 0 deletions make/targets.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
help:
@echo $(OBJ)
all: $(OBJ)
@$(LD) -o $(BIN_DIR)/tmf $(OBJ)

run: all
@$(BIN_DIR)/tmf

clean:
echo "$(RM)"
$(RM) $(OBJ) $(BIN_DIR)/tmf
31 changes: 31 additions & 0 deletions sw/common.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include"common.h"

Watt::Watt(int watt)
{
this->watt = watt;
}

Watt::Watt()
{
this->watt = 0;
}

int Watt::getWatt()
{
return watt;
}

dBm::dBm()
{
dbm = -0x8000;
}
dBm::dBm(float powerdBm)
{
dbm = static_cast<int>(10.0f * powerdBm);
}

dBm dBm::fromWatt(Watt w)
{
dBm db;
return db;
}
12 changes: 12 additions & 0 deletions sw/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include "common.h"

using namespace std;

int main(int argc, char const *argv[])
{
Watt w(13);
cout <<w.getWatt()<<endl;

return 0;
}
12 changes: 12 additions & 0 deletions sw/swModule.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
INCLUDE = -I$(PROJ_DIR)/inc
TOTAL_FILE = main.cc \
common.cc

OBJ = $(TOTAL_FILE:%.cc=$(OBJ_DIR)/%.o)

swobj:$(OBJ)
@echo "make obj"

$(OBJ_DIR)/%.o: $(PROJ_DIR)/sw/%.cc
@mkdir -p $(@D)
@$(CXX) -c $(INCLUDE) -o $@ $<
Binary file added sw/test
Binary file not shown.
10 changes: 10 additions & 0 deletions sw/test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<iostream>

using namespace std;


int main(int argc, char const *argv[])
{
cout<<"hello world"<<endl;
return 0;
}

0 comments on commit 573ecb6

Please sign in to comment.