embeded/i2c2018. 4. 26. 15:05


[링크 : https://www.i2c-bus.org/]


10bit address

0b11110xxM 0bxxxxxxxx

M은 Read/Write

xx 총 10비트로 7비트에서 확장하여 장치를 더 많이 사용 가능함

RW는 첫 바이트(?)에만 나오므로 두번째 바이트는 기존에 장치 register address로 쓰이던 부분임

0x78~ 0x7B(120~123) 주소로 시작하면 10비트 어드레싱으로 간주하면 된다


7비트 addressing 일 경우

0~127 까지 가능한데 그럼 7비트랑 10비트랑 어떻게 구분해야 하려나?

[링크 : https://www.i2c-bus.org/addressing/10-bit-addressing/]



반복 start 상태는 

ACK 받은 후 STOP으로 진행후 idle로 빠지는게 아니라

ACK 받은 후 START로 진행후 한번더 전송하는 상태이다.

[링크 : https://www.i2c-bus.org/repeated-start-condition/]



---

버스트

[링크 : https://blog.naver.com/specialist0/220645221966]

'embeded > i2c' 카테고리의 다른 글

i2cdump  (0) 2024.12.11
linux i2c 예제  (0) 2022.12.27
i2c mode - tm4c  (0) 2018.04.26
i2c BUS에 pull-up, pull-down  (0) 2018.04.26
i2c bank switching  (0) 2015.09.02
Posted by 구차니

회사 근처에 약국이 음슴

레알 없음


(가장 가까운게 직선거리 800m)


암튼 병원가긴 시간이 애매해서

약국가서 침 넘기는데 아프다고 하니 약팔이 시작하는데



나 : 아 가루약 빼주세요(정체 불명의 그 한약 과립)

약사 : 알약만 먹어서는 안나아. 이거 먹어야 나아

나 : 어짜피 약국에서 처방전 없이 항생제 안되잖아요

약사 : 아냐 이거에 항생제 들어있어. 자 사인.

(한 8천원나옴. 알약 10개 들이 한상자 + 정체불명 5포)


나 : 이 돈이면 병원가는게 낫겠네요. 주사도 맞고

약사 : 병원가면 2시간은 기다려야 하잖아. 똑같아

나 : !!! (나... 납득 오... 케이?)

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

멘탈 와사삭  (2) 2018.05.03
어제 장거리 외근... 기아 레이 밴  (0) 2018.05.01
신용카드 추천..  (2) 2018.04.25
아 일하기 싫다  (0) 2018.03.22
왕피곤..  (0) 2018.03.17
Posted by 구차니

아내 친구가


학군 변경되는 시점에 고점에 팔고, 새로운데로 이사갔다는데

반대로 생각해보니...


요즘 출산률은 바닥을 찍고 있고

급속도로 인구가 깔대기 모양을 찍고 있는데

지금 우리 아이가 고등학교 학군을 중요시 여길 시점에는 (그러니까 한 10년 이후?)

교사가 학생보다 많아지고

일부 대도시를 제외하면 학교가 통폐합 당해서

결국에는 학군의 의미 자체가 사라지지 않을까?


그리고 그에 따라 학군의 프리미엄이 사라지니

(물론 등하교 문제로 인한 약간의 프리미엄은 있겠지만)

그에 따른 집값 하락도 추가도 발생하지 않을까?


그리고 학생수가 줄어드니

학교에서 등하교 지원을 하게 될지도?

(워낙 먼데서 부터 와야 하는데 교사는 남아 도니까?)

Posted by 구차니
embeded/i2c2018. 4. 26. 12:31

데이터시트 내용중에

Four I2C modes
– Master transmit
– Master receive
– Slave transmit
– Slave receive 
 

요런게 보이는데, 풀어 쓰다면

마스터 모드 - master가 slave로 전송 / slave가 master로 부터 받기

마스터 모드 - slave가 master로 전송 / master가 slave로 부터 받기

슬레이브 모드 - slave가 master로 전송 / master가 slave로 부터 받기

슬레이브 모드 - master가 slave로 전송 / slave가 master로 부터 받기 

요렇게 해석이 가능하다.


I2C 통신은 아래와 같이 이루어 지는데 Master에 의해서 SCL이 생성되고
마스터에 의해서 통신이 시작되고(START)

마스터가 쓰는 데이터 = 통신할 slave의 주소 + Read/Write(혹은 Receive/Send) 

슬레이브의 응답 = ACK
마스터가 쓰는 데이터 = slave의 register 주소
슬레이브의 응답 = ACK
마스터가 쓰는 데이터 = register의 data
슬레이브의 응답 = ACK

마스터에 의해서 통신이 종료되게 된다.(STOP)


 

I2C 레지스터 관련 내용 





Driverlib에 정의된 내용

#define I2C_MASTER_CMD_SINGLE_SEND                                            \

                                0x00000007

#define I2C_MASTER_CMD_SINGLE_RECEIVE                                         \

                                0x00000007

#define I2C_MASTER_CMD_BURST_SEND_START                                       \

                                0x00000003

#define I2C_MASTER_CMD_BURST_SEND_CONT                                        \

                                0x00000001

#define I2C_MASTER_CMD_BURST_SEND_FINISH                                      \

                                0x00000005

#define I2C_MASTER_CMD_BURST_SEND_STOP                                        \

                                0x00000004

#define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP                                  \

                                0x00000004

#define I2C_MASTER_CMD_BURST_RECEIVE_START                                    \

                                0x0000000b

#define I2C_MASTER_CMD_BURST_RECEIVE_CONT                                     \

                                0x00000009

#define I2C_MASTER_CMD_BURST_RECEIVE_FINISH                                   \

                                0x00000005

#define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP                               \

                                0x00000004

#define I2C_MASTER_CMD_QUICK_COMMAND                                          \

                                0x00000027

#define I2C_MASTER_CMD_HS_MASTER_CODE_SEND                                    \

                                0x00000013

#define I2C_MASTER_CMD_FIFO_SINGLE_SEND                                       \

                                0x00000046

#define I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE                                    \

                                0x00000046

#define I2C_MASTER_CMD_FIFO_BURST_SEND_START                                  \

                                0x00000042

#define I2C_MASTER_CMD_FIFO_BURST_SEND_CONT                                   \

                                0x00000040

#define I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH                                 \

                                0x00000044

#define I2C_MASTER_CMD_FIFO_BURST_SEND_ERROR_STOP                             \

                                0x00000004

#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_START                               \

                                0x0000004a

#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_CONT                                \

                                0x00000048

#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH                              \

                                0x00000044

#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_ERROR_STOP                          \

                                0x00000004


#define I2C_O_MCS               0x00000004  // I2C Master Control/Status 


void

I2CMasterControl(uint32_t ui32Base, uint32_t ui32Cmd)

{

    //

    // Check the arguments.

    //

    ASSERT(_I2CBaseValid(ui32Base));

    ASSERT((ui32Cmd == I2C_MASTER_CMD_SINGLE_SEND) ||

           (ui32Cmd == I2C_MASTER_CMD_SINGLE_RECEIVE) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_START) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_CONT) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_FINISH) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_ERROR_STOP) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_START) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_CONT) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_FINISH) ||

           (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP) ||

           (ui32Cmd == I2C_MASTER_CMD_QUICK_COMMAND) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_SINGLE_SEND) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_SEND_START) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_SEND_CONT) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_SEND_ERROR_STOP) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_RECEIVE_START) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_RECEIVE_CONT) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH) ||

           (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_RECEIVE_ERROR_STOP) ||

           (ui32Cmd == I2C_MASTER_CMD_HS_MASTER_CODE_SEND));


    //

    // Send the command.

    //

    HWREG(ui32Base + I2C_O_MCS) = ui32Cmd;



