5 Sending a USB PD message The general steps of transmitting a SOP* message are listed below. Please consult sections 4.7.1, 4.7.2, and 4.7.3 of the TCPC specification[3] for more detailed implementation and examples. • Step 0: TCPM writes the content of the message to be transmitted into the TRANSMIT_BUFFER • Step 1: TCPM writes to TRANSMIT requesting SOP* transmission • Step 2: The outcome reported by the TCPC may be one of three indications after asserting the Alert# pin: – If the TCPC PHY layer successfully transmits the message, the TCPC sets the Transmission Successful bit in the ALERT register. – If the TCPC PHY layer did not get any response after retries, the TCPC sets the Transmission Failed bit in the ALERT register. – If the transmission was discarded due to an incoming message, the TCPC sets the Transmission Discarded bit in the ALERT register. • Step 3: Before requesting another transmission, the TCPM shall clear the alert by writing a 1 to the asserted bit in the ALERT register. When transitioning through the steps of transmitting SOP* message, TCPC may assert ALERT.ReceiveStatus or ALERT.ReceivedHardReset bit at any time to notify that a message was received.
4.7 USB PD Communication Operational Model 4.7.1 Transmitting an SOP* USB PD Message with Less than or Equal to 128 Data Bytes 4.7.2 Transmitting an SOP* USB PD Message with Greater than 128 Data Bytes 4.7.3 Transmitting a Hard Reset Message
상자는 세로, 가로로 쓸 문자만 넣어주면 되는 듯. 터미널 사이즈에 따른 동적 변화는 따로 찾아봐야겠네.
#include <ncurses.h>
int main(void){ initscr(); start_color(); init_color(1, 0, 1000, 0); // 1번 색상(글자색): 초록색 init_color(2, 0, 0, 1000); // 2번 색상(배경색): 파랑색 init_pair(1, 1, 2); // 1번 Color pair를 초록 글자색과 파랑 배경색으로 지정
WINDOW * win = newwin(20, 20, 10, 10); box(win, '|', '-'); waddch(win, 'A' | COLOR_PAIR(1)); // 1번 Color pair를 적용해 문자 출력
refresh(); wrefresh(win); getch(); endwin(); }
start_color() 로 색상을 사용할 수 있도록 설정하고
init_color(index, , , ,)로 팔레트를 초기화 하고
attron(attribute on), attroff(attribute off) 함수로 색상을 적용/해제 한다.