값대로 정렬하면 아래처럼 나오는데

CONT 0x01

START 0x03

STOP 0x04

FINISH 0x05

_SINGLE_ 0x07

로 끝나게 된다.


I2C_MASTER_CMD_BURST_SEND_CONT 0x00000001


I2C_MASTER_CMD_BURST_SEND_START 0x00000003


I2C_MASTER_CMD_BURST_SEND_STOP 0x00000004

I2C_MASTER_CMD_BURST_SEND_ERROR_STOP 0x00000004

I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP 0x00000004

I2C_MASTER_CMD_FIFO_BURST_SEND_ERROR_STOP 0x00000004

I2C_MASTER_CMD_FIFO_BURST_RECEIVE_ERROR_STOP 0x00000004


I2C_MASTER_CMD_BURST_SEND_FINISH 0x00000005

I2C_MASTER_CMD_BURST_RECEIVE_FINISH 0x00000005


I2C_MASTER_CMD_SINGLE_SEND 0x00000007

I2C_MASTER_CMD_SINGLE_RECEIVE 0x00000007


I2C_MASTER_CMD_BURST_RECEIVE_CONT 0x00000009

I2C_MASTER_CMD_BURST_RECEIVE_START 0x0000000b


I2C_MASTER_CMD_HS_MASTER_CODE_SEND 0x00000013


I2C_MASTER_CMD_QUICK_COMMAND 0x00000027

I2C_MASTER_CMD_FIFO_BURST_SEND_CONT 0x00000040

I2C_MASTER_CMD_FIFO_BURST_SEND_START 0x00000042

I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH 0x00000044

I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH 0x00000044

I2C_MASTER_CMD_FIFO_SINGLE_SEND 0x00000046

I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE 0x00000046

I2C_MASTER_CMD_FIFO_BURST_RECEIVE_CONT 0x00000048

I2C_MASTER_CMD_FIFO_BURST_RECEIVE_START 0x0000004a 



+

데이터시트에는 존재하지 않는 오프셋 주소다.. ㄷㄷ

burst mode랑 multibyte랑 다른거 같긴한데 모르겠네..

#define I2C_O_MBLEN             0x00000030  // I2C Master Burst Length

#define I2C_O_MBCNT             0x00000034  // I2C Master Burst Count 


I2CMCS에 write 레지스터는.. 0x10까지만 공개되어 있네?

#define I2C_MCS_BURST           0x00000040  // Burst Enable 


공개가 안된건.. 해당 칩셋에서는 burst mode 사용불가인거 겠지?



state라고 하긴 애매한데

idle(통신을 잡지 않은 상태)

start (SDA,SCL Low, 통신 시작)

transmit(address LSB에 Write)

receive(address LSB에 Read)

stop (통신을 놓음)

repeat start(통신을 놓지 않고 다른 장치나 주소로 통신)

run (ACK 이후에 stop이나 transmit/recieve로 가는 상태)


이러한 상태들이 존재하게 된다.

그림으로 그리려니 참 애매해지네


그런 이유로... i2c 구현시에 함수들이 uart 처럼 단순하지 않고

토막토막 나있는 것으로 보인다.


I2CMasterControl()은

i2c driver의 state machine을 통제하고

i2c 로직에서는

장치 주소와, 데이터를 가지고 있고

state machine의 값을 이용해

어떤식으로 데이터를 보낼지 결정하게 된다.

(그래서 더 복잡한 듯)


+

2018.04.27

그러니까.. 1 byte를 기준으로 보내는데

바이트 별로 설정을 해줘야하고

그 설정에 통신을 끝낼지 이어서 전송을 할게 있는지를 설정해주는게 은근복잡했던 것..

'embeded > i2c' 카테고리의 다른 글

linux i2c 예제  (0) 2022.12.27
i2c 자료  (0) 2018.04.26
i2c BUS에 pull-up, pull-down  (0) 2018.04.26
i2c bank switching  (0) 2015.09.02
i2c 정리  (4) 2012.01.10
Posted by 구차니
embeded/i2c2018. 4. 26. 12:27

MCU 데이터시트를 보다보니 신기한거(?) 발견

I2C 에서 SCL/SDA에 둘다 풀업이 걸려있다.


그리고 HIGH->LOW로 가면서 통신이 이루어지게 된다.


혹시나 해서 봤는데..

UART 역시 TX 기준 HIGH에서 LOW로 떨어트린 다음 시작하게 된다.


SSI는... LOW에서 HIGH 가네?




아무튼 얼추 주워들은 이야기라 근거, 출처를 아직 못 찾아 봤지만

어떤 의미로 통신은

한쪽에서 전압을 떨구거나 올리는 스위치를 통해 이뤄지는 것이라 pull-up, pull-down이 중요하다고 한다.


I2C의 경우에는 Pull-up으로 통신라인이 구성되고

데이터를 보내기 위해서는 I2C Driver에서 내부적으로 GND로 돌려주는 작업을 하면 

BUS 라인내에서 간단하게 Logical 0과 1을 표현할 수 있고

받는 쪽에서도 rising edge나 falling edge를 탐지하면 인터럽트로 처리가 가능하니

통신이란 거진 이런 양상을 뛰는 걸지도?


SSI같이 Low에서 High로 가는건

Pull-down으로 구성하고, 드라이버 내에서 logical 1을 표현시에는

Driver에 인가되는 Vcc를 스위칭 해주는 것으로 구현될 것으로 추측된다.

'embeded > i2c' 카테고리의 다른 글

i2c 자료  (0) 2018.04.26
i2c mode - tm4c  (0) 2018.04.26
i2c bank switching  (0) 2015.09.02
i2c 정리  (4) 2012.01.10
I2C  (2) 2011.11.28
Posted by 구차니

누나가 쓰고 있다고 추천해줌..

고려해봐야지


KB 파인테크

[링크 : https://card.kbcard.com/CXPRICAC0076.cms?mainCC=a&cooperationcode=04580]


KB 다담

[링크 : https://card.kbcard.com/CXPRICAC0076.cms?mainCC=a&cooperationcode=09169]

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

어제 장거리 외근... 기아 레이 밴  (0) 2018.05.01
침 넘기기 힘들어서 어제 약을 사러 갔던 썰  (4) 2018.04.26
아 일하기 싫다  (0) 2018.03.22
왕피곤..  (0) 2018.03.17
배터리 방전  (0) 2018.03.14
Posted by 구차니
Programming/openGL2018. 4. 25. 09:56

어디였나.. 뷰포트로 두개 하면 된다고 하는데

예전에 내가 스테레오 비전 만든것도 뷰포트였나? 기억이 안나네..


GLvoid display(GLvoid)

{

  glDrawBuffer(GL_BACK);                                   //draw into both back buffers

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);      //clear color and depth buffers


  glDrawBuffer(GL_BACK_LEFT);                              //draw into back left buffer

  glMatrixMode(GL_MODELVIEW);

  glLoadIdentity();                                        //reset modelview matrix

  gluLookAt(-IOD/2,                                        //set camera position  x=-IOD/2

            0.0,                                           //                     y=0.0

            0.0,                                           //                     z=0.0

            0.0,                                           //set camera "look at" x=0.0

            0.0,                                           //                     y=0.0

            screenZ,                                       //                     z=screenplane

            0.0,                                           //set camera up vector x=0.0

            1.0,                                           //                     y=1.0

            0.0);                                          //                     z=0.0

  

  glPushMatrix();

  {

    glTranslatef(0.0, 0.0, depthZ);                        //translate to screenplane

    drawscene();

  }

  glPopMatrix();


  glDrawBuffer(GL_BACK_RIGHT);                             //draw into back right buffer

  glMatrixMode(GL_MODELVIEW);

  glLoadIdentity();                                        //reset modelview matrix

  gluLookAt(IOD/2, 0.0, 0.0, 0.0, 0.0, screenZ,            //as for left buffer with camera position at:

            0.0, 1.0, 0.0);                                //                     (IOD/2, 0.0, 0.0)


  glPushMatrix();

  {

    glTranslatef(0.0, 0.0, depthZ);                        //translate to screenplane

    drawscene();

  }

  glPopMatrix();

  

  glutSwapBuffers();

[링크 : http://www.orthostereo.com/geometryopengl.html]


The default framebuffer contains up to 4 color buffers, named GL_FRONT_LEFT, GL_BACK_LEFT, GL_FRONT_RIGHT, and GL_BACK_RIGHT. The left and right buffers are used for stereoscopic rendering

[링크 : https://www.khronos.org/opengl/wiki/Default_Framebuffer]



glulookat 쓴거 보면 맞는 듯?

기본 컨셉은 비슷한데 위에 예제는 openGL에서 스테레오 스코픽 지원 기능을 쓰고 있는 거군

void display(void)

{

glClear(GL_COLOR_BUFFER_BIT);


glMatrixMode(GL_MODELVIEW); //GL_PROJECTION

glPushMatrix();

glViewport(0, 0, 250, 250); 

gluLookAt(0.10, 0.0, 0.2, 0.0, 0.0, -2.0, 0.0, 1.0, 0.0);

draw_sin();

glPopMatrix();


glPushMatrix();

glViewport(250, 0, 250, 250); 

gluLookAt(0.2, 0.0, 0.2, 0.0, 0.0, -2.0, 0.0, 1.0, 0.0);

draw_sin();

glPopMatrix();


glutSwapBuffers();

2011/10/08 - [Programming/openGL] - openGL의 미스테리...

'Programming > openGL' 카테고리의 다른 글

glfw - gl framework  (0) 2019.05.07
openGL 3.0 tutorial  (0) 2019.05.07
openGL cardboard lens distortion  (0) 2018.04.25
glxgears 소스  (0) 2016.09.07
opencv opengl  (0) 2016.02.26
Posted by 구차니
Programming/openGL2018. 4. 25. 09:52

구글 카드보드 같은거 써서 보려면

영상을 왜곡해야 하는데(왜곡이란 단어부터 생각이 안남... ㅠㅠ)



[링크 : https://stackoverflow.com/questions/44489686/camera-lens-distortion-in-opengl]

[링크 : http://smus.com/vr-lens-distortion/]

[링크 : https://www.opengl.org/discussion_boards/showthread.php/197596-Pincushion-Distortion-with-a-Camera]


+

[링크 : https://github.com/googlevr/gvr-android-sdk/.../videoplayer/VideoScene.java]

[링크 : https://github.com/googlevr/gvr-android-sdk/.../videoplayer/VideoSceneRenderer.java]

[링크 : http://www.freevr.org/downloads.html]

[링크 : https://arm-software.github.io/vr-sdk-for-android/IntroductionToStereoRendering.html] <<<

https://support.google.com/cardboard/manufacturers/answer/6324808?hl=en

'Programming > openGL' 카테고리의 다른 글

openGL 3.0 tutorial  (0) 2019.05.07
openGL Stereoscopic  (0) 2018.04.25
glxgears 소스  (0) 2016.09.07
opencv opengl  (0) 2016.02.26
opengl camera의 이해  (0) 2016.02.02
Posted by 구차니
Programming/openCV2018. 4. 25. 08:44

Odroid U3를 두개 묶어 놓다 보니 든 생각..

한대에서 영상 두개를 받고(USB로)

그 이미지중 하나(그러니까 사람으로 치면 오른눈-오른눈잡이)를 본인이 처리하고

다른쪽 영상 하나를 다른 시스템으로 넘겨서 처리하거나


아니면 각각 하나의 영상을 받아서

처리 결과만 다른쪽으로 넘겨주면 어떨까?


적고 보니 후자가 더 안정적일 수도 있겠네


[링크 : http://pachyderm.readthedocs.io/en/latest/getting_started/beginner_tutorial.html]

'Programming > openCV' 카테고리의 다른 글

opencv cannyedge  (0) 2019.01.16
opencv 원 추정  (0) 2019.01.16
openCV release mode와 debug mode 속도 차이  (0) 2018.03.19
openCV multicore support  (0) 2018.03.19
stitch / opencv / python  (0) 2016.07.18
Posted by 구차니

I2C slave에서 마스터로 전송할 데이터가 생길 경우에는

폴링을 기다리거나, 마스터로 연결된 interrupt 핀이 있어야 한다.


Case 1: Slave has an interrupt pin


You need to connect this interrupt pin to master microcontroller. Every time the slave has some data, it should raise an interrupt. At that point, master will read the available data.


Case 2: Slave doesn't have an interrupt pin


Polling is the only option in this case. Master keeps reading all the slaves at regular interval and keeps comparing the received data with old one. If the data has changed, master will take appropriate action. You need to decide the interval according to your application. 

[링크 : https://electronics.stackexchange.com/questions/307630/slave-wants-to-send-data-to-master-in-i2c/307641]



다만 SMBUS에서는

slave가 mater 처럼 작동하여 호스트(0x08)에게 자신의 주소와 2바이트 정보는 던질 수 있도록 되어있다.

아니면 SMBALERT# 시그널을 통해 주의를 요청인데 이게 인터럽트 라인인 듯?

Arbitration in SMBus

Although conceptually a single-master bus, a slave device that supports the "host notify protocol" acts as a master to perform the notification. It seizes the bus and writes a 3-byte message to the reserved "SMBus Host" address (0x08), passing its address and two bytes of data. When two slaves try to notify the host at the same time, one of them will lose arbitration and need to retry.

An alternative slave notification system uses the separate SMBALERT# signal to request attention. In this case, the host performs a 1-byte read from the reserved "SMBus Alert Response Address" (0x0c), which is a kind of broadcast address. All alerting slaves respond with a data bytes containing their own address. When the slave successfully transmits its own address (winning arbitration against others) it stops raising that interrupt. In both this and the preceding case, arbitration ensures that one slave's message will be received, and the others will know they must retry.

SMBus also supports an "address resolution protocol", wherein devices return a 16-byte "universal device ID" (UDID). Multiple devices may respond; the one with the least UDID will win arbitration and be recognized. 

[링크 : http://www.microchip.com/forums/m/tm.aspx?m=795577&p=1]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

hdmi pinout  (0) 2018.05.29
VGA 관련 자료 검색중  (0) 2018.05.29
haze / defog  (0) 2018.03.19
USB class - DFU(Device Firmware Upgrade)  (0) 2017.12.26
불 대수(bool algebra)  (0) 2017.12.20
Posted by 구차니